Learn R Programming

brms (version 1.4.0)

marginal_smooths.brmsfit: Display Smooth Terms

Description

Display smooth s and t2 terms of models fitted with brms.

Usage

"marginal_smooths"(x, smooths = NULL, probs = c(0.025, 0.975), resolution = 100, too_far = 0, ...)
marginal_smooths(x, ...)

Arguments

x
An object usually of class brmsfit.
smooths
Optional character vector of smooth terms to display. If NULL (the default) all smooth terms are shown.
probs
The quantiles to be used in the computation of credible intervals (defaults to 2.5 and 97.5 percent quantiles)
resolution
Number of support points used to generate the plots. Higher resolution leads to smoother plots. Defaults to 100. If contour is TRUE, this implies 10000 support points for interaction terms, so it might be necessary to reduce resolution when only few RAM is available.
too_far
For contour plots only: Grid points that are too far away from the actual data points can be excluded from the plot. too_far determines what is too far. The grid is scaled into the unit square and then grid points more than too_far from the predictor variables are excluded. By default, all grid points are used. Ignored for non-contour plots.
...
Currently ignored.

Value

For the brmsfit method, an object of class brmsMarginalEffects. See marginal_effects for more details and documentation of the related plotting function.

Details

Two-dimensional smooth terms will be visualized using contour plots.

Examples

Run this code
## Not run: 
# set.seed(0) 
# dat <- mgcv::gamSim(1, n = 200,scale = 2)
# fit <- brm(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)
# # show all smooth terms
# plot(marginal_smooths(fit), rug = TRUE, ask = FALSE)
# # show only the smooth term s(x2)
# plot(marginal_smooths(fit, smooths = "s(x2)"), ask = FALSE)
# 
# # fit and plot a two-dimensional smooth term
# fit2 <- brm(y ~ t2(x0, x2), data = dat)
# ms <- marginal_smooths(fit2)
# plot(ms, stype = "contour")
# plot(ms, stype = "raster")
# ## End(Not run)

Run the code above in your browser using DataLab