I am simulating data according to this model (R version 3.3.1):
set.seed(1)
T <- 10^3
mu <- 20
rho <- 0.7
sigma2 <- 5
x <- mu + arima.sim(model=list(ar=rho), n=T, sd=sqrt(sigma2))
And I am fitting the same model to these data, both with arima and inla (INLA version 0.0-1468872408, dated 2016-07-18):
fit1 <- arima(x=x, order=c(1,0,0))
fit2 <- inla(formula=x ~ 1 + f(i, model="ar1"), data=data.frame(x=x, i=1:length(x)))
Given the fairly large sample size, I expect the estimates of mu, rho and sigma to be quite accurate.
Indeed, the results are fine for arima:
Coefficients:
ar1 intercept
0.6511 19.8572
s.e. 0.0240 0.2093
sigma^2 estimated as 5.353: log likelihood = -2258.03, aic = 4522.07
Here are the results for inla:
(Intercept) 19.8572 0.2106 19.4426 19.8572 20.2711 19.8572 0
mean sd 0.025quant 0.5quant 0.975quant mode
Precision for the Gaussian observations 1.982e+04 2.033e+04 1412.0635 1.378e+04 7.340e+04 3876.447
Precision for i 1.072e-01 7.500e-03 0.0929 1.071e-01 1.224e-01 0.107
Rho for i 6.528e-01 2.390e-02 0.6052 6.530e-01 6.989e-01 0.653
The estimates of mu and rho are fine.
Thanks in advance,
Tim
Two points:
1. you have to fix the precision for the likelihood on a big value
inla(...,
control.family=list(list(hyper=list(theta=list(initial=10,
fixed=TRUE)))))
2. ar1 in INLA is parametrized as marginal variance, see inla.doc('ar1')
Elias
--
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 post to this group, send email to r-inla-disc...@googlegroups.com.
Visit this group at https://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/d/optout.