Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

posterior_smooths.brmsfit

Posterior Predictions of Smooth Terms


Description

Compute posterior predictions of smooth s and t2 terms of models fitted with brms.

Usage

## S3 method for class 'brmsfit'
posterior_smooths(
  object,
  smooth,
  newdata = NULL,
  resp = NULL,
  dpar = NULL,
  nlpar = NULL,
  nsamples = NULL,
  subset = NULL,
  ...
)

posterior_smooths(object, ...)

Arguments

object

An object of class brmsfit.

smooth

Name of a single smooth term for which predictions should be computed.

newdata

An optional data.frame for which to evaluate predictions. If NULL (default), the original data of the model is used. Only those variables appearing in the chosen smooth term are required.

resp

Optional names of response variables. If specified, predictions are performed only for the specified response variables.

dpar

Optional name of a predicted distributional parameter. If specified, expected predictions of this parameters are returned.

nlpar

Optional name of a predicted non-linear parameter. If specified, expected predictions of this parameters are returned.

nsamples

Positive integer indicating how many posterior samples should be used. If NULL (the default) all samples are used. Ignored if subset is not NULL.

subset

A numeric vector specifying the posterior samples to be used. If NULL (the default), all samples are used.

...

Currently ignored.

Value

An S x N matrix, where S is the number of posterior samples and N is the number of observations.

Examples

## 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)
summary(fit)

newdata <- data.frame(x2 = seq(0, 1, 10))
str(posterior_smooths(fit, smooth = "s(x2)", newdata = newdata))

## End(Not run)

brms

Bayesian Regression Models using 'Stan'

v2.15.0
GPL-2
Authors
Paul-Christian Bürkner [aut, cre], Jonah Gabry [ctb], Sebastian Weber [ctb], Andrew Johnson [ctb], Martin Modrak [ctb]
Initial release
2021-03-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.