Thomas H. Jagger, Florida State University
July 1, 2014, UCLA
Space Time Model of Kansas County Tornadoes
Integrating R-INLA with \( \require{color} \color{green} \mathbf{R} \) Spatial Packages
with support from James B. Elsner
Generated using R-Studio on Mon Jan 12 22:17:33 2015
Warning: Aggregation of any kind may result in spurious relationships
Bayesian models
R-INLA performs Integrated Nested Laplacian Analysis
Hurricane Count Example:
\[ \begin{eqnarray} Y_{i} &\sim& \mbox{Pois}(\lambda_{i}) \\ \log(\lambda_{i}) &\sim& N(\alpha+ \mbox{sst}_i \cdot \beta,\tau^{-1}) \\ \alpha, \beta &\sim& N(0,1000) \\ \tau &\sim& \Gamma(1,.00001) \\ \end{eqnarray} \]
require(INLA)
a=.5;b=.5;n=100;sst=rnorm(100);ID=1:100
y=rpois(n,exp(a+b*sst+rnorm(n)/sqrt(10)))
mydata=data.frame(y=y,ID=1:100,sst=sst)
form = y ~ sst + f(ID, model="iid")
inla.out = inla(form, family="poisson",data=mydata,
control.compute = list(config = TRUE,mlik=T,cpo=T,dic=T,po=T))
Call:
c("inla(formula = form, family = \"poisson\", data = mydata, control.compute = list(config = TRUE, ", " mlik = T, cpo = T, dic = T, po = T))")
Time used:
Pre-processing Running inla Post-processing Total
0.3310 0.0745 0.0440 0.4495
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 0.5777 0.0776 0.4218 0.5790 0.7267 0.5815 0
sst 0.4380 0.0663 0.3071 0.4382 0.5676 0.4387 0
Random effects:
Name Model
ID IID model
Model hyperparameters:
mean sd 0.025quant 0.5quant 0.975quant mode
Precision for ID 18571.51 18339.99 1261.14 13169.95 66863.71 3422.02
Expected number of effective parameters(std dev): 2.019(0.0145)
Number of equivalent replicates : 49.54
Deviance Information Criterion: 340.41
Effective number of parameters: 2.019
Marginal Likelihood: -176.22
CPO and PIT are computed
Posterior marginals for linear predictor and fitted values computed
We used a modified tornado data set keeping tornado paths in Kansas from 1954 through 2013 of at least EF1 (F1) strength. The data sets were put into \( \require{color} \color{green} \mathbf{R} \) SpatialLinesDataFrame objects or arrays. We use the \( \require{color} \color{green} \mathbf{R} \) ggplot2 package for plotting data sets.
Likelihood: \( \mbox{Pr}(X=k|r,P) = \frac{\Gamma(k+r)}{\Gamma(r) k!}P^r(1-P)^k \)
spatial.formula = nT ~ I(log(area)) +
I(log(pop/area)) + I(elevS) + I(elev.20*100) +
f(ID, model = "besag", graph = tornb.inla)
c.r = list(return.marginals.random = TRUE)
c.c = list(config = TRUE,mlik=T,cpo=T,dic=T,po=T)
c.p = list(compute=TRUE)
spatial.inla= inla(formula = spatial.formula, family = "nbinomial", E = area,
data = spdf.1@data, control.predictor = c.p,
control.compute=c.c, control.results=c.r)
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) -2.984 1.449 -5.844 -2.982 -0.142 -2.976 0
I(log(area)) -0.186 0.195 -0.569 -0.186 0.199 -0.187 0
I(log(pop/area)) 0.100 0.043 0.017 0.100 0.185 0.100 0
I(elevS) -0.014 0.005 -0.024 -0.014 -0.004 -0.014 0
I(elev.20 * 100) -0.149 0.163 -0.471 -0.149 0.172 -0.149 0
Random effects:
Name Model
ID Besags ICAR model
Model hyperparameters:
mean sd 0.025quant
size for the nbinomial observations (overdispersion) 10.32 2.35 6.37
Precision for ID 18.77 17.33 4.65
0.5quant 0.975quant mode
size for the nbinomial observations (overdispersion) 10.11 15.54 9.72
Precision for ID 13.53 64.06 8.34
Expected number of effective parameters(std dev): 20.20(7.03)
Number of equivalent replicates : 5.20
Deviance Information Criterion: 700.05
Effective number of parameters: 21.97
We can use the output to quickly ascertain
spaceTime.formula = nT ~ I(log(area)) +
I(log(pop/area)) + I(elevS) +
I(Apr + May - mam) + I(mam) + f(ID, model = "besag", graph = tornb.inla)
spaceTime.inla= inla(formula = spaceTime.formula, family = "nbinomial", E = area,
data = inladata, control.predictor = c.p, control.compute=c.c, control.results=c.r)
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) -5.202 2.804 -10.761 -5.188 0.269 -5.158 0
I(log(area)) -0.404 0.380 -1.147 -0.406 0.346 -0.409 0
I(log(pop/area)) 0.015 0.084 -0.148 0.015 0.182 0.014 0
I(elevS) -0.019 0.010 -0.038 -0.019 0.000 -0.019 0
I(Apr + May - mam) 0.107 0.026 0.057 0.107 0.158 0.107 0
I(mam) -0.006 0.096 -0.191 -0.008 0.188 -0.011 0
Random effects:
Name Model
ID Besags ICAR model
Model hyperparameters:
mean sd 0.025quant
size for the nbinomial observations (overdispersion) 0.355 0.047 0.272
Precision for ID 2.086 0.934 0.882
0.5quant 0.975quant mode
size for the nbinomial observations (overdispersion) 0.352 0.457 0.345
Precision for ID 1.883 4.452 1.551
Expected number of effective parameters(std dev): 29.65(6.18)
Number of equivalent replicates : 49.58
Deviance Information Criterion: 2079.14
Effective number of parameters: 30.94
DIC is 15.1213 smaller than model without spring precipitation anomaly.
Thank you for your time.
Analysis and Talk on http://rpubs.com/thjagger/
Thomas Jagger tjagger@fsu.edu