CASE STUDY 05 / STUDY DESIGN

Study power and repeated-measures simulation

Testing recruitment assumptions before a study is conducted.

RTrialSizedplyrtidyrpurrrreadxlggplot2knitrR Markdownlme4tibble
10,000-REPLICATE CHECKS
Illustrative visual; no research data shown
THE QUESTION

How many observations might a planned fatigue comparison require under different endpoint, pairing, and missingness assumptions?

THE SETTING

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

Study planning is an experiment on the assumptions.

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.

Technology behind this workflow 11 tools & formats

The stack follows the analytical task: prepare the data, fit or apply the method, check the result, and communicate the output.

RTrialSizedplyrtidyrpurrrreadxlggplot2knitrR Markdownlme4tibble
See how the libraries connect to the wider portfolio →

THE PROJECT, STEP BY STEP

See how the question became a reviewable result.

05 / STUDY DESIGNVISUAL WALKTHROUGH
STEP 01 / 03Set endpoint-specific assumptions
Design assumptionsSimulate + fitPower + uncertainty
10,000-replicate checks
STEP 02 / 03Simulate the planned design
Design assumptionsSimulate + fitPower + uncertainty
10,000-replicate checks
STEP 03 / 03Read failures as evidence
Design assumptionsSimulate + fitPower + uncertainty
10,000-replicate checks
Illustrative process diagram
01

Set endpoint-specific assumptions

Use relevant variability, non-inferiority margins, alpha, target power, and genuinely paired or unpaired comparison structures.

02

Simulate the planned design

Generate repeated observations with participant effects and configurable missingness, then fit linear or logistic mixed models across runs.

03

Read failures as evidence

Summarize detection frequency under stated assumptions and account for failed fits or changed cohort assumptions.

THE TECHNICAL CASE

Decisions behind the analysis.

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.

Unit of analysis
A planned participant and their repeated trips/timepoints; simulated datasets reproduce the proposed structure.
Inputs
Endpoint variability, effect or non-inferiority margin, alpha, target power, participant effects, and missingness assumptions.
Deliverables
Sample-size calculations and simulation summaries that compare plausible designs under stated assumptions.
01

Match the method to the estimand

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.

02

Generate the repeated structure

Simulation functions generate participant covariates, random participant effects, repeated observations, sleep predictors, and timepoint effects. Continuous and binary variants require different outcome models.

03

Fit the planned analysis

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.

04

Compare scenarios rather than one number

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.

METHOD IN FOCUS

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

Explore precision in a simulated power estimate

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

Checks that change the conclusion.

  • Design fidelity

    Confirm that the data generator and analysis model represent the intended pairing, repeated measurements, endpoint, and missingness mechanism.

  • Fit failures

    Track non-convergence, singular fits, or errors separately. Excluding difficult fits without disclosure can bias estimated power.

  • Monte Carlo error

    Report simulation uncertainty and increase replicates when uncertainty could change a recruitment decision.

  • Interpretation

    A target power in code is a planning assumption, not evidence that a completed study achieved that power.

FOR THE TECHNICAL CONVERSATION

Where I would take the discussion next.

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

From method to meaning.

The work compares planned designs before data collection, including power checks configured with 10,000 replicates in several scripts.

Want to discuss the methods?

Email Raee