[R-sig-Geo] Spatio-temporal Predictions with CARBayesST

Ariel Fuentesdi @r|e|@|uente@d| @end|ng |rom u@@ch@c|
Mon Nov 4 20:25:35 CET 2019


Hi everyone,

I'm trying to use the CARBayesST package and I need to do Spatio-temporal
predictions. In the vignette of the package on page 27 says " If there had
been say m missing values, then the Y component of the list would have
contained m columns, with each one containing posterior predictive samples
for one of the missing observations."

https://cran.r-project.org/web/packages/CARBayesST/vignettes/CARBayesST.pdf

But I don't understand well how to obtain the posterior predictive values
of Y, let's say I want to predict the value of Y for the next 3 periods for
each zone. How should I do it?

This is the reproducible code (found in the vignette):

library(CARBayesST)
#################################################
#### Run the model on simulated data on a lattice
#################################################
#### set up the regular lattice
x.easting <- 1:10
x.northing <- 1:10
Grid <- expand.grid(x.easting, x.northing)
K <- nrow(Grid)
N <- 10
N.all <- N * K
#### set up spatial neighbourhood matrix W
distance <- as.matrix(dist(Grid))
W <-array(0, c(K,K))
W[distance==1] <-1
#### Simulate the elements in the linear predictor and the data
gamma <- rnorm(n=N.all, mean=0, sd=0.001)
x <- rnorm(n=N.all, mean=0, sd=1)
beta <- 0.1
Q.W <- 0.99 * (diag(apply(W, 2, sum)) - W) + 0.01 * diag(rep(1,K))
Q.W.inv <- solve(Q.W)
phi.temp <- mvrnorm(n=1, mu=rep(0,K), Sigma=(0.1 * Q.W.inv))
phi <- phi.temp
for(i in 2:N)
{
  phi.temp2 <- mvrnorm(n=1, mu=(0.8 * phi.temp), Sigma=(0.1 * Q.W.inv))
  phi.temp <- phi.temp2
  phi <- c(phi, phi.temp)
}
LP <- 3 + x * beta + phi
mean <- exp(LP)
Y <- rpois(n=N.all, lambda=mean)
#### Run the model
model <- ST.CARar(formula=Y~x, family="poisson", W=W, burnin=10,
                  n.sample=50)

Regards,
Ariel

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list