Prediction by INLA

1,124 views
Skip to first unread message

Thomas Tong

unread,
Jun 4, 2012, 5:25:57 PM6/4/12
to r-inla-disc...@googlegroups.com
I am aware that, in INLA there is no function ``predict'' as for glm/lm in R. Predictions must to done as a part of the model fitting itself, see:

But this has a huge drawback as each time when you do prediction, you have to fit the model, which is not efficient, especially when you have to do prediction sequentially. I wonder if there is any new development on INLA that makes prediction more convenient, like that for glm/lm in R. Thanks a lot!

-Thomas

Andrea Riebler

unread,
Jun 5, 2012, 5:29:20 AM6/5/12
to r-inla-disc...@googlegroups.com
Hi Thomas,

to the best of my knowledge there is not yet an easy/automatic way to process data sequentially using INLA. However, I think there is some development in this direction, see for example

https://www.scss.tcd.ie/disciplines/statistics/statica/statica_web/Zurich_11.pdf

but I am not sure what the current state of this proposal is and whether it is applicable in the general context.

Best,
Andrea

INLA help

unread,
Jun 5, 2012, 6:11:36 AM6/5/12
to Thomas Tong, INLA help, r-inla-disc...@googlegroups.com
I agree, its unconvenient. There are currently no way out of it, as Andrea said...  the only think you could do, is to restart a larger model with the fit of a smaller model, so you might save some time, but not in the large ammount as you would like. 

Yes, check up the group at TCD which do sequential models in the same framework.


INLA help



Aminath Shausan

unread,
May 29, 2025, 12:38:52 AM5/29/25
to R-inla discussion group
Hi all, 
I was looking for a way to do forecast from inla without needing to re-fit the model and landed on this page. 
In my application, I have lagged features, and with the current methodology, I need to assign NA to forecast time points and re-fit the model to get predictions. 
This is inconvenient as I need to perform the forecasts sequentially. 
I wonder if there is a development such as the glm predict() function, where we can use the fitted model to perform predictions for new data. 

thank you

Elias T. Krainski

unread,
May 29, 2025, 1:39:43 AM5/29/25
to R-inla discussion group
You can fix the hyper-parameters (no need to refit). See the following example

d1 <- data.frame(x=runif(10), y = rnorm(10))
fit <- inla(y ~ x, data = d1)

d2 <- data.frame(x = runif(3), y = NA)
fit2 <- inla(y ~x, data = rbind(d1,d2),
  control.mode = list(initial = fit$mode$theta, restart = FALSE))
fit2$summary.fitted.values[11:13, ]

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 view this discussion, visit https://groups.google.com/d/msgid/r-inla-discussion-group/6c4aee7a-3c4c-4d29-89b3-d4f6ffe35dfan%40googlegroups.com.

Elias T. Krainski

unread,
May 29, 2025, 1:42:52 AM5/29/25
to R-inla discussion group
code fix:

d1 <- data.frame(x=runif(10), y = rnorm(10))
fit <- inla(y ~ x, data = d1)

d2 <- data.frame(x = runif(3), y = NA)
fit2 <- inla(y ~x, data = rbind(d1,d2),
  control.mode = list(theta = fit$mode$theta, restart = FALSE))
fit2$summary.fitted.values[11:13, ]

Aminath Shausan

unread,
May 30, 2025, 1:29:34 AM5/30/25
to R-inla discussion group
thank you Elias, 
that worked

John Molitor

unread,
Jun 8, 2025, 1:15:00 AM6/8/25
to R-inla discussion group
Elias,
Thanks for this - very helpful. Does this prediction approach properly deal with changes in x when they are weights in a random effect (e.g. f(id,x,)). Does it deal with splines properly? If so, should this be made into a predict function?

Thanks,

John
Reply all
Reply to author
Forward
0 new messages