Hals.fastcv.snow {widals} | R Documentation |
ALS Spacial Cross-Validation
Description
Fit Adaptive Least Squares with k
-fold cross-validation
Usage
Hals.fastcv.snow(j, rm.ndx, Z, Hs, Ht, Hst.ls, GP.mx)
Arguments
j |
Index used by |
rm.ndx |
A list of vectors of indices to remove for k-fold cross-validation. |
Z |
Data. A |
Hs |
Spacial covariates. An |
Ht |
Temporal covariates. An |
Hst.ls |
Space-time covariates. A list of length |
GP.mx |
Hyperparameters. A |
Value
A \tau
x n
numeric matrix. The ALS cross-validated predictions of Z
.
See Also
Examples
set.seed(99999)
library(SSsimple)
tau <- 70
n.all <- 14
Hs.all <- matrix(rnorm(n.all), nrow=n.all)
Ht <- matrix(rnorm(tau*2), nrow=tau)
Hst.ls.all <- list()
for(i in 1:tau) { Hst.ls.all[[i]] <- matrix(rnorm(n.all*2), nrow=n.all) }
Hst.combined <- list()
for(i in 1:tau) {
Hst.combined[[i]] <- cbind( Hs.all, matrix(Ht[i, ], nrow=n.all,
ncol=ncol(Ht), byrow=TRUE), Hst.ls.all[[i]] )
}
######## use SSsimple to simulate
sssim.obj <- SS.sim.tv( 0.999, Hst.combined, 0.01, diag(1, n.all), tau )
Z.all <- sssim.obj$Z
Z <- Z.all
n <- n.all
Hst.ls <- Hst.ls.all
Hs <- Hs.all
xrho <- 1/10
xreg <- 1/10
GP.mx <- matrix(c(xrho, xreg), nrow=1)
rm.ndx <- create.rm.ndx.ls(n, 10)
Zcv <- Hals.fastcv.snow(j=1, rm.ndx, Z, Hs, Ht, Hst.ls, GP.mx)
test.rng <- 20:tau
errs.sq <- (Z - Zcv)^2
sqrt( mean(errs.sq[test.rng, ]) )
[Package widals version 0.6.1 Index]