Add draws from a matrix of draws (usually draws from a predictive distribution) to a data frame in tidy format. This is
a generic version of add_predicted_draws()
that can be used with model types
that have their own prediction functions that are not yet supported by tidybayes.
add_draws(data, draws, value = ".value")
A data frame (actually, a tibble) with a .row
column (a
factor grouping rows from the input data
), a .draw
column (a unique index corresponding to each draw
from the distribution), and a column with its name specified by the value
argument (default is .value
)
containing the values of draws from draws
. The data frame is grouped by all rows in data
plus the .row
column.
Data frame to add draws to, with M rows.
N by M matrix of draws, with M columns corresponding to the M rows in data
, and N draws in each column.
The name of the output column; default ".value"
.
Matthew Kay
Given a data frame with M rows and an N by M matrix of N draws, adds a .row
, .draw
, and .value
column (or another name if value
is set) to data
, and expands data
into a long-format dataframe of draws.
add_epred_draws(df, m)
is roughly equivalent to add_draws(df, posterior_epred(m, newdata = df))
, except
that add_epred_draws
standardizes argument names and values across packages and has additional features for some
model types (like handling ordinal responses and distributional parameters in brms).
add_predicted_draws(df, m)
is roughly equivalent to add_draws(df, posterior_predict(m, newdata = df))
, except
that add_predicted_draws
standardizes argument names and values across packages.
add_predicted_draws()
, add_draws()