| decorrelate | R Documentation |
Apply the spatial decorrelation transformation for point-referenced data, allowing for random effects, anisotropy, partition factors, and big data methods.
decorrelate(
formula,
data,
spcov_type,
spcov_params,
xcoord,
ycoord,
algorithm = "ranger",
statistic = "RMSPE",
training,
evaluate_test,
anisotropy = FALSE,
random,
randcov_params,
partition_factor,
ordering,
local,
grid,
dense_grid,
...
)
## S3 method for class 'decorrelate_grid'
tidy(x, sort_by, decreasing, ...)
formula |
A two-sided linear formula describing the fixed effect structure
of the model, with the response to the left of the |
data |
A data frame or |
spcov_type |
The spatial covariance type. Available options include
|
spcov_params |
An object from |
xcoord |
The name of the column in |
ycoord |
The name of the column in |
algorithm |
The machine learning algorithm applied. Available options
include |
statistic |
The statistic used to evaluate fit in the test data. Available options
include |
training |
An list controlling how the training and test data are assigned when evaluating test data performance. The following arguments detail this process:
If omitted, |
evaluate_test |
A logical indicating whether a grid should be constructed
and evaluated when spatial decorrelation parameters are known (i.e.,
|
anisotropy |
A logical indicating whether (geometric) anisotropy should
be modeled. Not required if the |
random |
A one-sided linear formula describing the random effect structure
of the model. Terms are specified to the right of the |
randcov_params |
An object from |
partition_factor |
A one-sided linear formula with a single term specifying the partition factor. The partition factor assumes observations from different levels of the partition factor are uncorrelated. |
ordering |
The data ordering applied. Available options
include |
local |
A optional logical or list controlling the big data approximation.
If omitted,
When |
grid |
An explicit grid of parameter values by which to evaluate fit. The
names of |
dense_grid |
If |
... |
Other arguments to the functions called by |
x |
An object from |
sort_by |
Sort by a specific row in |
decreasing |
Whether |
The spatial decorrelation transformation is a preprocessing transformation that reduces the impacts of spatial dependence (i.e., covariance, correlation) on machine learning models. Predictions are made on the decorrelated scale and then recorrelated to account for spatial dependence. See Heaton et al., 2025 for details.
spcov_type Details: The correlation matrix R controls the spatial dependence structure
among observations. Parametric forms for R are given below, where \eta = h / range
for h distance between observations:
exponential: exp(- \eta )
spherical: (1 - 1.5\eta + 0.5\eta^3) * I(h <= range)
gaussian: exp(- \eta^2 )
triangular: (1 - \eta) * I(h <= range)
circular: (1 - (2 / \pi) * (m * sqrt(1 - m^2) + sin^{-1}(m))) * I(h <= range), m = min(\eta, 1)
cubic: (1 - 7\eta^2 + 8.75\eta^3 - 3.5\eta^5 + 0.75\eta^7) * I(h <= range)
pentaspherical: (1 - 1.875\eta + 1.25\eta^3 - 0.375\eta^5) * I(h <= range)
cosine: cos(\eta)
wave: sin(\eta) / \eta * I(h > 0) + I(h = 0)
jbessel: Bj(h * range), Bj is Bessel-J function
gravity: (1 + \eta^2)^{-0.5}
rquad: (1 + \eta^2)^{-1}
magnetic: (1 + \eta^2)^{-1.5}
matern: 2^{1 - extra}/ \Gamma(extra) * \alpha^{extra} * Bk(\alpha, extra), \alpha = (2extra)^{0.5} * \eta, Bk is Bessel-K function with order 1/5 \le extra \le 5
cauchy: (1 + \eta^2)^{-extra}, extra > 0
pexponential: exp(h^{extra}/range), 0 < extra \le 2
none: 0
All spatial covariance functions are valid in one spatial dimension. All
spatial covariance functions except triangular and cosine are
valid in two dimensions. An alias for none is ie.
anisotropy Details: By default, all spatial covariance parameters except rotate
and scale as well as all random effect variance parameters
are assumed unknown, requiring estimation. If either rotate or scale
are given initial values other than 0 and 1 (respectively)
in spcov_params(), anisotropy is implicitly set to TRUE.
(Geometric) Anisotropy is modeled by transforming a covariance function that
decays differently in different directions to one that decays equally in all
directions via rotation and scaling of the original coordinates. The rotation is
controlled by the rotate parameter in [0, \pi] radians. The scaling
is controlled by the scale parameter in [0, 1]. The anisotropy
correction involves first a rotation of the coordinates clockwise by rotate and then a
scaling of the coordinates' minor axis by the reciprocal of scale. The spatial
covariance is then computed using these transformed coordinates.
random Details: If random effects are used (the estimation method must be "reml" or
"ml"), the model
can be written as y = X \beta + Z1u1 + ... Zjuj + \tau + \epsilon,
where each Z is a random effects design matrix and each u is a random effect.
partition_factor Details: The partition factor can be represented in matrix form as P, where
elements of P equal one for observations in the same level of the partition
factor and zero otherwise. The covariance matrix involving only the
spatial and random effects components is then multiplied element-wise
(Hadmard product) by P, yielding the final covariance matrix.
training Details: When replicate or the number of cross validation folds is at
least two, there are separate grids evaluated for each replication (or fold). Statistics in each grid are
averaged across replications (or folds) to determine a final grid ranked by statistic.
local Details: The big data approximation works by leveraging the
conditional nature of the spatial decorrelation transformation via the
Vecchia approximation. The Vecchia approximation enables efficient computation
of the conditional distribution by considering only the size most relevant
observations in the ordering (rather than using all the observations).
Observations with NA response values are removed for model
fitting, but their values can be predicted afterwards by running
predict(object).
A list with many elements that store information about the fitted model object:
algorithm: The machine learning algorithm used.
decorrelate_data: The output of decorrelate_data() applied to data.
fit: The fitted machine learning model object applied to the decorrelated data.
grid: If used, the grid of spatial decorrelation parameters evaluated and their corresponding
metrics when applied to the test data.
newdata: The rows of data that have NA response values and are stored as prediction data.
training: If used, the observations assigned to each training and test data set.
test: If used, a list with the lowest (absolute) mean bias (bias), mean-squared-prediction error (MSPE),
root-mean-squared-prediction error (RMSPE), and predictive R-squared (cor2).
Matthew J. Heaton, Andrew Millane, and Jake S. Rhodes. 2025. A Scalable Spatial Decorrelation Preprocessing Approach for Machine and Deep Learning. Journal of Data Science. 1-15, DOI 10.6339/25-JDS1210
decorr <- decorrelate(log_cond ~ temp, data = lake, spcov_type = "exponential")
tidy(decorr$grid)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.