Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

INLA initial value as fixed

21 views
Skip to first unread message

Alokesh Manna

unread,
Dec 9, 2024, 9:55:08 AM12/9/24
to R-inla discussion group
Hi INLA group,

I am trying some experiments as fixed value of hyperprior. 

I put log gamma. I know internally that log(perc)=log(tau)=(theta).

Just for the fixed case,

a) If I put the value below, does it mean prec=25? 

b) Also in your case, why did you put the default value as 4?(check below). It is neither mean/mode for $theta$param (1e+00 5e-05).

f(as.numeric(spatial_ID_15),value_u1__value_d1,
                               constr=FALSE,  model = "besag", scale.model=TRUE,
                                  graph = graph_adjacency_2 ,
                                  hyper=list(theta = list(prior = "loggamma",
                                                          param=c(3,.003),
                                                          initial=log(25.0),
                                                         fixed=TRUE,
                                                         scale.model=TRUE)
                                  )
                              ) 



inla.models()$latent$besag$hyper
$theta
$theta$hyperid
[1] 8001
attr(,"inla.read.only")
[1] FALSE

$theta$name
[1] "log precision"
attr(,"inla.read.only")
[1] FALSE

$theta$short.name
[1] "prec"
attr(,"inla.read.only")
[1] FALSE

$theta$prior
[1] "loggamma"
attr(,"inla.read.only")
[1] FALSE

$theta$param
[1] 1e+00 5e-05
attr(,"inla.read.only")
[1] FALSE

$theta$initial
[1] 4
attr(,"inla.read.only")
[1] FALSE

$theta$fixed
[1] FALSE
attr(,"inla.read.only")
[1] FALSE

$theta$to.theta
function (x)
log(x)
<bytecode: 0x12c7f94a0>
<environment: 0x12c7ef660>
attr(,"inla.read.only")
[1] TRUE

$theta$from.theta
function (x)
exp(x)
<bytecode: 0x12c7f95b8>
<environment: 0x12c7ef660>
attr(,"inla.read.only")
[1] TRUE

Alokesh Manna

unread,
Dec 9, 2024, 10:14:02 AM12/9/24
to R-inla discussion group
Also a follow-up question.

1. Why besag model had a hyperprior as loggamma?
Why not gamma? Was there any specific reason for keeping the default as loggamma?

Finn Lindgren

unread,
Dec 9, 2024, 11:39:17 AM12/9/24
to Alokesh Manna, R-inla discussion group
The priors are set on the internal transformed scale of the parameters. For precisions, that’s theta=log(precision), so a loggamma on theta is a gamma on the precision.
Finn

On 9 Dec 2024, at 15:14, Alokesh Manna <alokesh...@gmail.com> wrote:

Also a follow-up question.
--
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, visit https://groups.google.com/d/msgid/r-inla-discussion-group/dfae2f8a-3938-4dad-bb8c-1f9c2221520an%40googlegroups.com.

Alokesh Manna

unread,
Dec 9, 2024, 11:43:56 AM12/9/24
to Finn Lindgren, R-inla discussion group
Thanks.

If I make fixed=True with initial value log(25), does it mean it will not randomly generate( does not affested by the choise of hyperprior)? It will directly use precision =25 or log(precision)=log(25) equivalently? 

In my run, if I fix that value which I want, it takes a long time for fitting. So I wanted this clarity.

Finn Lindgren

unread,
Dec 9, 2024, 11:45:53 AM12/9/24
to Alokesh Manna, R-inla discussion group
With fixed=TRUE, the prior isn’t used, only the transformation. So initial=log(25) means theta=log(25) i.e. precision=25.
Finn

On 9 Dec 2024, at 16:43, Alokesh Manna <alokesh...@gmail.com> wrote:



Alokesh Manna

unread,
Dec 9, 2024, 11:51:31 AM12/9/24
to Finn Lindgren, R-inla discussion group
Thanks. For some reason in fixed=true, when I have say 15 random effect, and I do prefix some value of theta as log(25) it takes a long time whereas when I fix theta as log(.0005) it is reasonably faster. The second one does not smooth my model well. 

Is there any specific reason I should be looking into?

Also if I give wrong initial value but fixed=False, is there a possibility that it can go wrong?

Helpdesk (Haavard Rue)

unread,
Dec 11, 2024, 2:13:57 AM12/11/24
to Alokesh Manna, Finn Lindgren, R-inla discussion group
On Mon, 2024-12-09 at 11:51 -0500, Alokesh Manna wrote:
> Thanks. For some reason in fixed=true, when I have say 15 random effect, and I
> do prefix some value of theta as log(25) it takes a long time whereas when I
> fix theta as log(.0005) it is reasonably faster. The second one does not
> smooth my model well. 

run with option verbose=TRUE to see what is going on. as always, after upgrade
to the most recent testing version of R-INLA

>
> Is there any specific reason I should be looking into?

the only issue are issues in convergence of the optimizer.


>
> Also if I give wrong initial value but fixed=False, is there a possibility
> that it can go wrong?

the 'best' you can do is to do nothing. the default initial values are often
better than user-supplied ones... the reason is that is better to start with a
to tight model that widens up for data, than the other way around.
Håvard Rue
he...@r-inla.org

Alokesh Manna

unread,
Dec 11, 2024, 2:16:06 AM12/11/24
to Helpdesk, Finn Lindgren, R-inla discussion group
Thanks for the explanation.
Reply all
Reply to author
Forward
0 new messages