widals.predict {widals} | R Documentation |
WIDALS Interpolation
Description
Interpolate to unmonitored sites using WIDALS
Usage
widals.predict(Z, Hs, Ht, Hst.ls, locs, lags, b.lag, Hs0, Hst0.ls, locs0,
geodesic = FALSE, wrap.around = NULL, GP, stnd.d = FALSE, ltco = -16)
Arguments
Z |
Space-time data. A |
Hs |
Spacial covariates (of supporting sites). An |
Ht |
Temporal covariates (of supporting sites). A |
Hst.ls |
Space-time covariates (of supporting sites). A list of length |
locs |
Locations of supporting sites. An n x 2 numeric matrix, first column is spacial |
lags |
Temporal lags for stochastic smoothing. An integer vector or scalar. E.g., if the data's time increment is daily, then |
b.lag |
ALS lag. A scalar integer, typically -1 (a-prior), or 0 (a-posteriori). |
Hs0 |
Spacial covariates (of interpolation sites). An |
Hst0.ls |
Space-time covariates (of interpolation sites). A list of length |
locs0 |
Locations of interpolation sites. An n* x 2 numeric matrix. See |
geodesic |
Use geodesic distance? Boolean. If true, distance (used internally) is in units kilometers. |
wrap.around |
**Unused. |
GP |
Widals hyperparameters. A non-negative vector. |
stnd.d |
Spacial compression. Boolean. |
ltco |
Weight threshold. A scalar number. A value of, e.g., -10, will instruct |
Value
A \tau
x n
* matrix. The WIDALS predictions at locs0
.
See Also
crispify
, H.als.b
, widals.snow
.
Examples
#### similar to example provided in H.als.b.
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]] )
}
locs.all <- cbind(runif(n.all, -1, 1), runif(n.all, -1, 1))
D.mx.all <- distance(locs.all, locs.all, FALSE)
R.all <- exp(-2*D.mx.all) + diag(0.01, n.all)
######## use SSsimple to simulate
sssim.obj <- SS.sim.tv( 0.999, Hst.combined, 0.01, R.all, tau )
ndx.support <- 1:10
ndx.interp <- 11:14
locs <- locs.all[ndx.support, ]
locs0 <- locs.all[ndx.interp, ]
Z.all <- sssim.obj$Z
Z <- Z.all[ , ndx.support]
Z0 <- Z.all[ , ndx.interp]
Hst.ls <- subsetsites.Hst.ls(Hst.ls.all, ndx.support)
Hst0.ls <- subsetsites.Hst.ls(Hst.ls.all, ndx.interp)
Hs <- Hs.all[ ndx.support, , drop=FALSE]
Hs0 <- Hs.all[ ndx.interp, , drop=FALSE]
test.rng <- 20:tau
################# use ALS
xrho <- 1/10
xreg <- 1/10
xALS <- H.als.b(Z=Z, Hs=Hs, Ht=Ht, Hst.ls=Hst.ls, rho=xrho, reg=xreg,
b.lag=-1, Hs0=Hs0, Ht0=Ht, Hst0.ls=Hst0.ls)
errs.sq <- (Z0 - xALS$Z0.hat)^2
sqrt( mean(errs.sq[test.rng, ]) )
################# now use WIDALS
GP <- c(1/10, 1/10, 2, 0, 1)
Zwid <- widals.predict(Z=Z, Hs=Hs, Ht=Ht, Hst.ls=Hst.ls, locs=locs, lags=c(0),
b.lag=-1, Hs0=Hs0, Hst0.ls=Hst0.ls, locs0=locs0, FALSE, NULL, GP)
errs.sq <- (Z0 - Zwid)^2
sqrt( mean(errs.sq[test.rng, ]) )