Set endpoint-specific assumptions
Use relevant variability, non-inferiority margins, alpha, target power, and genuinely paired or unpaired comparison structures.
CASE STUDY 05 / STUDY DESIGN
Testing recruitment assumptions before a study is conducted.
How many observations might a planned fatigue comparison require under different endpoint, pairing, and missingness assumptions?
The study-design work combines analytical non-inferiority sample-size functions with simulation of repeated trips, participant effects, and continuous or binary outcomes.
THE STORY IN PLAIN LANGUAGE
Analytical calculations give a starting recruitment target. Simulation adds repeated observations, participant variability, and missingness to investigate how a proposed design behaves. Together they connect statistical theory to practical planning choices.
The stack follows the analytical task: prepare the data, fit or apply the method, check the result, and communicate the output.
See how the libraries connect to the wider portfolio →THE PROJECT, STEP BY STEP
Use relevant variability, non-inferiority margins, alpha, target power, and genuinely paired or unpaired comparison structures.
Generate repeated observations with participant effects and configurable missingness, then fit linear or logistic mixed models across runs.
Summarize detection frequency under stated assumptions and account for failed fits or changed cohort assumptions.
THE TECHNICAL CASE
Study planning asks how a proposed analysis behaves before the final data exist. Analytical sample-size calculations and simulation complement one another when the design includes pairing, repeated observations, or incomplete follow-up.
The analytical notebooks call TrialSize::TwoSampleMean.NIS and OneSampleMean.NIS with endpoint-specific margins, variability, alpha, and beta. A paired analysis requires meaningful pairing; row order is not a pairing mechanism.
Simulation functions generate participant covariates, random participant effects, repeated observations, sleep predictors, and timepoint effects. Continuous and binary variants require different outcome models.
The repeated-measures code fits linear mixed models and logistic mixed models using lme4. Seeded generation and tryCatch handling support reproducible execution and visibility into fitting failures.
Varying sample size, missingness, and participant effects reveals sensitivity to the assumptions. Several analytical power workflows configure 10,000 replicates; the separate mixed-model simulations include 200- and 300-run settings. These workloads should not be conflated.
Estimated power = successful rejections / attempted simulation replicates
The denominator and treatment of failed fits must be reported. Monte Carlo uncertainty is approximately √[p(1 − p) / B] when B independent replicates are evaluated consistently.
EXPLORE THE METHOD
This calculator shows Monte Carlo standard error for an assumed power estimate. It does not calculate a recruitment target or reproduce the study’s power analysis.
QUALITY OF THE EVIDENCE
Confirm that the data generator and analysis model represent the intended pairing, repeated measurements, endpoint, and missingness mechanism.
Track non-convergence, singular fits, or errors separately. Excluding difficult fits without disclosure can bias estimated power.
Report simulation uncertainty and increase replicates when uncertainty could change a recruitment decision.
A target power in code is a planning assumption, not evidence that a completed study achieved that power.
FOR THE TECHNICAL CONVERSATION
Interview discussion can explore intraclass correlation, effective sample size, missing-not-at-random scenarios, and why a robust design may be preferable to a nominally smaller recruitment target.
WHAT IT DEMONSTRATES
The work compares planned designs before data collection, including power checks configured with 10,000 replicates in several scripts.