The distributional package allows distributions to be used in a
vectorised context. It provides methods which are minimal wrappers to
the standard d, p, q, and r distribution functions which are applied to
each distribution in the vector. Additional distributional statistics
can be computed, including the mean(), median(), variance(), and
intervals with hilo().
The distributional nature of a model’s predictions is often understated,
with default output of prediction methods usually only producing point
predictions. Some R packages (such as
forecast) further
emphasise uncertainty by producing point forecasts and intervals by
default, however the user’s ability to interact with them is limited.
This package vectorises distributions and provides methods for working
with them, making distributions compatible with prediction outputs of
modelling functions. These vectorised distributions can be illustrated
with ggplot2 using the
ggdist package, providing
further opportunity to visualise the uncertainty of predictions and
teach distributional theory.
Installation
You can install the released version of distributional from
CRAN with:
install.packages("distributional")
The development version can be installed from
GitHub with:
Additionally, some distributions may support other methods such as
mathematical operations and summary measures. If the methods aren’t
supported, a transformed distribution will be created.
This package differs from the above libraries by storing the
distributions in a vectorised format. It does this using
vctrs, so it should play nicely with the
tidyverse (try putting distributions into a tibble!).
distributional
The distributional package allows distributions to be used in a vectorised context. It provides methods which are minimal wrappers to the standard d, p, q, and r distribution functions which are applied to each distribution in the vector. Additional distributional statistics can be computed, including the
mean(),median(),variance(), and intervals withhilo().The distributional nature of a model’s predictions is often understated, with default output of prediction methods usually only producing point predictions. Some R packages (such as forecast) further emphasise uncertainty by producing point forecasts and intervals by default, however the user’s ability to interact with them is limited. This package vectorises distributions and provides methods for working with them, making distributions compatible with prediction outputs of modelling functions. These vectorised distributions can be illustrated with ggplot2 using the ggdist package, providing further opportunity to visualise the uncertainty of predictions and teach distributional theory.
Installation
You can install the released version of distributional from CRAN with:
The development version can be installed from GitHub with:
Examples
Distributions are created using
dist_*()functions. A list of included distribution shapes can be found here: https://pkg.mitchelloharawild.com/distributional/reference/The standard four distribution functions in R are usable via these generics:
You can also compute intervals using
hilo()Additionally, some distributions may support other methods such as mathematical operations and summary measures. If the methods aren’t supported, a transformed distribution will be created.
You can also visualise the distribution(s) using the ggdist package.
Related work
There are several packages which unify interfaces for distributions in R:
This package differs from the above libraries by storing the distributions in a vectorised format. It does this using vctrs, so it should play nicely with the tidyverse (try putting distributions into a tibble!).