predicted temporal pattern calculation

24 views
Skip to first unread message

Uma Mahi

unread,
Sep 13, 2021, 9:08:53 AM9/13/21
to R-inla discussion group

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 follows

SMR <-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.

 

Helpdesk

unread,
Sep 13, 2021, 3:32:39 PM9/13/21
to Uma Mahi, R-inla discussion group

that would depend on how these linear combinations are defined, which is
not given.
> --
> You received this message because you are subscribed to the Google
> Groups "R-inla discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to r-inla-discussion...@googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/r-inla-discussion-group/caf10896-ae18-4e1f-a657-07d7e47cf523n%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org

Uma Mahi

unread,
Sep 14, 2021, 1:30:56 AM9/14/21
to Helpdesk, R-inla discussion group

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.

 


Thanks and Regards
R.Uma Maheswari

Helpdesk

unread,
Sep 14, 2021, 3:59:56 AM9/14/21
to Uma Mahi, R-inla discussion group
the easiest way to check this is to run with

control.inla=list(strategy="gaussian", int.strategy="eb")

and then the mean's should match. compare the means of the lincomb's
with the corresponding mean of the temporal patterns etc...
Reply all
Reply to author
Forward
0 new messages