This vignette shows how to make power analyses reproducible: capture a manifest (scenario fingerprint, seed, session info), bundle results with metadata and labels, export to CSV/JSON, and use the manifest to regenerate the same outputs.
Run your analysis as usual and create a manifest from the same scenario and seed you used. The manifest records a scenario digest (so you can verify the same design/assumptions later), seed strategy, R and mixpower versions, optional session info, and git SHA when in a repo.
d <- mp_design(clusters = list(subject = 30), trials_per_cell = 4)
a <- mp_assumptions(
fixed_effects = list(`(Intercept)` = 0, condition = 0.3),
residual_sd = 1,
icc = list(subject = 0.1)
)
scn <- mp_scenario_lme4(
y ~ condition + (1 | subject),
design = d,
assumptions = a,
test_method = "wald"
)
seed <- 123
res <- mp_power(scn, nsim = 20, seed = seed)
manifest <- mp_manifest(scn, seed = seed, session = FALSE)
manifest
#> <mp_manifest>
#> scenario_digest: 81c8db483e995593 ...
#> seed:123 (fixed)
#> timestamp: 2026-02-10 01:29:06 EST
#> r_version: 4.5.2
#> mixpower_version: 0.1.0
#> git_sha: 317d17bCombine the result, manifest, and optional labels into a single bundle. Then write a publication-ready table (and, for JSON, manifest and labels) to disk.
bundle <- mp_bundle_results(
res,
manifest,
study_id = "power_2024_01",
analyst = "analyst",
notes = "Initial power run for condition effect"
)
bundle
#> <mp_bundle>
#> result: mp_power
#> study_id: power_2024_01
#> analyst: analyst
#> <mp_manifest>
#> scenario_digest: 81c8db483e995593 ...
#> seed:123 (fixed)
#> timestamp: 2026-02-10 01:29:06 EST
#> r_version: 4.5.2
#> mixpower_version: 0.1.0
#> git_sha: 317d17btab <- mp_report_table(bundle)
tab
#> power_estimate ci_low ci_high failure_rate singular_rate n_effective nsim
#> 1 0 0 0 0 0 20 20mp_write_results(bundle, "power_results.csv", format = "csv", row.names = FALSE)
mp_write_results(bundle, "power_results.json", format = "json")(Export is skipped in the vignette to avoid writing to the user’s working directory.)
To reproduce the same run later:
scenario_digest is a fingerprint of formula,
design, assumptions, and test; you can recompute it with
mp_manifest(scn, session = FALSE)$scenario_digest and
compare to the stored value.mp_power(scn, nsim = 20, seed = manifest$seed).nsim, alpha, and
failure_policy as in the original run (store these in your
notes or in the bundle labels if needed).Example: re-run with the stored seed and confirm the power estimate matches.
You can flatten the manifest to a one-row data frame (e.g. to append
to a log) by building it from the list, omitting the long
session_info if desired:
m <- mp_manifest(scn, seed = 123, session = FALSE)
df_row <- data.frame(
scenario_digest = m$scenario_digest,
seed = m$seed,
seed_strategy = m$seed_strategy,
timestamp = m$timestamp,
r_version = m$r_version,
mixpower_version = m$mixpower_version,
git_sha = m$git_sha,
stringsAsFactors = FALSE
)
df_row
#> scenario_digest seed
#> 1 81c8db483e99559349c12c06e4cb32a095e1364c68af1bb6a8fe13f7863d6cf4 123
#> seed_strategy timestamp r_version mixpower_version
#> 1 fixed 2026-02-10 01:29:06 EST 4.5.2 0.1.0
#> git_sha
#> 1 317d17b82dcbfd920dc6ce9edf45ab597e03dd4f