plot_ppc.bgmfit {bsitar} | R Documentation |
Perform posterior predictive distribution checks
Description
Perform posterior predictive checks with the help of the bayesplot package.
Usage
## S3 method for class 'bgmfit'
plot_ppc(
model,
type,
ndraws = NULL,
dpar = NULL,
draw_ids = NULL,
prefix = c("ppc", "ppd"),
group = NULL,
x = NULL,
newdata = NULL,
resp = NULL,
size = 0.25,
alpha = 0.7,
trim = FALSE,
bw = "nrd0",
adjust = 1,
kernel = "gaussian",
n_dens = 1024,
pad = TRUE,
discrete = FALSE,
binwidth = NULL,
bins = NULL,
breaks = NULL,
freq = TRUE,
y_draw = c("violin", "points", "both"),
y_size = 1,
y_alpha = 1,
y_jitter = 0.1,
verbose = FALSE,
deriv_model = NULL,
dummy_to_factor = NULL,
expose_function = FALSE,
usesavedfuns = NULL,
clearenvfuns = NULL,
envir = NULL,
...
)
plot_ppc(model, ...)
Arguments
model |
An object of class |
type |
Type of the ppc plot as given by a character string.
See |
ndraws |
A positive integer indicating the number of posterior draws to
use in estimation. If |
dpar |
Optional name of a predicted distributional parameter. If specified, expected predictions of this parameters are returned. |
draw_ids |
An integer specifying the specific posterior draw(s) to use
in estimation (default |
prefix |
The prefix of the bayesplot function to be applied. Either '"ppc"' (posterior predictive check; the default) or '"ppd"' (posterior predictive distribution), the latter being the same as the former except that the observed data is not shown for '"ppd"'. |
group |
Optional name of a factor variable in the model
by which to stratify the ppc plot. This argument is required for
ppc |
x |
Optional name of a variable in the model.
Only used for ppc types having an |
newdata |
An optional data frame for estimation. If |
resp |
A character string (default |
size , alpha |
Passed to the appropriate geom to control the appearance of the predictive distributions. |
trim |
A logical scalar passed to |
bw , adjust , kernel , n_dens |
Optional arguments passed to
|
pad |
A logical scalar passed to |
discrete |
For |
binwidth |
Passed to |
bins |
Passed to |
breaks |
Passed to |
freq |
For histograms, |
y_draw |
For |
y_jitter , y_size , y_alpha |
For |
verbose |
A logical argument (default |
deriv_model |
A logical value specifying whether to estimate the
velocity curve from the derivative function or by differentiating the
distance curve. Set |
dummy_to_factor |
A named list (default
|
expose_function |
A logical argument (default |
usesavedfuns |
A logical value (default |
clearenvfuns |
A logical value indicating whether to clear the exposed
Stan functions from the environment ( |
envir |
The environment used for function evaluation. The default is
|
... |
Additional arguments passed to the |
Details
The plot_ppc() function is a wrapper around the
brms::pp_check()
function, which allows for the visualization of
posterior predictive checks.
Value
A ggplot
object that can be further customized using the
ggplot2 package.
Author(s)
Satpal Sandhu satpal.sandhu@bristol.ac.uk
Examples
# Fit Bayesian SITAR model
# To avoid mode estimation, which takes time, the Bayesian SITAR model is fit to
# the 'berkeley_exdata' and saved as an example fit ('berkeley_exfit').
# See the 'bsitar' function for details on 'berkeley_exdata' and 'berkeley_exfit'.
# Check and confirm whether the model fit object 'berkeley_exfit' exists
berkeley_exfit <- getNsObject(berkeley_exfit)
model <- berkeley_exfit
plot_ppc(model, ndraws = 100)