Methods for the {rstantools} posterior-prediction generics. They return a
draws-by-observation matrix and enable {tidybayes} workflows such as
add_epred_draws(), add_predicted_draws(), and add_linpred_draws().
These methods and workflows require the suggested package {rstantools}.
Usage
posterior_epred.mcpfit(
object,
newdata = NULL,
draws = NULL,
ndraws = NULL,
re.form = NULL,
re_formula = NULL,
dpar = NULL,
seed = NULL,
...
)
posterior_predict.mcpfit(
object,
newdata = NULL,
draws = NULL,
ndraws = NULL,
re.form = NULL,
re_formula = NULL,
seed = NULL,
...
)
posterior_linpred.mcpfit(
object,
transform = FALSE,
newdata = NULL,
draws = NULL,
ndraws = NULL,
re.form = NULL,
re_formula = NULL,
dpar = NULL,
seed = NULL,
...
)Arguments
- object
An
mcpfitobject.- newdata
Optional data frame at which to evaluate the model. For GARMA
posterior_predict(), only predictors and required response auxiliaries are needed: each response series is generated recursively without conditioning on an observed response column.- draws, ndraws
Number of posterior draws to return.
drawsfollows the{rstantools}convention;ndrawsis the mcp spelling. Supply at most one.- re.form, re_formula
Group-level effects to include.
NULLincludes all effects andNAexcludes them.- dpar
Distributional parameter for
posterior_epred()andposterior_linpred();NULLuses the expected response.- seed
Optional integer seed for draw selection and posterior prediction.
- ...
Must be empty. Reserved for future use.
- transform
For
posterior_linpred(), return the inverse-link transformed expected response instead of the linear predictor.
Details
For GARMA models, posterior_predict() generates each replicated
response series recursively. It does not condition later predictions on
the observed response history, unlike fitted() and posterior predict().
These methods require posterior draws. For prior prediction, use
predict() with prior = TRUE, which also generates fresh series.
For binomial models, posterior_epred() and posterior_predict() (and
corresponding {tidybayes} workflows such as add_epred_draws()) follow
{brms} and {rstantools} conventions by returning values on the outcome
count scale (rate = FALSE), i.e., expected counts \(E[Y] = n\mu\) and
simulated counts in \(\{0, \dots, n\}\). In contrast, fitted() and predict()
default to proportions (rate = TRUE). To obtain the success probability
parameter \(\mu\) on the \([0, 1]\) scale regardless of trial counts, pass
dpar = "mu".
