Skip to contents

Computes the visual-analysis summary statistics of Grekov & Pustejovsky (2026) on the observed data and on posterior-predictive replicate datasets, then returns the posterior predictive p-value for each statistic. The statistics are initial performance, within-phase level (mean), trend (OLS slope), variability (SD), absence of behavior (proportion of outcomes \(\le 0\)), immediacy (first-five time-specific treatment effects), non-overlap (Kendall's Tau via SingleCaseES), and lag-1 autocorrelation. Each is computed per case and pooled across cases; the level/trend/variability/absence statistics are additionally split by baseline vs intervention condition.

Usage

posterior_predictive_features(
  model,
  data = NULL,
  statistics = .ppc_statistics_all,
  n_draws = 500L,
  mode = c("same", "new"),
  intervention_goal = c("increase", "decrease")
)

Arguments

model

A fitted brmsfit.

data

Data holding the outcome, case, phase and (optional) time columns; defaults to the model's data.

statistics

Character vector selecting which statistics to compute.

n_draws

Number of posterior-predictive replicate datasets.

mode

"same" replicates for the observed cases; "new" draws new case effects from the population posterior (allow_new_levels = TRUE) to assess generalization.

intervention_goal

"increase" or "decrease"; sets the improvement direction for immediacy and Tau.

Value

A list with summary (one row per statistic/case/phase, holding the observed value, posterior predictive p-value and a flag at p < 0.025 or p > 0.975) and draws (long data frame of replicate values for density plots). Empty data frames if the required columns or posterior draws are unavailable.

Details

The lag-1 autocorrelation uses stats::acf on the within-condition centered series rather than the REML AR(1) fit of the source paper, to avoid an nlme dependency.

References

Grekov, Y., & Pustejovsky, J. E. (2026). A gentle introduction to Bayesian posterior predictive checking for single-case researchers. Journal of Behavioral Education.

Examples

if (interactive()) {
  fit <- run_scd_analysis(simulate_scd_data())$model
  posterior_predictive_features(fit, n_draws = 200)$summary
}