covmatrix {spmodel}R Documentation

Create a covariance matrix

Description

Create a covariance matrix from a fitted model object.

Usage

covmatrix(object, newdata, ...)

## S3 method for class 'splm'
covmatrix(object, newdata, ...)

## S3 method for class 'spautor'
covmatrix(object, newdata, ...)

## S3 method for class 'spglm'
covmatrix(object, newdata, ...)

## S3 method for class 'spgautor'
covmatrix(object, newdata, ...)

Arguments

object

A fitted model object (e.g., splm(), spautor(), spglm(), or spgautor()).

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.

...

Other arguments. Not used (needed for generic consistency).

Value

If newdata is omitted, the covariance matrix of the observed data, which has dimension n x n, where n is the sample size used to fit object. If newdata is provided, the covariance matrix between the unobserved (new) data and the observed data, which has dimension m x n, where m is the number of new observations and n is the sample size used to fit object.

Examples

spmod <- splm(z ~ water + tarp,
  data = caribou,
  spcov_type = "exponential", xcoord = x, ycoord = y
)
covmatrix(spmod)

[Package spmodel version 0.7.0 Index]