Fitted values for INLA

1,154 views
Skip to first unread message

Alan Arazi

unread,
Jun 7, 2017, 1:25:24 AM6/7/17
to R-inla discussion group
Hi,

I've seen discussions but no answer was really helpful.

I've tried to fit INLA for SMR using the following formula:

ID = 1:2644
formula_bym = shape_02$patients_total ~ 1 + f(ID, model="bym", graph = "neighbours.adj", constr=TRUE, scale.model=TRUE)
m05_inla_bym = inla(formula_bym, family="poisson", data=as.data.frame(shape_02), E=shape_02$expected)

And later on I've tried to add a covariate:

formula_bym_a = shape_02$patients_total ~ 1 + f(ID, model="bym", graph = m05a_inla_bym = inla(formula_bym_a, family="poisson", data=as.data.frame(shape_02), E=shape_02$expected)

However, the results are a bit confusing.

For both models, m05a_inla_bym$summary.fitted.values returns "data frame with 0 columns and 0 rows" and m05a_inla_bym$marginals.fitted.values returns "NULL".

From my understanding so far, m05a_inla_bym$summary.fixed can give me "alpha" and "beta". For the random effects I get the dataframe m05a_inla_bym$summary.random$ID but it has 2n rows. From my understanding, to compute the prediction, I should manually take the first n rows and just follow the INLA formula? it's really surprising not to have a function which does it automatically.

Thanks
Alan

Finn Lindgren

unread,
Jun 7, 2017, 1:38:19 AM6/7/17
to Alan Arazi, R-inla discussion group
You need to use
inla(..., control.predictor=list(compute=TRUE))
to enable the fitted.values calculations.

Finn
--
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.

Alan Arazi

unread,
Jun 7, 2017, 1:50:47 AM6/7/17
to R-inla discussion group, alana...@gmail.com
Thanks a lot! 

בתאריך יום רביעי, 7 ביוני 2017 בשעה 08:38:19 UTC+3, מאת Finn Lindgren:
You need to use
inla(..., control.predictor=list(compute=TRUE))
to enable the fitted.values calculations.

Finn

On 7 Jun 2017, at 06:25, Alan Arazi <alana...@gmail.com> wrote:

Hi,

I've seen discussions but no answer was really helpful.

I've tried to fit INLA for SMR using the following formula:

ID = 1:2644
formula_bym = shape_02$patients_total ~ 1 + f(ID, model="bym", graph = "neighbours.adj", constr=TRUE, scale.model=TRUE)
m05_inla_bym = inla(formula_bym, family="poisson", data=as.data.frame(shape_02), E=shape_02$expected)

And later on I've tried to add a covariate:

formula_bym_a = shape_02$patients_total ~ 1 + f(ID, model="bym", graph = m05a_inla_bym = inla(formula_bym_a, family="poisson", data=as.data.frame(shape_02), E=shape_02$expected)

However, the results are a bit confusing.

For both models, m05a_inla_bym$summary.fitted.values returns "data frame with 0 columns and 0 rows" and m05a_inla_bym$marginals.fitted.values returns "NULL".

From my understanding so far, m05a_inla_bym$summary.fixed can give me "alpha" and "beta". For the random effects I get the dataframe m05a_inla_bym$summary.random$ID but it has 2n rows. From my understanding, to compute the prediction, I should manually take the first n rows and just follow the INLA formula? it's really surprising not to have a function which does it automatically.

Thanks
Alan

--
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-group+unsub...@googlegroups.com.

Finn Lindgren

unread,
Jun 7, 2017, 2:12:20 AM6/7/17
to Alan Arazi, R-inla discussion group
You also need to supply a link= specification (link=1 should be enough) to make it apply the link function to the linear predictor for missing values. Search the FAQ.

Finn
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages