covmatrix.SSN2 {SSN2} | R Documentation |
Create a covariance matrix
Description
Create a covariance matrix from a fitted model object.
Usage
## S3 method for class 'ssn_lm'
covmatrix(object, newdata, cov_type, ...)
## S3 method for class 'ssn_glm'
covmatrix(object, newdata, cov_type, ...)
Arguments
object |
A fitted model object (e.g., ssn_lm() or ssn_glm() ).
|
newdata |
If omitted, the covariance matrix of
the observed data is returned. If provided, newdata is
a data frame or sf object that contains coordinate information
required to construct the covariance between newdata and
the observed data. If a data frame, newdata
must contain variables that represent coordinates having the same name as
the coordinates from the observed data used to fit object . If an
sf object, coordinates are obtained from the geometry of newdata .
|
cov_type |
The type of covariance matrix returned. If newdata
is omitted, the n \times n covariance matrix of the observed
data is returned, where n is the sample size used to fit object .
If newdata is provided and cov_type is "pred.obs" (the default),
the m \times n covariance matrix of the predicted and observed data is returned,
where m is the number of observations in the prediction data.
If newdata is provided and cov_type is "obs.pred" ,
the n \times m covariance matrix of the observed and prediction data is returned.
If newdata is provided and cov_type is "pred.pred" ,
the m \times m covariance matrix of the prediction data is returned.
|
... |
Other arguments. Not used (needed for generic consistency).
|
Value
A covariance matrix (see cov_type
).
Examples
# 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, predpts = "CapeHorn", overwrite = TRUE)
ssn_mod <- ssn_lm(
formula = Summer_mn ~ ELEV_DEM,
ssn.object = mf04p,
tailup_type = "exponential",
additive = "afvArea"
)
covmatrix(ssn_mod)
covmatrix(ssn_mod, "CapeHorn")
[Package
SSN2 version 0.2.1
Index]