Gaussian likelihood model with fixed precision

221 views
Skip to first unread message

Zhe Sha

unread,
Jun 7, 2017, 7:28:36 AM6/7/17
to R-inla discussion group
Hi,

I want to estimate and predict a Gaussian likelihood model with spde latent field and I want to fix the error term in the Gaussian likelihood model with given values. 
Suppose my data frame looks like this
ID   ydata   std 
1    y1        s1
2    y2        s2
3    y3        s3
...  ...         ...

I want to use the value in the column "std" to be the Gaussian likelihood errors, so I fix the precision to be 1 and use 1/std for scale. Below are my codes.

st.est <- inla.stack(data = list(y=ydata), A = list(Ay), 
                     effects = list(spde = 1:n.spde), tag = "est")

st.pred <- inla.stack(data = list(y=NA), A = list(Ay), 
                      effects = list(spde=1:n.spde), tag = "pred")
st <- inla.stack(st.est, st.pred)

## Fix the sigma_e^2 to be 1 and scale them according to the data in inla(...,scale = scale)
## Default uses log(1/sigma_e^2) to be loggamma distribution with intial value = 0.
hyper <- list(prec = list(fixed = TRUE, initial = 0))
formula = y ~ -1 + f(spde, model = my_spde)
prec_scale <- rep(1/std, 2)

res_inla <- inla(formula, data = inla.stack.data(st, spde = spde), family = "gaussian", 
                      scale = prec,_scale, control.family = list(hyper = hyper),
                      control.predictor=list(A=inla.stack.A(st), compute =TRUE))

Just wondering if I have done it correctly in INLA, especially about setting up the scale. Is the resulted variance 1/(scale*prec) or 1/(scale*prec)^2? 
i.e Should I use scale = 1/std or scale = 1/std^2 ?
Also, when I want to predict at the data location, should I also provide the scale or just leave them to be one?
i.e Should I use scale = rep(1/std, 2) or  scale = c(1/std, rep(1, length(ydata)) ?

Thanks for your attention and help!

Zhe

Elias T Krainski

unread,
Jun 13, 2017, 10:21:39 AM6/13/17
to r-inla-disc...@googlegroups.com

Hi Zha,

If you want the predictions at the data locations, there is no need for a new stack as such predictions will be already computed if asked, just set compute=TRUE in control.predictor().

The 'scale' is the scale for the precision, which is the inverse of the squared standard deviation.

Best,

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.

Reply all
Reply to author
Forward
0 new messages