Plot posterior or prior predictive distributions. Each of these functions
makes the same plot as the corresponding ppc_
function
but without plotting any observed data y
. The Plot Descriptions section
at PPC-distributions has details on the individual plots.
ppd_data(ypred, group = NULL)ppd_dens_overlay(
ypred,
...,
size = 0.25,
alpha = 0.7,
trim = FALSE,
bw = "nrd0",
adjust = 1,
kernel = "gaussian",
n_dens = 1024
)
ppd_ecdf_overlay(
ypred,
...,
discrete = FALSE,
pad = TRUE,
size = 0.25,
alpha = 0.7
)
ppd_dens(ypred, ..., trim = FALSE, size = 0.5, alpha = 1)
ppd_hist(ypred, ..., binwidth = NULL, bins = NULL, breaks = NULL, freq = TRUE)
ppd_freqpoly(
ypred,
...,
binwidth = NULL,
bins = NULL,
freq = TRUE,
size = 0.5,
alpha = 1
)
ppd_freqpoly_grouped(
ypred,
group,
...,
binwidth = NULL,
bins = NULL,
freq = TRUE,
size = 0.5,
alpha = 1
)
ppd_boxplot(ypred, ..., notch = TRUE, size = 0.5, alpha = 1)
The plotting functions return a ggplot object that can be further
customized using the ggplot2 package. The functions with suffix
_data()
return the data that would have been drawn by the plotting
function.
An S
by N
matrix of draws from the posterior (or prior)
predictive distribution. The number of rows, S
, is the size of the
posterior (or prior) sample used to generate ypred
. The number of
columns, N
, is the number of predicted observations.
A grouping variable of the same length as y
.
Will be coerced to factor if not already a factor.
Each value in group
is interpreted as the group level pertaining
to the corresponding observation.
Currently unused.
Passed to the appropriate geom to control the appearance of the predictive distributions.
A logical scalar passed to ggplot2::geom_density()
.
Optional arguments passed to
stats::density()
to override default kernel density estimation
parameters. n_dens
defaults to 1024
.
For ppc_ecdf_overlay()
, should the data be treated as
discrete? The default is FALSE
, in which case geom="line"
is
passed to ggplot2::stat_ecdf()
. If discrete
is set to
TRUE
then geom="step"
is used.
A logical scalar passed to ggplot2::stat_ecdf()
.
Passed to ggplot2::geom_histogram()
to override
the default binwidth.
Passed to ggplot2::geom_histogram()
to override
the default binwidth.
Passed to ggplot2::geom_histogram()
as an
alternative to binwidth
.
For histograms, freq=TRUE
(the default) puts count on the
y-axis. Setting freq=FALSE
puts density on the y-axis. (For many
plots the y-axis text is off by default. To view the count or density
labels on the y-axis see the yaxis_text()
convenience
function.)
For the box plot, a logical scalar passed to
ggplot2::geom_boxplot()
. Note: unlike geom_boxplot()
, the default is
notch=TRUE
.
For Binomial data, the plots may be more useful if the input contains the "success" proportions (not discrete "success" or "failure" counts).
Other PPDs:
PPD-intervals
,
PPD-overview
,
PPD-test-statistics
# difference between ppd_dens_overlay() and ppc_dens_overlay()
color_scheme_set("brightblue")
preds <- example_yrep_draws()
ppd_dens_overlay(ypred = preds[1:50, ])
ppc_dens_overlay(y = example_y_data(), yrep = preds[1:50, ])
Run the code above in your browser using DataLab