posterior_smooths.brmsfit {brms} R Documentation

## 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,
ndraws = NULL,
draw_ids = 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. ndraws Positive integer indicating how many posterior draws should be used. If NULL (the default) all draws are used. Ignored if draw_ids is not NULL. draw_ids An integer vector specifying the posterior draws to be used. If NULL (the default), all draws are used. ... Currently ignored.

### Value

An S x N matrix, where S is the number of posterior draws 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)



[Package brms version 2.17.0 Index]