Learn R Programming

inlabru (version 2.3.1)

plot.bru: Plot method for posterior marginals estimated by bru

Description

bru() uses INLA::inla() to fit models. The latter estimates the posterior densities of all random effects in the model. This function serves to access and plot the posterior densities in a convenient way.

Usage

# S3 method for bru
plot(x, ...)

Arguments

x

a fitted bru() model.

...

A character naming the effect to plot, e.g. "Intercept". For random effects, adding index = ... plots the density for a single component of the latent model.

Value

an object of class gg

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# Generate some data and fit a simple model
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 <- bru(y ~ x, family = "gaussian", data = input.df)
summary(fit)

# Plot the posterior of the model's x-effect
plot(fit, "x")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab