Create a spatial decorrelation transformation grid of initial parameters to be evaluated via a grid search.

decorrelate_grid(
  formula,
  data,
  spcov_type,
  spcov_params,
  xcoord,
  ycoord,
  anisotropy = FALSE,
  random,
  randcov_params,
  dense_grid
)

Arguments

formula

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. . on the right-hand side represents every variable in data except the response and the x-coordinate/y-coordinate columns (xcoord/ycoord, or, for an sf object, the geometry column), which are never included via . (though they may still be given explicitly).

data

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.

spcov_type

The spatial covariance type. Available options include "exponential", "spherical", "gaussian", "triangular", "circular", "cubic", "pentaspherical", "cosine", "wave", "jbessel", "gravity", "rquad", "magnetic", "matern", "cauchy", "pexponential", and "none". Parameterizations of each spatial covariance type are available in Details. Multiple spatial covariance types can be provided as a character vector, and then decorrelate() is called iteratively for each element and a list is returned for each model fit. The default for spcov_type is "exponential". When spcov_type is specified, all spatial covariance parameters are estimated. spcov_type is ignored if spcov_params is provided.

spcov_params

An object from spcov_params() that contains the spatial covariance parameters used by the spatial decorrelation transformation.

xcoord

The name of the column in data representing the x-coordinate. Can be quoted or unquoted. Not required if data is an sf object.

ycoord

The name of the column in data representing the y-coordinate. Can be quoted or unquoted. Not required if data is an sf object.

anisotropy

A logical indicating whether (geometric) anisotropy should be modeled. Not required if the rotate and scale parameters in spcov_params() are 0 and 1, respectively. When anisotropy is TRUE, computational times can significantly increase. The default is FALSE.

random

A one-sided linear formula describing the random effect structure of the model. Terms are specified to the right of the ~ operator. Each term has the structure x1 + ... + xn | g1/.../gm, where x1 + ... + xn specifies the model for the random effects and g1/.../gm is the grouping structure. Separate terms are separated by + and must generally be wrapped in parentheses. Random intercepts are added to each model implicitly when at least one other variable is defined. If a random intercept is not desired, this must be explicitly defined (e.g., x1 + ... + xn - 1 | g1/.../gm). If only a random intercept is desired for a grouping structure, the random intercept must be specified as 1 | g1/.../gm. Note that g1/.../gm is shorthand for (1 | g1/.../gm). If only random intercepts are desired and the shorthand notation is used, parentheses can be omitted.

randcov_params

An object from randcov_params() that contains the random effect variances used by the spatial decorrelation transformation.

dense_grid

A logical which controls the density of the constructed grid to be evaluated. If dense_grid is TRUE, a denser grid is used. If dense_grid is FALSE, a sparser grid is used. By default, dense_grid is FALSE when the sample size is greater than 5,000 and TRUE otherwise.

Value

A grid of spatial decorrelation parameters stored as a data.frame.

Examples

decorrelate_grid(log_cond ~ temp, data = lake, spcov_type = "exponential")
#>     spcov_type         de         ie    range rotate scale
#> 1  exponential 1.06861065 0.05624267 150742.8      0     1
#> 2  exponential 0.84363999 0.28121333 150742.8      0     1
#> 3  exponential 0.56242666 0.56242666 150742.8      0     1
#> 4  exponential 0.28121333 0.84363999 150742.8      0     1
#> 5  exponential 0.05624267 1.06861065 150742.8      0     1
#> 6  exponential 1.06861065 0.05624267 452228.3      0     1
#> 7  exponential 0.84363999 0.28121333 452228.3      0     1
#> 8  exponential 0.56242666 0.56242666 452228.3      0     1
#> 9  exponential 0.28121333 0.84363999 452228.3      0     1
#> 10 exponential 0.05624267 1.06861065 452228.3      0     1
#> 11        none 0.00000000 1.00000000      Inf      0     1