Apply the spatial decorrelation transformation to a newdata object. This object contains explanatory variables that are transformed for prediction accoring to some spatial decorrelation transformation.
decorrelate_newdata(object, newdata, local, ...)A list with many elements that store information about the fitted model object. Importantly, the list contains the following element:
X_newdata: The original fixed effects design matrix (of explanatory variables) for the prediction data.
tX_newdata: The spatially decorrelated fixed effects design matrix for the prediction data.
A decorrelate_data() object.
A data frame or sf object in which to
look for variables with which to predict. If a data frame, newdata
must contain all variables used by formula(object) and all variables
representing coordinates. If an sf object, newdata must contain
all variables used by formula(object) and coordinates are obtained
from the geometry of newdata. If omitted, missing data from the
fitted model object are used.
A optional logical or list controlling the big data approximation.
If omitted, local is set
to TRUE or FALSE based on the sample size (the number of
non-missing observations in data) -- if the sample size exceeds 5,000,
local is set to TRUE. Otherwise it is set to FALSE.
If local is FALSE, no big data approximation
is implemented. If a list is provided, the following arguments detail the big
data approximation:
method: The big data approximation method. If method = "all",
all observations are used and size is ignored. If method = "distance",
the size data observations closest (in terms of Euclidean distance)
to the observation requiring prediction are used.
If method = "covariance", the size data observations
with the highest covariance with the observation requiring prediction are used.
If random effects and partition factors are not used in estimation and
the spatial covariance function is monotone decreasing,
"distance" and "covariance" are equivalent. The default
is "covariance".
size: The number of data observations to use when method
is "distance" or "covariance". The default is 30.
parallel: If TRUE, parallel processing via the
parallel package is automatically used. This can significantly speed
up computations even when method = "all" (i.e., no big data
approximation is used), as predictions
are spread out over multiple cores. The default is FALSE.
ncores: If parallel = TRUE, the number of cores to
parallelize over. The default is the number of available cores on your machine.
When local is a list, at least one list element must be provided to
initialize default arguments for the other list elements.
If local is TRUE, defaults for local are chosen such
that local is transformed into
list(size = 30, method = "covariance", parallel = FALSE).
Other arguments.
params <- spcov_params("exponential", de = 1, ie = 0.2, range = 1e5)
decorr <- decorrelate_data(log_cond ~ temp, data = lake, spcov_params = params)
decorr_newdata <- decorrelate_newdata(decorr, newdata = lake_preds)
head(decorr_newdata$tX_newdata)
Run the code above in your browser using DataLab