Re: [r-inla] Using inla.tmarginal with gaussian distribution and log link function

145 views
Skip to first unread message

Helpdesk

unread,
Sep 22, 2021, 1:46:45 PM9/22/21
to Kurt McLaren, R-inla discussion group

the safe option is to always start from the marginal in the internal
scale, as those are more 'gaussian'-like, and transform from there. If
the problem is ''well behaved'' with enough data, then you can start
anywhere, but personally, I always convert from the internal scale.

to get the variance from the the log-precision, then do (as you suggest)

marg.variance = inla.tmarginal(
function(x) exp(-x),
mod$internal.marginals.hyperpar[[1]])

and then do summary

inla.zmarginal(marg.variance)


personally, I like more stdev which is in an interpretable scale, then
use 'exp(-x/2)'





On Mon, 2021-09-20 at 15:01 -0700, Kurt McLaren wrote:
> Hi, I am seeking some help and thanks for the help in advance. I used a
> log link function with a Gaussian distribution for a model:
> mod =   inla(formula,
>              data=inla.stack.data(stack.est, spde=spde),
>              family="gaussian",control.family = list(link = "log"),
>              control.predictor=list(A=inla.stack.A(stack.est),
> compute=TRUE),inla.setOption(scale.model.default = TRUE),
>              control.compute=list(cpo=TRUE, dic=TRUE,  config=TRUE),
>              keep=FALSE, verbose=TRUE)
>
>
> However, I am unsure how to compute the  variance of the error term. If 
> I use:
>  inla.tmarginal(function(x) 1/x, mod$marginals.hyperpar$"Precision for
> the Gaussian observations"),
> the value is very small, as if it is still on a log scale.  This also
> gives the same result:
> inla.tmarginal(function(x) exp(-x),mod$internal.marginals.hyperpar[[1]])
>
> If however I use 
> inla.tmarginal(function(x) x,mod$internal.marginals.hyperpar[[1]]),
> the values seem reasonable. Can anyone give me advice on which one
> should be used?
>
> Thanks,
> Kurt
> --
> 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 view this discussion on the web, visit
> https://groups.google.com/d/msgid/r-inla-discussion-group/76769120-5d93-4312-a903-0231ee833966n%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org

Reply all
Reply to author
Forward
0 new messages