Setting an informed prior on quadratic term?

Skip to first unread message

Rowenna Gryba

May 17, 2022, 7:26:05 PMMay 17
to R-inla discussion group

I'm working on a model that includes a quadratic term for one of the covariates. For reasons I need to actually include the quadratic term rather than using splines. I'm having an issue assigning an informed prior to the quadratic term. 

formula <-STATUS ~  x1  + I(x1^2) + x2 + ....

model  <- inla(formula, family ="binomial", ....., control.fixed = list(
                                                             mean = list(x1 = mean.x1,
                                                                                     `x1^2` = mean.x1.2,
                                                                                     x2 = mean.x2),
                                                             prec = list(iceConc.z = prec.x1,
                                                                                     `x1^2` = prec.x1.2,
                                                                                     x2 = prec.x2) ))

For `x1^2` it is going to the default prior rather than my set values. 
I'm assuming it's something silly like how I'm calling the parameter in the control.fixed list? 

Any help would be appreciated!



May 20, 2022, 9:35:47 AMMay 20
to Rowenna Gryba, R-inla discussion group
you can do

xx = x1^2

upfront and then add xx to the data.frame and the formula

otherwise, you can also use

f(xx,model="linear", mean.linear = <mu>, prec.linear = <prec>)

to define prior for this effect. see inla.doc("linear")

this was added to make the prior spesification easier

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
To view this discussion on the web, visit

Håvard Rue

Reply all
Reply to author
0 new messages