cvband_pred: Cross-validation for Bandwidth Selection in...

View source: R/cvband.R

cvband_predR Documentation

Cross-validation for Bandwidth Selection in Separable-plus-banded Model via Prediction

Description

Examines the prediction performance of the separable-plus-banded model for different (discrete) bandwidths d=mind,...,maxd via a cross-validated scheme: for every surface in the current hold-out sample, a part of the surface (a fixed number of last few rows and columns give by perc) is predicted based on the remainder of the given surface, and relative prediction error is calculated.

Usage

cvband_pred(X, Folds = 10, maxd = 20, mind = 1, perc = c(1/4, 1/4))

Arguments

X

data, array of size N x K1 x K2

Folds

number of folds

maxd

maximum bandwidth value to check

mind

minimum bandwidth value to check

perc

vector of 2 values in (0,1) giving the ratio of rows and columns to be predicted

Value

vector of cross-validated prediction errors for d=mind,...,maxd

Examples

N <- 4
K1 <- 4
K2 <- 4
set.seed(517)
X <- array(0,c(N,K1,K2))
A <- matrix(rnorm(K1^2),K1)
B <- matrix(rnorm(K2^2),K2)
A <- A %*% t(A)
B <- B %*% t(B)
A <- mat_root(A)
B <- mat_root(B)
for(n in 1:N){
  X[n,,] <- A %*% X[n,,] %*% B + matrix(rnorm(K1*K2),K1)
}
( cvscores <- cvband_pred(X,2,2,0) )
min(localMaxima(-cvscores))

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