Hi INLA group members,
I am running a spatio temporal model considering database from duration Jan 2013 to Dec 2018 (72 months) with 502 areas.
I am trying to plot monthly temporal pattern (Observed and predicted incidence rate ratio) which is calculated as followsSMR <-apply(matrix(data$O,S,T,byrow=F),2,sum)/apply(matrix(data$E,S,T,byrow=F),2,sum)
temporal <- unlist(lapply(main_Model2$marginals.lincomb.derived[(S+2):(1+S+T)], function(x) inla.emarginal(exp,x)))
aux <- lapply(main_Model2$marginals.lincomb.derived[(S+2):(1+S+T)], function(x) inla.tmarginal(exp,x))
q1 <- unlist(lapply(aux, function(x) inla.qmarginal(0.025,x)))
q2 <- unlist(lapply(aux, function(x) inla.qmarginal(0.975,x)))
I would like to know whether the predicted emarginals from “marginals.lincomb.derived” for the 72 months are based on all the 502 spatial areas.
Hi Rue
I am very thankful for your timely response as it helps us.
I have few clarifications based on your response “How these linear combinations defined?”
When running the model, I have used the linear combinations which is given below:
## Posterior distribution of the global intercept ##
lc1 = inla.make.lincomb(Predictor = rep(1/(S*T),S*T))
names(lc1) <- "intercept"
## Posterior distribution of the spatial pattern ##
M1 <- matrix(-1/(S*T),S,S*T)
for (i in 1:S) {
M1[i,seq(0,S*(T-1),by=S)+i] <- 1/(S*T)*(S-1)
}
lc2 = inla.make.lincombs(Predictor = M1)
names(lc2) <- paste("spatial.",as.character(seq(1:S)),sep="")
## Posterior distribution of the temporal pattern ##
M2 <- matrix(-1/(S*T),T,S*T)
for (i in 1:T) {
M2[i,seq(1,S)+S*(i-1)] <- 1/(S*T)*(T-1)
}
lc3 = inla.make.lincombs(Predictor = M2)
names(lc3) <- paste("temporal.",as.character(seq(1:T)),sep="")
## Posterior distribution of the spatio-temporal pattern ##
M3 <- matrix(1/(S*T),S*T,S*T)
k=1
for (j in 1:T) {
for (i in 1:S) {
M3[k,seq(0,S*(T-1),by=S)+i] <- 1/(S*T)*(1-S)
M3[k,seq(1,S)+S*(j-1)] <- 1/(S*T)*(1-T)
M3[k,k] <- (S*T-S-T+1)/(S*T)
k=k+1
}
}
lc4 = inla.make.lincombs(Predictor = M3)
names(lc4) <- paste("spatio.temporal.",as.character(seq(1:(S*T))),sep="")
all.lc <- c(lc1,lc2,lc3,lc4)
My questions are:
(1) Whether the r-codes for the posterior-distribution of the temporal pattern would result in predictions for 72 months? Please correct me if I am wrong.
(2) In the “marginal.lincomb.derived” estimates for each month I have only 35 rows. I would like to know what this number “35” refers to? Is it the no. of samples randomly generated from the posterior distribution or the rows for each time point corresponding to the no. of blocks, if so, which was found to be less than the total no. of blocks (502) in my data set? Kindly clarify.