Compute summary of posterior predictive distribution for the data given posterior distributions of eta and cutpoints
posterior_predictions_for_response_counts.RdCompute summary of posterior predictive distribution for the data given posterior distributions of eta and cutpoints
Usage
posterior_predictions_for_response_counts(
df,
formula,
eta,
cutpoints,
ci_variable = "P",
R = NULL,
CI = 0.97,
.progress = TRUE
)Arguments
- df
Table with data
- formula
Formula that specifies outcome variable, fixed and random effects.
- eta
Matrix of samples_n x nrow(df), each row is a single posterior sample
- cutpoints
Matrix of samples_n x nlevels(df$outcome) - 1, each row is a single posterior sample
- ci_variable
Which variable to use for percentile confidence intervals, either
"N"or"P"(default).- R
Number of samples to process,
NULL(default) means all samples are used.- CI
Percentile confidence interval, default is
0.97- .progress
Logical, whether to show progress bar during bootstrapping. Default is
TRUE.
Value
data.frame or tibble with fixed effects columns, PosteriorMean, PosteriorMedian, PosteriorLowerCI, and PosteriorUpperCI.
Examples
data(aiq)
data(aiq_draws)
eta_draws <- extract_stan_posterior_matrix(aiq_draws, eta)
cutpoints_draws <- extract_stan_posterior_matrix(aiq_draws, cutpoints)
aiq_posterior_avg <-
posterior_predictions_for_response_counts(aiq,
Response ~ Group + Question,
eta_draws,
cutpoints_draws,
R=10)