Generates a data frame of bins representing the kernel density (or
histogram) of a vector, suitable for use in generating predictive
distributions for visualization. These functions were originally
designed for use with the now-deprecated predict_curve()
, and
may be deprecated in the future.
density_bins(x, n = 101, ...)histogram_bins(x, n = 30, breaks = n, ...)
A data frame representing bins and their densities with the following columns:
Bin midpoint
Lower endpoint of each bin
Upper endpoint of each bin
Density estimate of the bin
Matthew Kay
These functions are simple wrappers to density()
and
hist()
that compute density estimates and return their results
in a consistent format: a data frame of bins suitable for use with
the now-deprecated predict_curve()
.
density_bins
computes a kernel density estimate using
density()
.
histogram_bins
computes a density histogram using hist()
.
See add_predicted_draws()
and stat_lineribbon()
for a better approach. These
functions may be deprecated in the future.