spb: Separable-plus-banded Covariance Estimation

View source: R/spb.R

spbR Documentation

Separable-plus-banded Covariance Estimation

Description

Estimates components of cov(X) = A1 x A2 + B where B is banded by d. If bandwidth d is not provided, it is estimated via cross-validation.
CV can be either fit-based, i.e tailored to minimize mean squared estimation error, or prediction-based, i.e. tailored to minimize the mean squared prediction error. The fit-based CV is faster.
B is considered stationary by default, this can be changed by toggling stationary=F.

Usage

spb(
  X,
  d = NULL,
  stationary = TRUE,
  mu = NULL,
  predict = FALSE,
  maxd = NULL,
  mind = NULL,
  Folds = NULL,
  perc = c(1/4, 1/4)
)

Arguments

X

data array of size N x K1 x K2

d

the bandwidth, an integer between 0 and min(K1,K2)

stationary

a flag whether the banded part should be stationary, defaults to TRUE

mu

matrix of size K1 x K2, the mean, defaults to the empirical mean

predict

flag whether prediction-based cross-validation should be used, the default is fit-based cross-validation

maxd

integer, maximum bandwidth considered by CV, defaults to min(K1,K2)/10

mind

minimum bandwidth considered by CV, defaults to zero

Folds

number of folds for cross-validation, defaults to 10

perc

vector of 2, if predict=T, what proportions (in time and space) of every observation should be predicted. When perc>=1, specific number of grid lines is predicted, e.g. perc=1 corresponds to one-step-ahead prediction (in both space and time)

Value

a list of objects, depending on stationary and d:

  • A1 - matrix of size K1 x K1, the temporal kernel

  • A2 - matrix of size K2 x K2, the spatial kernel

  • B - matrix of size d x d, i.e. the symbol of the banded part, if stationary=T. If stationary=F, then the value depends on d: for d=1 it is a matrix of size K1 x K2 representing location-wise variances, while for d>1 a structure produced by banded_nonstat_est is returned

if cross-validation was conducted, the list contains also:

  • cv - the CV objective values: a larger value is better for fit-based CV and a smaller value is better for the prediction-based CV (when predict=T)

  • d - the chosen bandwidth

Examples

N <- 100
K1 <- K2 <- 7
X <- array(rnorm(N*K1*K2),c(N,K1,K2))
A1 <- array(0,c(K1,K1))
A1[,1] <- 1
A1[,2] <- -3:3
A1 <- A1 %*% t(A1)
A2 <- A1 <- mat_root(A1)
for(n in 1:N){
  X[n,,] <- A1 %*% X[n,,] %*% A2 + matrix(rnorm(K1*K2),K1)
}
# we have separable-plus-banded model, where B is stationary and d=1
Chat <- spb(X)
Chat$d # estimated bandwidth by fit-based CV
Chat <- spb(X,stationary=FALSE) # when we do not use stationarity
Chat$d # estimated bandwidth by fit-based CV without stationarity

TMasak/surfcov documentation built on April 25, 2022, 12:15 a.m.