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 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.
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()
.
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.
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)
# }
Run the code above in your browser using DataLab