Learn R Programming

inlabru (version 2.1.9)

predict.inla: Prediction from fitted inla model

Description

Takes a fitted inla object produced by the function inla() and produces predictions given a new set of values for the model covariates or the original values used for the model fit. The predictions can be based on any R expression that is valid given these values/covariates and the posterior of the estimated effects.

Usage

# S3 method for inla
predict(object, ...)

Arguments

object

A bru object obtained by calling bru or lgcp.

...

Arguments passed on to predict.bru.

Value

A prediction object.

Examples

Run this code
# NOT RUN {
# Some features use the INLA package.
if (require("INLA", quietly = TRUE)) {

# Generate some data

input.df <- data.frame(x=cos(1:10))
input.df <- within(input.df, y <- 5 + 2*cos(1:10) + rnorm(10, mean=0, sd=0.1))

# Fit a Gaussian likelihood model

formula = y ~ x
fit <- inla(formula, "gaussian", data = input.df, control.compute=list(config = TRUE))

# Estimate posterior statistics of exp(x), where x is the fixed effect.

xpost = predict(fit, NULL, ~ exp(x))
xpost
plot(xpost)

}
# }

Run the code above in your browser using DataLab