cvband | R Documentation |
Calculates the objective value of the cross-validation criterion for bandwidth d between mind and maxd.
cvband(X, Folds = 10, maxd = 20, mind = 1)
X |
data set, array of size |
Folds |
number of folds |
maxd |
maximum bandwidth value to check |
mind |
minimum bandwidth value to check |
matrix with two rows: first row gives the fit, the second gives the norm, columns correspond to different bandwidths
N <- 500 K1 <- 5 K2 <- 7 set.seed(517) X <- array(rnorm(N*K1*K2),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) } maxd <- 3 # max range tobe mind <- 1 cvscores <- cvband(X,10,maxd,mind) # two rows: fit and norm cvscores[1,]/cvscores[2,] # cross-validation objective: fit/norm cvscores[2,]^2 - 2*cvscores[1,] # alternative objective: norm^2 - 2*fit # choose bandwidth as the smallest local maximum: min(localMaxima(cvscores[1,]/cvscores[2,])) + mind - 1 min(which.min(cvscores[2,]^2 - 2*cvscores[1,])) + mind - 1 # "+mind-1" to take care if mind in not equal to one
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.