Dear all,
I tried to run the R code in Chapter 7 of this book,the name is《Spatial and spatio-temporal Bayesian models with R-INLA》。
and I got Hessian WARNING,and Different results on different computers. I do not know how to deal with it.
I try to section 7.1.2 Space– time interactions,there are four models here,
I wanna say the model 1&4 seem is fine,but model2&3 seem to have some problems.
the book code is following:
## the book code
> require(INLA)
> inla.setOption(scale.model.default=FALSE)
> require(splancs)
> require(sp)
> require(fields)
> require(maptools)
> require(lattice)
> require(abind)
...
###################################################
### Code for Section 7.1.1
###################################################
# You neeed a folder called "LBW in Georgia" inside your working directory (my.dir)
# with the data downloaded from
#import Data
#and Data preprocessing
....
###################################################
### Code for Section 7.1.2 (run the code for Section 7.1.1 first)
###################################################
#--- Type I interaction ---#
formula.intI<- y ~ + f(ID.area,model="bym", graph=Georgia.adj) +
f(ID.year,model="rw2") + f(ID.year1,model="iid") + f(ID.area.year,model="iid")
mod.intI <- inla(formula.intI,family="poisson",data=data,E=E,
control.predictor=list(compute=TRUE),
control.compute=list(dic=TRUE,cpo=TRUE))
#--- Type II interaction ---#
formula.intII<- y ~ f(ID.area,model="bym",graph=Georgia.adj) +
f(ID.year,model="rw2") + f(ID.year1,model="iid") +
mod.intII <- inla(formula.intII,family="poisson",data=data,E=E,
control.predictor=list(compute=TRUE),
control.compute=list(dic=TRUE,cpo=TRUE))
#--- Type III interaction ---#
formula.intIII<- y ~ f(ID.area,model="bym",graph=Georgia.adj) +
f(ID.year,model="rw2") +
f(ID.year1,model="iid") +
mod.intIII <- inla(formula.intIII,family="poisson",data=data,E=E,
control.predictor=list(compute=TRUE),
control.compute=list(dic=TRUE,cpo=TRUE))
#--- Type IV interaction ---#
formula.intIV<- y ~ f(ID.area,model="bym",graph=Georgia.adj) +
f(ID.year,model="rw2") +
f(ID.year1,model="iid") +
mod.intIV <- inla(formula.intIV,family="poisson",data=data,E=E,
control.predictor=list(compute=TRUE),
control.compute=list(dic=TRUE,cpo=TRUE))
## the book code is end
and when I run model2, I got Hessian WARNING, like following:
> mod.intII <- inla(formula.intII,family="poisson",data=data,E=E,
+ control.predictor=list(compute=TRUE),
+ control.compute=list(dic=TRUE,cpo=TRUE))
*** WARNING *** Eigenvalue 0 of the Hessian is -27.7435 < 0
*** WARNING *** Set this eigenvalue to 0.897788
*** WARNING *** This have consequence for the accurancy of
*** WARNING *** the approximations; please check!!!
*** WARNING *** R-inla: Use option inla(..., control.inla = list(h = h.value), ...)
*** WARNING *** R-inla: to chose a different `h.value'.
I also check mod.intII$logfile,and found warning info like above.
and fixed result of model2 and model3 is similar,mean is close to zero, and sd is very big.
> mod.intI$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.03615165 0.01521281 0.006234724 0.03614904 0.06604964 0.03614552 4.183286e-12
> mod.intII$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.001716422 4055.897 -7963.092 -0.11257 7956.45 0.001848365 9.058292e-16
> mod.intIII$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.002882901 2556.503 -5019.437 -0.1489356 5015.27 0.03745706 3.448638e-09
> mod.intIV$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.03317507 0.006451598 0.02043958 0.03318634 0.04583411 0.03321004 1.353453e-11
>
in adition, I restarted the R session and run all model again, I found model2 still tip Hessian WARNING.
but fixed result of model3 is different as following:
################################################################################################
# in centos 7
> mod.intI$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.03616816 0.01520576 0.006263853 0.03616563 0.06605255 0.03616192 4.216472e-12
> mod.intII$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) -5.384162e-05 4056.925 -7965.113 -0.1144125 7958.465 0.0001806746 2.716519e-15
> mod.intIII$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.01806566 0.1333061 -0.2436593 0.0180619 0.2795721 0.01806566 1.967613e-16
> mod.intIV$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.03318039 0.006491015 0.0203669 0.03319124 0.04591975 0.03321439 1.099425e-11
>
#by the way, in this situation I get the same picture result as in the book. so I can't understand....
#cause I think the fixed mean of the four models should be similar....
############################################################################################
# in windows10
> mod.intI$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.03615165 0.01521281 0.006234724 0.03614904 0.06604964 0.03614552 4.183286e-12
> mod.intII$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.001716422 4055.897 -7963.092 -0.11257 7956.45 0.001848365 9.058292e-16
> mod.intIII$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) -0.005845292 7922.847 -15585.55 -0.7158791 15569.51 0.06985049 1.003045e-08
> mod.intIV$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.03317507 0.006451598 0.02043958 0.03318634 0.04583411 0.03321004 1.353453e-11
>
#############################################################################################
Is anyone have suggestions on how to deal with Hessian WARNING and
how to troubleshoot why different computers produce different results?
Thanks very much!
Best
Dong