Fit random forest spatial residual models for point-referenced data (i.e., geostatistical models) using random forest to fit the mean and a spatial linear model to fit the residuals. The spatial linear model fit to the residuals can incorporate variety of estimation methods, allowing for random effects, anisotropy, partition factors, and big data methods.
splmRF(formula, data, ...)A two-sided linear formula describing the fixed effect structure
of the model, with the response to the left of the ~ operator and
the terms on the right, separated by + operators.
A data frame or sf object object that contains
the variables in fixed, random, and partition_factor
as well as geographical information. If an sf object is
provided with POINT geometries, the x-coordinates and y-coordinates
are used directly. If an sf object is
provided with POLYGON geometries, the x-coordinates and y-coordinates
are taken as the centroids of each polygon.
Additional named arguments to ranger::ranger() or splm().
A list with several elements to be used with predict(). These
elements include the function call (named call), the random forest object
fit to the mean (named ranger),
the spatial linear model object fit to the residuals
(named splm or splm_list), and an object can contain data for
locations at which to predict (called newdata). The newdata
object contains the set of
observations in data whose response variable is NA.
If spcov_type or spcov_initial (which are passed to splm())
are length one, the list has class splmRF and the spatial linear
model object fit to the residuals is called splm, which has
class splm. If
spcov_type or spcov_initial are length greater than one, the
list has class splmRF_list and the spatial linear model object
fit to the residuals is called splm_list, which has class splm_list.
and contains several objects, each with class splm.
An splmRF object to be used with predict(). There are
three elements: ranger, the output from fitting the mean model with
ranger::ranger(); splm, the output from fitting the spatial
linear model to the ranger residuals; and newdata, the newdata
object, if relevant.
The random forest residual spatial linear model is described by
Fox et al. (2020). A random forest model is fit to the mean portion of the
model specified by formula using ranger::ranger(). Residuals
are computed and used as the response variable in an intercept-only spatial
linear model fit using splm(). This model object is intended for use with
predict() to perform prediction, also called random forest
regression Kriging.
This function does not perform any internal scaling. If optimization is not stable due to large extremely large variances, scale relevant variables so they have variance 1 before optimization.
Fox, E.W., Ver Hoef, J. M., & Olsen, A. R. (2020). Comparing spatial regression to random forests for large environmental data sets. PloS one, 15(3), e0229509.
# \donttest{
sulfate$var <- rnorm(NROW(sulfate)) # add noise variable
sulfate_preds$var <- rnorm(NROW(sulfate_preds)) # add noise variable
sprfmod <- splmRF(sulfate ~ var, data = sulfate, spcov_type = "exponential")
predict(sprfmod, sulfate_preds)
#> 1 2 3 4 5 6 7
#> -3.5177428 26.5058296 19.6072045 21.2316850 9.0470650 37.5294026 -1.2947288
#> 8 9 10 11 12 13 14
#> 19.2008321 11.0858351 13.2948892 5.8104916 13.8861231 -3.6343146 17.9481835
#> 15 16 17 18 19 20 21
#> 24.0006918 18.0632608 16.3643709 9.1794410 -5.1378418 17.6770884 -2.6628383
#> 22 23 24 25 26 27 28
#> 1.3005035 2.2005469 8.5576662 10.9395243 -1.4181838 23.9507396 9.1824453
#> 29 30 31 32 33 34 35
#> 27.1993757 20.3576288 2.7037135 14.5496507 9.2441496 -1.9206175 1.1251662
#> 36 37 38 39 40 41 42
#> 7.6079874 21.5627132 19.5004855 4.6284697 9.0969723 14.1300503 30.1854797
#> 43 44 45 46 47 48 49
#> 15.4537651 29.7662389 -1.5739942 9.5033811 15.0452138 21.1082273 15.4678720
#> 50 51 52 53 54 55 56
#> 2.8670163 22.5238999 17.5879710 6.6241926 -0.5469381 4.2803922 15.1157787
#> 57 58 59 60 61 62 63
#> 13.8173046 5.1587678 16.7728991 12.3573216 25.4450076 35.5860876 2.7811085
#> 64 65 66 67 68 69 70
#> 8.6537452 23.5906629 3.2931058 0.4758935 12.6478801 2.1605014 9.9345238
#> 71 72 73 74 75 76 77
#> -5.5864343 16.7048072 4.0848293 8.1050154 -5.1697048 -5.6495170 20.3350468
#> 78 79 80 81 82 83 84
#> 1.7881387 11.7552723 15.3853385 25.7404721 -3.4586157 23.9263802 -0.9345473
#> 85 86 87 88 89 90 91
#> 0.3837401 7.5551265 -1.1007337 4.2403237 -1.4441017 25.5579876 17.6534660
#> 92 93 94 95 96 97 98
#> 5.9888315 12.1586875 30.7691911 23.8451200 21.9781206 15.0251815 21.5289242
#> 99 100
#> 8.8713092 13.7642258
# }