R/decorrelate_ssn.R
ssn_decorrelate_grid.RdCreate a spatial decorrelation transformation grid of initial parameters to be evaluated via a grid search.
ssn_decorrelate_grid(
formula,
ssn.object,
tailup_type = "none",
taildown_type = "none",
euclid_type = "none",
nugget_type = "nugget",
tailup_params,
taildown_params,
euclid_params,
nugget_params,
additive,
anisotropy = FALSE,
random,
randcov_params,
dense_grid
)
# S3 method for class 'ssn_decorrelate_grid'
print(x, ...)
# S3 method for class 'ssn_decorrelate_grid'
tidy(x, sort_by, decreasing, ...)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 ssn.object$obs except the
response and geometry column.
A spatial stream network object with class SSN.
Covariance types
specified as in ssn_lm().
Known
covariance parameter objects to be used in the spatial decorrelation
transformation. See tailup_params(), taildown_params(),
euclid_params(), and nugget_params().
Additive-function variable for the tail-up covariance, as in ssn_lm().
A logical indicating whether Euclidean (geometric) anisotropy should
be modeled. Not required if euclid_params is provided with a nonzero
rotate or a scale less than one. When anisotropy is
TRUE, computational times can significantly increase. The default
is FALSE.
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.
An object from spmodel::randcov_params() that contains the
random effect variances used by the spatial decorrelation transformation.
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.
An object from object$grid.
Other arguments to the functions called by algorithm.
Sort by a specific row in x. Fit statistics are
"bias", "MSPE", "RMSPE", and "cor2".
The default is "MSPE".
Whether sort_by should sort by decreasing order? If
sort_by = "cor2", the default is TRUE; otherwise it is FALSE.
A grid of spatial decorrelation parameters stored as a data.frame.
# Copy the mf04p .ssn data to a local directory and read it into R
# When modeling with your .ssn object, you will load it using the relevant
# path to the .ssn data on your machine
copy_lsn_to_temp()
temp_path <- paste0(tempdir(), "/MiddleFork04.ssn")
mf04p <- ssn_import(temp_path, overwrite = TRUE)
grid <- ssn_decorrelate_grid(
Summer_mn ~ ELEV_DEM, mf04p, tailup_type = "exponential",
additive = "afvArea", dense_grid = FALSE
)
#> Error in ssn_decorrelate_grid(Summer_mn ~ ELEV_DEM, mf04p, tailup_type = "exponential", additive = "afvArea", dense_grid = FALSE): could not find function "ssn_decorrelate_grid"
tidy(grid)
#> Error in UseMethod("tidy"): no applicable method for 'tidy' applied to an object of class "function"
# Supply edited rows as grid = custom_grid to ssn_decorrelate().
custom_grid <- grid[1:2, ]
#> Error in grid[1:2, ]: object of type 'closure' is not subsettable
custom_grid$tailup_range <- c(5000, 10000)
#> Error: object 'custom_grid' not found