Description Usage Arguments Value See Also Examples
Fit Adaptive Least Squares
1 | Hals.snow(j, Z, Hs, Ht, Hst.ls, b.lag, GP.mx)
|
j |
Index used by |
Z |
Data. A τ x n numeric matrix. |
Hs |
Spacial covariates. An n x p_s numeric matrix. |
Ht |
Temporal covariates. An τ x p_t numeric matrix. |
Hst.ls |
Space-time covariates. A list of length τ, each element containing a n x p_st numeric matrix. |
b.lag |
ALS lag. A scalar integer, typically -1 (a-prior), or 0 (a-posteriori). |
GP.mx |
Hyperparameters. A k.glob x 2 non-negative matrix. See |
A τ x n numeric matrix. The ALS predictions of Z
.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | set.seed(9999)
library(SSsimple)
tau <- 280
n.all <- 35
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*3), 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.1, 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
b.lag <- -1
GP.mx <- matrix(c(xrho, xreg), nrow=1)
Zcv <- Hals.snow(j=1, Z, Hs, Ht, Hst.ls, b.lag, GP.mx)
test.rng <- 20:tau
errs.sq <- (Z - Zcv)^2
sqrt( mean(errs.sq[test.rng, ]) )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.