Sigma_y: Covariance Matrix of GP-based SVC Model

Description Usage Arguments Value Author(s) References Examples

View source: R/help_functions.R

Description

Builds the covariance matrix of y (p. 6, Dambon et al. (2021) doi: 10.1016/j.spasta.2020.100470) for a given set of covariance parameters and other, pre-defined objects (like the outer-products, covariance function, and, possibly, a taper matrix).

Usage

1
Sigma_y(x, cov_func, outer.W, taper = NULL)

Arguments

x

(numeric(2q+1))
Non negative vector containing the covariance parameters in the following order: ρ_1, σ_1^2, ..., ρ_q, σ_q^2 , τ^2. Note that the odd entries, i.e., the ranges and the nugget variance, have to be greater than 0, otherwise the covariance matrix is not well-defined (singularities or not-invertible).

cov_func

(function)
A covariance function that works on the pre-defined distance matrix d. It takes a numeric vector as an input, the first entry being the range, the second being the variance (also called partial sill). Usually, it is defined as, e.g.: function(pars) spam::cov.exp(d, pars) or any other covariance function defined for two parameters.

outer.W

(list(q))
A list of length q containing the outer products of the random effect covariates in a lower triangular, (possibly sparse) matrix. If tapering is applied, the list entries, i.e., the outer products have to be given as spam objects.

taper

(NULL or spam)
If covariance tapering is applied, this argument contains the taper matrix, which is a spam object. Otherwise, it is NULL.

Value

Returns a positive-definite covariance matrix y, which is needed in the MLE. Specifically, a Cholesky Decomposition is applied on the covariance matrix.

Author(s)

Jakob Dambon

References

Dambon, J. A., Sigrist, F., Furrer, R. (2021) Maximum likelihood estimation of spatially varying coefficient models for large data with an application to real estate price prediction, Spatial Statistics doi: 10.1016/j.spasta.2020.100470

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# locations
locs <- 1:6
# random effects covariates
W <- cbind(rep(1, 6), 5:10)
# distance matrix with and without tapering
d <- as.matrix(dist(locs))
# distance matrix with and without tapering
tap_dist <- 2
d_tap <- spam::nearest.dist(locs, delta = tap_dist)
# call without tapering
(Sy <- varycoef:::Sigma_y(
  x = rep(0.5, 5),
  cov_func = function(x) spam::cov.exp(d, x),
  outer.W = lapply(1:ncol(W), function(k) W[, k] %o% W[, k])
))
str(Sy)
# call with tapering
(Sy_tap <- varycoef:::Sigma_y(
  x = rep(0.5, 5),
  cov_func = function(x) spam::cov.exp(d_tap, x),
  outer.W = lapply(1:ncol(W), function(k)
    spam::as.spam((W[, k] %o% W[, k]) * (d_tap<=tap_dist))
  ),
  taper = spam::cov.wend1(d_tap, c(tap_dist, 1, 0))
))
str(Sy_tap)
# difference between tapered and untapered covariance matrices
Sy-Sy_tap

varycoef documentation built on June 3, 2021, 5:10 p.m.