Skip to contents

Computes bootstrapped summary via bootstrap_response_counts() and posterior predictions via posterior_predictions_for_response_counts(), then joins them on fixed factors and response variable as specified by the formula

Usage

compute_bootstrap_and_posterior_predictions(
  df,
  formula,
  eta,
  cutpoints,
  ci_variable = "P",
  RBoot = 2000,
  RPost = 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).

RBoot

Number of samples for bootstrapping, default is 2000.

RPost

Number of posterior 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_avg <-
  compute_bootstrap_and_posterior_predictions(aiq,
                                              Response ~ Group + Question,
                                              eta_draws,
                                              cutpoints_draws,
                                              RBoot=10,
                                              RPost=10)