Learn R Programming

brms (version 1.1.0)

pp_check.brmsfit: Posterior Predictive Checks for brmsfit Objects

Description

Perform posterior predictive checks with the help of the bayesplot package.

Usage

"pp_check"(object, type, nsamples, group = NULL, time = NULL, x = NULL, re_formula = NULL, subset = NULL, ntrys = 5, ...)

Arguments

object
An object of class brmsfit.
type
Type of the ppc plot as given by a character string. Currently, the following plots (as names) are implemented: dens dens_overlay, hist, resid, resid_binned, scatter, scatter_avg, scatter_avg_grouped, stat, stat_2d, stat_grouped, ts, ts_grouped, and violin_grouped.
nsamples
Positive integer indicating how many posterior samples should be used. If NULL all samples are used. If not specified, the number of posterior samples is chosen automatically. Ignored if subset is not NULL.
group
Optional name of a grouping factor in the model by which to stratify the ppc plot. This argument is required for ppc *_grouped types and ignored otherwise.
time
Optional name of a time variable in the model by which to order time-series plots. Only used for ppc ts* types and ignored otherwise.
x
Optional name of a variable in the model. Only used for ppc vs_x* types and ignored otherwise.
re_formula
formula containing random effects to be considered in the prediction. If NULL (default), include all random effects; if NA, include no random effects.
subset
A numeric vector specifying the posterior samples to be used. If NULL (the default), all samples are used.
ntrys
Parameter used in rejection sampling for truncated discrete models only (defaults to 5). For more details see predict.brmsfit.
...
Further arguments passed to the ppc functions of the bayesplot package.

Value

A ggplot object that can be further customized using the ggplot2 package.

Details

For a detailed explanation of each of the ppc functions, see the documentation of the bayesplot package.

Examples

Run this code
## Not run: 
# fit <-  brm(count ~ log_Age_c + log_Base4_c * Trt_c
#             + (1|patient) + (1|visit),
#             data = epilepsy, family = poisson())
# 
# pp_check(fit) # shows dens_overlay plot by default
# pp_check(fit, type = "resid", nsamples = 12)
# pp_check(fit, type = "scatter_average", nsamples = 100)
# pp_check(fit, type = "stat_2d")
# ## End(Not run)

Run the code above in your browser using DataLab