Skip to contents

Create a covariance matrix from a fitted model object.

Usage

covmatrix(object, newdata, ...)

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

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

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

# S3 method for 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)
#>             1          2          3          4          5          6          7
#> 1  0.13345875 0.10521027 0.09984818 0.09475938 0.08992992 0.10521027 0.10295515
#> 2  0.10521027 0.13345875 0.10521027 0.09984818 0.09475938 0.10295515 0.10521027
#> 3  0.09984818 0.10521027 0.13345875 0.10521027 0.09984818 0.09862277 0.10295515
#> 4  0.09475938 0.09984818 0.10521027 0.13345875 0.10521027 0.09395839 0.09862277
#> 5  0.08992992 0.09475938 0.09984818 0.10521027 0.13345875 0.08935266 0.09395839
#> 6  0.10521027 0.10295515 0.09862277 0.09395839 0.08935266 0.13345875 0.10521027
#> 7  0.10295515 0.10521027 0.10295515 0.09862277 0.09395839 0.10521027 0.13345875
#> 8  0.09862277 0.10295515 0.10521027 0.10295515 0.09862277 0.09984818 0.10521027
#> 9  0.09395839 0.09862277 0.10295515 0.10521027 0.10295515 0.09475938 0.09984818
#> 10 0.08935266 0.09395839 0.09862277 0.10295515 0.10521027 0.08992992 0.09475938
#> 11 0.09984818 0.09862277 0.09561367 0.09180478 0.08773608 0.10521027 0.10295515
#> 12 0.09862277 0.09984818 0.09862277 0.09561367 0.09180478 0.10295515 0.10521027
#> 13 0.09561367 0.09862277 0.09984818 0.09862277 0.09561367 0.09862277 0.10295515
#> 14 0.09180478 0.09561367 0.09862277 0.09984818 0.09862277 0.09395839 0.09862277
#> 15 0.08773608 0.09180478 0.09561367 0.09862277 0.09984818 0.08935266 0.09395839
#> 16 0.09475938 0.09395839 0.09180478 0.08879570 0.08534660 0.09984818 0.09862277
#> 17 0.09395839 0.09475938 0.09395839 0.09180478 0.08879570 0.09862277 0.09984818
#> 18 0.09180478 0.09395839 0.09475938 0.09395839 0.09180478 0.09561367 0.09862277
#> 19 0.08879570 0.09180478 0.09395839 0.09475938 0.09395839 0.09180478 0.09561367
#> 20 0.08534660 0.08879570 0.09180478 0.09395839 0.09475938 0.08773608 0.09180478
#> 21 0.08992992 0.08935266 0.08773608 0.08534660 0.08246389 0.09475938 0.09395839
#> 22 0.08935266 0.08992992 0.08935266 0.08773608 0.08534660 0.09395839 0.09475938
#> 23 0.08773608 0.08935266 0.08992992 0.08935266 0.08773608 0.09180478 0.09395839
#> 24 0.08534660 0.08773608 0.08935266 0.08992992 0.08935266 0.08879570 0.09180478
#> 25 0.08246389 0.08534660 0.08773608 0.08935266 0.08992992 0.08534660 0.08879570
#> 26 0.08534660 0.08490568 0.08364425 0.08171630 0.07930674 0.08992992 0.08935266
#> 27 0.08490568 0.08534660 0.08490568 0.08364425 0.08171630 0.08935266 0.08992992
#> 28 0.08364425 0.08490568 0.08534660 0.08490568 0.08364425 0.08773608 0.08935266
#> 29 0.08171630 0.08364425 0.08490568 0.08534660 0.08490568 0.08534660 0.08773608
#> 30 0.07930674 0.08171630 0.08364425 0.08490568 0.08534660 0.08246389 0.08534660
#>             8          9         10         11         12         13         14
#> 1  0.09862277 0.09395839 0.08935266 0.09984818 0.09862277 0.09561367 0.09180478
#> 2  0.10295515 0.09862277 0.09395839 0.09862277 0.09984818 0.09862277 0.09561367
#> 3  0.10521027 0.10295515 0.09862277 0.09561367 0.09862277 0.09984818 0.09862277
#> 4  0.10295515 0.10521027 0.10295515 0.09180478 0.09561367 0.09862277 0.09984818
#> 5  0.09862277 0.10295515 0.10521027 0.08773608 0.09180478 0.09561367 0.09862277
#> 6  0.09984818 0.09475938 0.08992992 0.10521027 0.10295515 0.09862277 0.09395839
#> 7  0.10521027 0.09984818 0.09475938 0.10295515 0.10521027 0.10295515 0.09862277
#> 8  0.13345875 0.10521027 0.09984818 0.09862277 0.10295515 0.10521027 0.10295515
#> 9  0.10521027 0.13345875 0.10521027 0.09395839 0.09862277 0.10295515 0.10521027
#> 10 0.09984818 0.10521027 0.13345875 0.08935266 0.09395839 0.09862277 0.10295515
#> 11 0.09862277 0.09395839 0.08935266 0.13345875 0.10521027 0.09984818 0.09475938
#> 12 0.10295515 0.09862277 0.09395839 0.10521027 0.13345875 0.10521027 0.09984818
#> 13 0.10521027 0.10295515 0.09862277 0.09984818 0.10521027 0.13345875 0.10521027
#> 14 0.10295515 0.10521027 0.10295515 0.09475938 0.09984818 0.10521027 0.13345875
#> 15 0.09862277 0.10295515 0.10521027 0.08992992 0.09475938 0.09984818 0.10521027
#> 16 0.09561367 0.09180478 0.08773608 0.10521027 0.10295515 0.09862277 0.09395839
#> 17 0.09862277 0.09561367 0.09180478 0.10295515 0.10521027 0.10295515 0.09862277
#> 18 0.09984818 0.09862277 0.09561367 0.09862277 0.10295515 0.10521027 0.10295515
#> 19 0.09862277 0.09984818 0.09862277 0.09395839 0.09862277 0.10295515 0.10521027
#> 20 0.09561367 0.09862277 0.09984818 0.08935266 0.09395839 0.09862277 0.10295515
#> 21 0.09180478 0.08879570 0.08534660 0.09984818 0.09862277 0.09561367 0.09180478
#> 22 0.09395839 0.09180478 0.08879570 0.09862277 0.09984818 0.09862277 0.09561367
#> 23 0.09475938 0.09395839 0.09180478 0.09561367 0.09862277 0.09984818 0.09862277
#> 24 0.09395839 0.09475938 0.09395839 0.09180478 0.09561367 0.09862277 0.09984818
#> 25 0.09180478 0.09395839 0.09475938 0.08773608 0.09180478 0.09561367 0.09862277
#> 26 0.08773608 0.08534660 0.08246389 0.09475938 0.09395839 0.09180478 0.08879570
#> 27 0.08935266 0.08773608 0.08534660 0.09395839 0.09475938 0.09395839 0.09180478
#> 28 0.08992992 0.08935266 0.08773608 0.09180478 0.09395839 0.09475938 0.09395839
#> 29 0.08935266 0.08992992 0.08935266 0.08879570 0.09180478 0.09395839 0.09475938
#> 30 0.08773608 0.08935266 0.08992992 0.08534660 0.08879570 0.09180478 0.09395839
#>            15         16         17         18         19         20         21
#> 1  0.08773608 0.09475938 0.09395839 0.09180478 0.08879570 0.08534660 0.08992992
#> 2  0.09180478 0.09395839 0.09475938 0.09395839 0.09180478 0.08879570 0.08935266
#> 3  0.09561367 0.09180478 0.09395839 0.09475938 0.09395839 0.09180478 0.08773608
#> 4  0.09862277 0.08879570 0.09180478 0.09395839 0.09475938 0.09395839 0.08534660
#> 5  0.09984818 0.08534660 0.08879570 0.09180478 0.09395839 0.09475938 0.08246389
#> 6  0.08935266 0.09984818 0.09862277 0.09561367 0.09180478 0.08773608 0.09475938
#> 7  0.09395839 0.09862277 0.09984818 0.09862277 0.09561367 0.09180478 0.09395839
#> 8  0.09862277 0.09561367 0.09862277 0.09984818 0.09862277 0.09561367 0.09180478
#> 9  0.10295515 0.09180478 0.09561367 0.09862277 0.09984818 0.09862277 0.08879570
#> 10 0.10521027 0.08773608 0.09180478 0.09561367 0.09862277 0.09984818 0.08534660
#> 11 0.08992992 0.10521027 0.10295515 0.09862277 0.09395839 0.08935266 0.09984818
#> 12 0.09475938 0.10295515 0.10521027 0.10295515 0.09862277 0.09395839 0.09862277
#> 13 0.09984818 0.09862277 0.10295515 0.10521027 0.10295515 0.09862277 0.09561367
#> 14 0.10521027 0.09395839 0.09862277 0.10295515 0.10521027 0.10295515 0.09180478
#> 15 0.13345875 0.08935266 0.09395839 0.09862277 0.10295515 0.10521027 0.08773608
#> 16 0.08935266 0.13345875 0.10521027 0.09984818 0.09475938 0.08992992 0.10521027
#> 17 0.09395839 0.10521027 0.13345875 0.10521027 0.09984818 0.09475938 0.10295515
#> 18 0.09862277 0.09984818 0.10521027 0.13345875 0.10521027 0.09984818 0.09862277
#> 19 0.10295515 0.09475938 0.09984818 0.10521027 0.13345875 0.10521027 0.09395839
#> 20 0.10521027 0.08992992 0.09475938 0.09984818 0.10521027 0.13345875 0.08935266
#> 21 0.08773608 0.10521027 0.10295515 0.09862277 0.09395839 0.08935266 0.13345875
#> 22 0.09180478 0.10295515 0.10521027 0.10295515 0.09862277 0.09395839 0.10521027
#> 23 0.09561367 0.09862277 0.10295515 0.10521027 0.10295515 0.09862277 0.09984818
#> 24 0.09862277 0.09395839 0.09862277 0.10295515 0.10521027 0.10295515 0.09475938
#> 25 0.09984818 0.08935266 0.09395839 0.09862277 0.10295515 0.10521027 0.08992992
#> 26 0.08534660 0.09984818 0.09862277 0.09561367 0.09180478 0.08773608 0.10521027
#> 27 0.08879570 0.09862277 0.09984818 0.09862277 0.09561367 0.09180478 0.10295515
#> 28 0.09180478 0.09561367 0.09862277 0.09984818 0.09862277 0.09561367 0.09862277
#> 29 0.09395839 0.09180478 0.09561367 0.09862277 0.09984818 0.09862277 0.09395839
#> 30 0.09475938 0.08773608 0.09180478 0.09561367 0.09862277 0.09984818 0.08935266
#>            22         23         24         25         26         27         28
#> 1  0.08935266 0.08773608 0.08534660 0.08246389 0.08534660 0.08490568 0.08364425
#> 2  0.08992992 0.08935266 0.08773608 0.08534660 0.08490568 0.08534660 0.08490568
#> 3  0.08935266 0.08992992 0.08935266 0.08773608 0.08364425 0.08490568 0.08534660
#> 4  0.08773608 0.08935266 0.08992992 0.08935266 0.08171630 0.08364425 0.08490568
#> 5  0.08534660 0.08773608 0.08935266 0.08992992 0.07930674 0.08171630 0.08364425
#> 6  0.09395839 0.09180478 0.08879570 0.08534660 0.08992992 0.08935266 0.08773608
#> 7  0.09475938 0.09395839 0.09180478 0.08879570 0.08935266 0.08992992 0.08935266
#> 8  0.09395839 0.09475938 0.09395839 0.09180478 0.08773608 0.08935266 0.08992992
#> 9  0.09180478 0.09395839 0.09475938 0.09395839 0.08534660 0.08773608 0.08935266
#> 10 0.08879570 0.09180478 0.09395839 0.09475938 0.08246389 0.08534660 0.08773608
#> 11 0.09862277 0.09561367 0.09180478 0.08773608 0.09475938 0.09395839 0.09180478
#> 12 0.09984818 0.09862277 0.09561367 0.09180478 0.09395839 0.09475938 0.09395839
#> 13 0.09862277 0.09984818 0.09862277 0.09561367 0.09180478 0.09395839 0.09475938
#> 14 0.09561367 0.09862277 0.09984818 0.09862277 0.08879570 0.09180478 0.09395839
#> 15 0.09180478 0.09561367 0.09862277 0.09984818 0.08534660 0.08879570 0.09180478
#> 16 0.10295515 0.09862277 0.09395839 0.08935266 0.09984818 0.09862277 0.09561367
#> 17 0.10521027 0.10295515 0.09862277 0.09395839 0.09862277 0.09984818 0.09862277
#> 18 0.10295515 0.10521027 0.10295515 0.09862277 0.09561367 0.09862277 0.09984818
#> 19 0.09862277 0.10295515 0.10521027 0.10295515 0.09180478 0.09561367 0.09862277
#> 20 0.09395839 0.09862277 0.10295515 0.10521027 0.08773608 0.09180478 0.09561367
#> 21 0.10521027 0.09984818 0.09475938 0.08992992 0.10521027 0.10295515 0.09862277
#> 22 0.13345875 0.10521027 0.09984818 0.09475938 0.10295515 0.10521027 0.10295515
#> 23 0.10521027 0.13345875 0.10521027 0.09984818 0.09862277 0.10295515 0.10521027
#> 24 0.09984818 0.10521027 0.13345875 0.10521027 0.09395839 0.09862277 0.10295515
#> 25 0.09475938 0.09984818 0.10521027 0.13345875 0.08935266 0.09395839 0.09862277
#> 26 0.10295515 0.09862277 0.09395839 0.08935266 0.13345875 0.10521027 0.09984818
#> 27 0.10521027 0.10295515 0.09862277 0.09395839 0.10521027 0.13345875 0.10521027
#> 28 0.10295515 0.10521027 0.10295515 0.09862277 0.09984818 0.10521027 0.13345875
#> 29 0.09862277 0.10295515 0.10521027 0.10295515 0.09475938 0.09984818 0.10521027
#> 30 0.09395839 0.09862277 0.10295515 0.10521027 0.08992992 0.09475938 0.09984818
#>            29         30
#> 1  0.08171630 0.07930674
#> 2  0.08364425 0.08171630
#> 3  0.08490568 0.08364425
#> 4  0.08534660 0.08490568
#> 5  0.08490568 0.08534660
#> 6  0.08534660 0.08246389
#> 7  0.08773608 0.08534660
#> 8  0.08935266 0.08773608
#> 9  0.08992992 0.08935266
#> 10 0.08935266 0.08992992
#> 11 0.08879570 0.08534660
#> 12 0.09180478 0.08879570
#> 13 0.09395839 0.09180478
#> 14 0.09475938 0.09395839
#> 15 0.09395839 0.09475938
#> 16 0.09180478 0.08773608
#> 17 0.09561367 0.09180478
#> 18 0.09862277 0.09561367
#> 19 0.09984818 0.09862277
#> 20 0.09862277 0.09984818
#> 21 0.09395839 0.08935266
#> 22 0.09862277 0.09395839
#> 23 0.10295515 0.09862277
#> 24 0.10521027 0.10295515
#> 25 0.10295515 0.10521027
#> 26 0.09475938 0.08992992
#> 27 0.09984818 0.09475938
#> 28 0.10521027 0.09984818
#> 29 0.13345875 0.10521027
#> 30 0.10521027 0.13345875