I've been running a spatio temporal model in R-INLA. the time scope is 46 years, and it's yearly data.
The models run pretty smoothly for the Knorr-Held formulation described in "spatio and spatio-temporal bayesian models with R-INLA", with the following code:
control <- list(
predictor = list(compute = TRUE),
results = list(return.marginals.random = TRUE, return.marginals.predictor=TRUE),
compute = list(hyperpar=TRUE, return.marginals=TRUE, dic=TRUE, mlik = TRUE, cpo = TRUE,
po = TRUE, waic=TRUE, graph=TRUE, gdensity=TRUE, openmp.strategy="huge"),
group = list(model="rw2"))
#non-parametric dynamic trend
#knorr-held formulation
formula2 <- numberTorn ~1 + f(ID, model = "bym", graph=tornb.inla) + f(Year, model="crw2")+
f(Year2, model="iid")
modelsptp2 <- inla(formula = formula2, family = "poisson",
quantiles = c(.05, .5, .95),
data = TornInla,
control.compute = control$compute,
control.predictor = control$predictor)
summary(modelsptp2)
But I also would like to understand the space-time interactions, so I started to dig into it, and this is what happens:
#SP-TIME INTERACTION
#TYPE I
TornInla$area.year <- seq(1,length(countyTorn))
formTypeI <- numberTorn~ + f(ID, model="bym", graph=tornb.inla)+
f(Year, model="crw2") + f(Year2, model="iid")+
f(area.year, model="iid")
mod.intI <- inla(formTypeI,family="poisson",data=TornInla,
control.predictor=list(compute=TRUE),
control.compute=list(dic=TRUE,cpo=TRUE))
--------------- type I works fine
#Type II
formTypeII <-numberTorn ~ + f(ID, model="bym", graph=tornb.inla)+
f(Year, model= "rw2") + f(Year2, model="iid") +
control.group=list(model="rw2"))
mod.intII<-inla(formTypeII,family="poisson",data=TornInla,
control.predictor=control$predictor,
control.compute=list(dic=TRUE,cpo=TRUE))
----------------------throws an error:
Warning in inla(formTypeII, family = "poisson", data = TornInla, control.predictor = control$predictor, :
f(
area.int, ...) : There is no indices where group[]=1, this is *usually* a misspesification
Warning in inla(formTypeII, family = "poisson", data = TornInla, control.predictor = control$predictor, :
f(
area.int, ...): Number of unused groups >= the number of groups used: 1969 >= 47, this is *usually* a misspesification
Error in inla.inlaprogram.has.crashed() :
The inla-program exited with an error. Unless you interupted it yourself, please rerun with verbose=TRUE and check the output carefully.
In addition: Warning message:
running command '"C:/Users/rp/Documents/R/win-library/3.3/INLA/bin/windows/64bit/inla.exe" -b -s -v "C:/Users/rp/AppData/Local/Temp/RtmpY3Jd2d/file1df8390cd9/Model.ini"' had status 1
>
#Type III
formTypeIII<- numberTorn~+ f(ID, model="bym", graph= tornb.inla)+
f(Year, model="crw2") +
f(Year2, model="iid") +
control.group=list(model="besag", graph = tornb.inla))
mod.intIII <- inla (formTypeIII,family="poisson",data=TornInla,
control.predictor=control$predictor,
control.compute=control$compute)
###Type IV
formTypeIV<- numberTorn ~+ f(ID, model="bym", graph=tornb.inla)+
f(Year, model="crw2") + f(Year2, model="iid") +
f(
area.int, control.group= list(model="rw2"))
mod.intIV <- inla (formTypeIV,family="poisson",data=TornInla,
control.predictor=control$predictor,
control.compute=control$compute)
Type III and IV just take too long (more than 12 hours so far). I even set in control.compute openmp.strategy="huge", and I am running the scripts in MRO, which is supposelly faster than R, but still it isn't fast enough. Is this normal, or is there something wrong with the code? And why does it crash when I try to run the type II?