The following artificial example has 12 independent subjects, two raters and two occasions. The true reference-rater mean change is 0.6, and the true difference between mean changes is 0.2. The two change scores are independently generated with unit variance, as assumed by the basic likelihood. Baseline scores can vary between subjects; the second rater has a constant baseline offset of 0.4.
set.seed(2026)
N <- 12L
baseline <- rnorm(N, 10, 2)
d1 <- rnorm(N, 0.6, 1)
d2 <- rnorm(N, 0.8, 1)
dat <- data.frame(
id = rep(seq_len(N), each = 4L),
time = rep(c("pre", "pre", "post", "post"), N),
rater = rep(c("r1", "r2"), 2L * N),
score = as.vector(rbind(baseline, baseline + 0.4,
baseline + d1, baseline + 0.4 + d2))
)
head(dat, 8)
#> id time rater score
#> 1 1 pre r1 11.041178
#> 2 1 pre r2 11.441178
#> 3 1 post r1 11.419742
#> 4 1 post r2 12.289385
#> 5 2 pre r1 7.840618
#> 6 2 pre r2 8.240618
#> 7 2 post r1 8.214802
#> 8 2 post r2 10.948702fit <- fit_model(dat, id, time, rater, score,
time_order = c("pre", "post"),
rater_order = c("r1", "r2"),
n_draws = 10000, seed = 12)
summary(fit)
#>
#> Summary of babebi model fit
#> ---------------------------
#> parameter estimate
#> beta 0.488
#> gamma 0.911
#>
#> parameter ci_low ci_high p_pos
#> beta -0.074 1.047 0.956
#>
#> bf10 log_bf10
#> 0.903 -0.102
#>
#> N delta bias_r2
#> 12 0.943 0.855The regression is \(D_{ij}=\beta+\gamma I(j=2)+\epsilon_{ij}\) with independent \(N(0,\sigma^2)\) residuals. The least-squares estimates are the reference-rater sample mean and the difference between rater-specific sample means.
c(reference = mean(d1), discrepancy = mean(d2-d1))
#> reference discrepancy
#> 0.4876925 0.9105449
c(reference = fit$beta_hat, discrepancy = fit$gamma_hat)
#> reference discrepancy
#> 0.4876925 0.9105449The approximate posterior draws use \(N_2(\hat\theta,\hat\sigma^2(X^TX)^{-1}+10^{-10}I)\), i.e., a flat coefficient prior conditional on the plug-in variance estimate, with a small numerical diagonal adjustment. Residual variance uncertainty is not propagated. The 95% interval is an empirical quantile interval of approximate posterior draws. A displayed probability of 1 or 0 is based on finitely many draws and does not establish certainty.
The BIC-based BF10 compares a model allowing nonzero reference-rater change with a model fixing that change to zero while retaining the second-rater term. It neither tests rater agreement nor gives a proper-prior marginal likelihood. It may be unreliable in small samples. Extremely large ordinary-scale values may overflow.
res <- babebi(dat, id, time, rater, score,
time_order = c("pre", "post"),
rater_order = c("r1", "r2"),
validate = TRUE, R = 200,
n_draws = 4000, seed = 15)
res$validation
#>
#> babebi Monte Carlo validation
#> -----------------------------
#> N: 12
#> delta: 0.943
#> bias_r2: 0.855
#> R: 200
#>
#> bias: -0.010
#> RMSE: 0.261
#> coverage: 0.945
#> mean Pr(beta > 0): 0.991
#> mean BF10: 966.894
#> log(mean BF10): 6.874
#>
#> Calibrated design from observed data
#> ------------------------------------
#> N: 12
#> delta: 0.943
#> bias_r2: 0.855
res$fit$design
#> $N
#> [1] 12
#>
#> $delta
#> [1] 0.9429649
#>
#> $bias_r2
#> [1] 0.8552725
#>
#> $time_levels
#> [1] "pre" "post"
#>
#> $rater_levels
#> [1] "r1" "r2"The historical defaults use the observed mean change across both
raters (delta) and the mean difference in rating levels
across occasions (bias_r2). The latter is not generally the
difference between mean changes. The simulation treats these two inputs
as the reference-rater change and additive second-rater change
discrepancy, respectively, and generates independent unit-variance
changes. This is a simplified scenario, not a reproduction of the
observed joint distribution. In this example the 0.4 baseline offset
illustrates why a rating-level discrepancy can differ from a change
discrepancy.
A simulation with the known generating values can be specified explicitly:
val <- montecarlo_from_data(dat, id, time, rater, score,
time_order = c("pre", "post"),
rater_order = c("r1", "r2"),
N = N, delta = 0.6, bias_r2 = 0.2,
R = 200, seed = 16)
val
#>
#> babebi Monte Carlo validation
#> -----------------------------
#> N: 12
#> delta: 0.600
#> bias_r2: 0.200
#> R: 200
#>
#> bias: -0.016
#> RMSE: 0.299
#> coverage: 0.925
#> mean Pr(beta > 0): 0.921
#> mean BF10: 88.403
#> log(mean BF10): 4.482
#>
#> Calibrated design from observed data
#> ------------------------------------
#> N: 12
#> delta: 0.943
#> bias_r2: 0.855Bias and RMSE describe repeated-sampling estimation performance;
coverage describes how often the approximate interval includes the
generating reference-rater change. ppos_mean and
bf_mean average inferential summaries across repetitions;
neither validates the observed effect. The simulation uses analytical
normal intervals, whereas fit_model() uses draw quantiles,
so their finite-draw intervals can differ. The small number of
repetitions here is for illustration; choose a study-specific number
based on Monte Carlo precision.
f0 <- fit_bivariate(dat, id, time, rater, score, model = "M0",
time_order = c("pre", "post"),
rater_order = c("r1", "r2"))
p0 <- posterior_bivariate(f0, prior = "reference")
exact <- contrast_bivariate(p0, "reference")
rbind(approximate = c(fit$ci_low, fit$ci_high),
exact = unname(exact$interval))
#> [,1] [,2]
#> approximate -0.07422335 1.046749
#> exact -0.10602027 1.081405Under the reference prior \(p(\beta,\gamma,\sigma^2)\propto1/\sigma^2\), the coefficient posterior is Student t with \(2N-2\) degrees of freedom. This comparison isolates variance uncertainty under the same independent, equal-variance model. If the raters’ changes are correlated, M0 is also misspecified. See the advanced vignette for M1–M3 and ordinal outcomes.
Gianeselli, I., Bosco, A., & Basso, D. (2026). babebi: An R package for Bayesian estimation and validation in small-N two-rater pre–post designs. Applied Psychological Measurement. https://doi.org/10.1177/01466216261465754