Skip to content

Calibration checks

Simulation-based calibration

from symphony_dt.calibration import SBCDesign, run_sbc, pd_v2_prior_design
design = pd_v2_prior_design(60, chains=4, iter_warmup=500, iter_sampling=500)
result = run_sbc(design, n_replicates=200, method="bonferroni")
print(result.verdict.passed, result.verdict.fwer_uncorrected)

Any model can be checked: an SBCDesign takes a generator and a fitter. judge applies Bonferroni, Benjamini-Hochberg or no correction and always reports the uncorrected family-wise risk. rank_histogram_bands gives the binomial band for rank histograms.

Identifiability report (TESTED)

A parameter can pass every convergence gate and still be learnt poorly from the data. identifiability_report compares each global parameter's posterior with its prior. Contraction is 1 minus the ratio of posterior to prior variance. Near 1 the data pin the parameter down; near 0 the posterior is barely narrower than the prior.

from symphony_dt.calibration import identifiability_report, pd_v2_prior_draws
prior = pd_v2_prior_draws(4000)
report = identifiability_report(result, prior)            # result is a FitResult
print(report.to_markdown())
report.plot()

On simulated data, pass the true values as well, for example cohort.truth(). The report then adds the posterior z-score, the distance from the posterior mean to the truth in posterior standard deviations. The plot then shows contraction against z, as proposed by Betancourt (2018) and used by Schad, Betancourt and Vasishth (2021).

A parameter is flagged "weak" when its contraction is below 0.1, and "off truth" when |z| exceeds 3. Both limits can be changed. pd_v2_prior_draws draws all 37 global parameters from the Stan program's priors. Any other model can supply its own prior draws as a mapping from Stan names to arrays.

Contraction describes what one data set says under this model. It is not a proof of identifiability. The model card names two parameters to watch here. The process-noise scale sigma_xi is sensitive to its prior, and the motor link slope b mixes slowly.

Posterior predictive checks

ppc_summary(draws, stan_data) reports, per endpoint, interval coverage, the share of values at each scale boundary against its replicated range, and a PIT histogram. symphony-dt ppc fit runs it on a fit's own data.