
Calc Sample Size
- 46 installs
- 236 repo stars
- Updated August 3, 2026
- aperivue/medsci-skills
Calc-Sample-Size is a skill that guides test selection and generates reproducible R/Python sample-size and power calculations with IRB-ready justification text.
About
Calc-Sample-Size walks a medical researcher through test selection with a decision tree, then generates reproducible R and Python code for sample-size and power calculations. It supports diagnostic accuracy, agreement, proportions, continuous outcomes, survival, ANOVA, logistic regression, and non-inferiority/equivalence designs. It also interprets effect sizes clinically and produces IRB-ready justification text for the study protocol.
- Decision-tree guided sample size and power calculation for medical studies
- Generates reproducible R (primary) and Python code plus IRB-ready justification text
- Supports diagnostic accuracy, agreement, proportions, survival, ANOVA, and non-inferiority designs
Calc Sample Size by the numbers
- 46 all-time installs (skills.sh)
- Ranked #956 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
calc-sample-size capabilities & compatibility
- Capabilities
- sample size calculation · power analysis · study design
- Use cases
- data analysis · research
What calc-sample-size says it does
Interactive sample size calculator for medical research. Decision-tree guided test selection, reproducible R/Python code, effect size interpretation, and IRB-ready justification text.
Guide the user through test selection using the decision tree, generate reproducible code in R (primary) and Python (alternative), interpret effect sizes clinically, and produce IRB-ready justificatio
npx skills add https://github.com/aperivue/medsci-skills --skill calc-sample-sizeAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 46 |
|---|---|
| repo stars | ★ 236 |
| Last updated | August 3, 2026 |
| Repository | aperivue/medsci-skills ↗ |
What it does
Guide test selection and generate reproducible sample-size and power calculations with IRB-ready justification for a medical study.
Who is it for?
Calculating sample size and power with reproducible code and justification for a medical study
When should I use this skill?
when a researcher asks how many patients or subjects are needed, or for a power analysis
What you get
A reproducible sample-size calculation plus IRB-ready justification prose
- reproducible R/Python sample-size code
- IRB-ready justification text
- effect-size interpretation
By the numbers
- decision tree across 11 supported tests
- R template covers 7 original tests
Files
Calc-Sample-Size Skill
You are assisting a medical researcher with sample size and power calculations. Guide the user through test selection using the decision tree, generate reproducible code in R (primary) and Python (alternative), interpret effect sizes clinically, and produce IRB-ready justification text.
Reference Files
- Formulas:
${CLAUDE_SKILL_DIR}/references/formulas.md-- mathematical formulas, R/Python functions, effect size conventions - Observational cohort precision branch:
${CLAUDE_SKILL_DIR}/references/observational_cohort.md - Justification prose exemplars:
${CLAUDE_SKILL_DIR}/references/justification_examples.md-- reviewer-safe IRB/Methods justification paragraphs per design (proportions, means, DTA precision, survival/log-rank, ICC agreement, non-inferiority), each stating the five required elements; load when producing the justification text - Existing R template: See
analyze-statsskill atreferences/templates/sample_size.Rfor the 7 original tests
Read formulas.md before generating calculation code. For retrospective observational cohorts with a fixed extract, also read references/observational_cohort.md and report event budget / confidence-interval precision instead of forcing a prospective recruitment-style power calculation.
Cross-Skill References
- design-study calls calc-sample-size when a sample size justification is needed during study design.
- calc-sample-size output feeds into write-protocol and write-paper (Methods section).
- Detailed formulas and references are in
${CLAUDE_SKILL_DIR}/references/formulas.md.
---
Decision Tree
When the user requests a sample size calculation, walk them through this tree interactively. Ask one question at a time. Do not assume answers.
What is your primary outcome?
|
+-- Binary (yes/no, positive/negative)
| |
| +-- Paired data (same subjects, two methods)?
| | +-- YES --> [5] McNemar test
| | +-- NO --> How many groups?
| | +-- 2 groups, superiority --> [4] Two-proportion comparison (chi-square)
| | +-- 2 groups, non-inferiority --> [10] Non-inferiority / equivalence
| | +-- Multivariable model --> [9] Logistic regression
| |
+-- Continuous (measurement, score)
| |
| +-- How many groups?
| +-- 2 groups --> [6] Independent t-test
| +-- 3+ groups --> [8] One-way ANOVA
|
+-- Time-to-event (survival, recurrence)
| |
| +-- Two groups, unadjusted --> [7] Log-rank test
| +-- Multivariable / adjusted HR --> [7] Log-rank (Schoenfeld) + [11] Cox EPV
|
+-- Agreement (inter-rater, reproducibility)
| |
| +-- Continuous measurements --> [2] ICC
| +-- Categorical ratings --> [3] Kappa
|
+-- Diagnostic accuracy (Se, Sp, AUC precision)
|
+--> [1] Diagnostic accuracy (precision-based)---
Supported Tests
Test 1: Diagnostic Accuracy (Sensitivity/Specificity Precision)
When to use: Estimating required sample size for desired precision of sensitivity or specificity in a diagnostic accuracy study.
Required parameters (ask the user):
| Parameter | Description | Default |
|---|---|---|
sensitivity_expected | Expected sensitivity | 0.85 |
ci_half_width | Desired half-width of 95% CI | 0.05 |
prevalence | Disease prevalence in study population | 0.30 |
alpha | Significance level | 0.05 |
attrition_rate | Expected dropout/exclusion rate | 0.15 |
Effect size interpretation: The CI half-width determines precision. A half-width of 0.05 means the 95% CI for sensitivity will be within +/-5 percentage points. Narrower CIs require larger samples.
---
Test 2: ICC Agreement (Bonett 2002)
When to use: Inter-rater or intra-rater agreement for continuous measurements (e.g., tumor size, angle measurement).
Required parameters:
| Parameter | Description | Default |
|---|---|---|
icc_expected | Expected ICC value | 0.75 |
icc_null | Null hypothesis ICC (lower bound) | 0.50 |
n_raters | Number of raters | 2 |
alpha | Significance level | 0.05 |
power | Desired power | 0.80 |
attrition_rate | Expected dropout rate | 0.10 |
Effect size interpretation: ICC < 0.50 = poor, 0.50-0.75 = moderate, 0.75-0.90 = good, > 0.90 = excellent (Koo & Li, 2016).
---
Test 3: Kappa Agreement (Donner & Eliasziw 1992)
When to use: Inter-rater agreement for categorical ratings (e.g., BI-RADS category, lesion present/absent).
Required parameters:
| Parameter | Description | Default |
|---|---|---|
kappa_expected | Expected kappa value | 0.70 |
kappa_null | Null hypothesis kappa | 0.40 |
po_expected | Expected proportion of agreement | 0.75 |
alpha | Significance level | 0.05 |
power | Desired power | 0.80 |
attrition_rate | Expected dropout rate | 0.10 |
Effect size interpretation: Kappa < 0.20 = slight, 0.21-0.40 = fair, 0.41-0.60 = moderate, 0.61-0.80 = substantial, 0.81-1.00 = almost perfect (Landis & Koch, 1977).
---
Test 4: Two-Proportion Comparison (Chi-Square)
When to use: Comparing proportions between two independent groups (e.g., AI detection rate vs. conventional detection rate).
Required parameters:
| Parameter | Description | Default |
|---|---|---|
p1 | Proportion in group 1 | -- |
p2 | Proportion in group 2 | -- |
alpha | Significance level | 0.05 |
power | Desired power | 0.80 |
attrition_rate | Expected dropout rate | 0.15 |
Effect size interpretation: Cohen's h = 2 arcsin(sqrt(p1)) - 2 arcsin(sqrt(p2)). Small = 0.20, medium = 0.50, large = 0.80.
---
Test 5: McNemar Test (Paired Proportions)
When to use: Paired binary outcomes (e.g., two readers reading same cases, before/after on same patients).
Required parameters:
| Parameter | Description | Default |
|---|---|---|
p01 | P(Method A negative, Method B positive) | -- |
p10 | P(Method A positive, Method B negative) | -- |
alpha | Significance level | 0.05 |
power | Desired power | 0.80 |
attrition_rate | Expected dropout rate | 0.10 |
Effect size interpretation: The ratio p10/p01 (discordant ratio) drives the required sample size. Larger asymmetry in discordant pairs means fewer subjects needed. Only discordant pairs contribute information.
---
Test 6: Independent t-Test
When to use: Comparing means between two independent groups (e.g., lesion size in malignant vs. benign).
Required parameters:
| Parameter | Description | Default |
|---|---|---|
mean_diff | Expected mean difference | -- |
pooled_sd | Pooled standard deviation (from literature/pilot) | -- |
alpha | Significance level | 0.05 |
power | Desired power | 0.80 |
attrition_rate | Expected dropout rate | 0.15 |
Effect size interpretation: Cohen's d = mean_diff / pooled_sd. Small = 0.20, medium = 0.50, large = 0.80. In clinical terms, d = 0.50 means the groups differ by half a standard deviation.
---
Test 7: Survival / Log-Rank Test (Schoenfeld 1981)
When to use: Comparing survival or time-to-event between two groups (e.g., treatment vs. control, RFA vs. surgery).
Required parameters:
| Parameter | Description | Default |
|---|---|---|
hr | Expected hazard ratio | -- |
median_ctrl | Median survival in control arm (months) | -- |
accrual_time | Accrual period (months) | 12 |
follow_up | Follow-up after accrual (months) | 24 |
drop_rate | Annual dropout rate | 0.05 |
alpha | Significance level | 0.05 |
power | Desired power | 0.80 |
Effect size interpretation: HR < 1 favors treatment. HR = 0.50 means treatment halves the hazard (strong effect). HR = 0.80 is a modest 20% reduction. The Schoenfeld formula calculates required number of events, then inflates for expected event probability and dropout.
---
Test 8: One-Way ANOVA (NEW)
When to use: Comparing means across 3 or more independent groups (e.g., comparing AI model performance across 3 architectures, comparing measurement accuracy across multiple readers).
Required parameters:
| Parameter | Description | Default |
|---|---|---|
k | Number of groups | -- |
f | Cohen's f effect size | -- |
alpha | Significance level | 0.05 |
power | Desired power | 0.80 |
attrition_rate | Expected dropout rate | 0.15 |
Help user estimate Cohen's f:
- If the user knows group means and pooled SD: f = sigma_means / pooled_SD
- If the user knows eta-squared: f = sqrt(eta_sq / (1 - eta_sq))
- Benchmarks: small = 0.10, medium = 0.25, large = 0.40
R function: pwr::pwr.anova.test(k, f, sig.level, power) Python equivalent: statsmodels.stats.power.FTestAnovaPower().solve_power(effect_size, nobs, alpha, power, k_groups)
Effect size interpretation: Cohen's f = 0.25 (medium) means the group means span about half a pooled SD. In clinical terms, this is typically a meaningful difference across treatment arms or measurement methods.
---
Test 9: Logistic Regression (NEW)
When to use: Multivariable binary outcome models (e.g., predicting malignancy from multiple imaging features). Two approaches are provided.
Required parameters:
| Parameter | Description | Default |
|---|---|---|
n_predictors | Number of predictor variables | -- |
event_rate | Expected event rate (proportion with outcome) | -- |
or_interest | Odds ratio of interest (for Hsieh formula) | -- |
r2_other | R-squared of covariate with other predictors | 0.0 |
alpha | Significance level | 0.05 |
power | Desired power | 0.80 |
attrition_rate | Expected dropout rate | 0.10 |
Approach A: Peduzzi Rule of Thumb (EPV >= 10)
- N_events = 10 * n_predictors
- N_total = N_events / event_rate
- Simple, widely cited, conservative. Use as a minimum baseline.
Approach B: Hsieh (1989) Formula
- Uses the OR of interest for the primary predictor to calculate a more precise sample size.
- Accounts for correlation with other predictors via R-squared adjustment.
Always report both approaches and recommend the larger N.
Effect size interpretation: OR = 1.5 is a small-to-moderate effect; OR = 2.0 is moderate; OR = 3.0+ is large. The Peduzzi rule ensures model stability; the Hsieh formula targets power for the primary predictor.
---
Test 10: Non-Inferiority / Equivalence (NEW)
When to use: Demonstrating that a new method is not worse than the standard by more than a pre-specified margin (non-inferiority) or that two methods are equivalent within a margin (equivalence / TOST).
Required parameters:
| Parameter | Description | Default |
|---|---|---|
design | "non-inferiority" or "equivalence" | "non-inferiority" |
outcome_type | "proportion" or "continuous" | -- |
p_reference | Reference group proportion (if proportion) | -- |
margin | Non-inferiority or equivalence margin (delta) | -- |
sd | Standard deviation (if continuous) | -- |
alpha | One-sided alpha for NI; two one-sided for equivalence | 0.025 (NI) / 0.05 (equiv) |
power | Desired power | 0.80 |
attrition_rate | Expected dropout rate | 0.15 |
Key guidance for margin selection:
- The margin must be clinically justified and smaller than the effect of the reference treatment vs. placebo.
- Common approach: margin = 50% of the established treatment effect (preservation of effect).
- For proportions: absolute difference margin (e.g., delta = 0.10 means new method can be at most 10 percentage points worse).
- For continuous: margin in the same unit as the outcome.
Non-inferiority (one-sided test):
- H0: new - reference <= -margin (new is inferior)
- H1: new - reference > -margin (new is non-inferior)
- Alpha is one-sided (typically 0.025).
Equivalence (TOST):
- H0: |new - reference| >= margin
- H1: |new - reference| < margin
- Two one-sided tests, each at alpha (typically 0.05 overall).
Effect size interpretation: The margin defines the largest clinically acceptable difference. A smaller margin requires a larger sample. Always justify the margin based on clinical reasoning and prior literature.
---
Test 11: Cox Regression EPV (Events Per Variable)
When to use: Multivariable Cox proportional hazards models — ensuring enough events for stable model estimates. Same EPV logic as logistic regression (Test 9), applied to time-to-event outcomes.
Required parameters:
| Parameter | Description | Default |
|---|---|---|
n_predictors | Number of predictor variables in Cox model | -- |
event_rate | Expected proportion of subjects experiencing the event | -- |
epv | Events per variable target | 10 |
attrition_rate | Expected dropout rate | 0.10 |
Formula:
N_events = EPV × n_predictors
N_total = N_events / event_rate
N_adj = N_total / (1 - attrition_rate)EPV guidelines:
- EPV >= 10: minimum for stable estimates (Peduzzi et al., 1995)
- EPV >= 20: recommended for reliable CI coverage and type I error control
- EPV < 5: model likely unstable — reduce predictors or use penalized methods
Effect size interpretation: The EPV rule ensures model stability, not power for a specific HR. If the user also needs power for detecting a specific HR, combine with Test 7 (log-rank/Schoenfeld) and report the larger N.
Always report both approaches (EPV minimum + Schoenfeld power, if HR is available) and recommend the larger N.
---
Scope Limitations
Supported
The 11 tests listed above cover the vast majority of sample size calculations needed in medical imaging research, diagnostic accuracy studies, and clinical trials.
NOT Supported
The following designs require specialized software or biostatistician consultation:
- Adaptive trials (group-sequential, sample size re-estimation)
- Cluster-randomized trials (design effect, ICC-based inflation)
- Bayesian sample size determination
- Crossover designs
- Multi-endpoint correction (mention Bonferroni adjustment if asked, but do not compute corrected sample sizes)
If the user requests any of these, respond:
"This design requires specialized tools beyond this skill's scope. Consider using G*Power software (free, https://www.psychologie.hhu.de/gpower), PASS software, or consulting a biostatistician for [specific design]."
---
Workflow
Phase 1: Understand the Study
1. Ask the user to describe their study briefly (design, primary outcome, groups). 2. Walk through the decision tree to identify the appropriate test. 3. Confirm the selected test with the user before proceeding.
Phase 2: Collect Parameters
1. Present the parameter table for the selected test. 2. For each parameter without a user-provided value, explain what it means and offer the default. 3. Help the user estimate effect sizes from:
- Prior literature (ask for references)
- Pilot data
- Cohen's conventions (as a last resort, with a note that convention-based estimates are less precise)
Phase 2b: Retrospective Study — Experience-Based Sample Size Justification
For retrospective studies, formal power analysis is often impractical because the dataset already exists. In these cases, an experience-based justification is acceptable for IRB and many journals. Offer this path when the user describes a retrospective design.
Two approaches:
Approach A: Institution Volume-Based
Estimate N from the number of examinations performed at the institution during the study period.
Total exams in period × prevalence of target condition × (1 - exclusion rate) = Expected N- Ask the user for: annual exam volume for the modality, study period length, estimated
prevalence, and expected exclusion rate
- This gives a realistic upper bound for N
IRB justification template:
Based on approximately [X] [modality] examinations performed annually at [institution],
and an estimated prevalence of [condition] of [Y]%, we anticipate identifying approximately
[N] eligible patients over the [Z]-year study period. After accounting for an estimated
[W]% exclusion rate (due to [reasons]), we expect a final sample of approximately [N_adj]
patients for analysis.
Approach B: Prior Study-Based
Use sample sizes from published studies with similar designs as justification.
- Search for 3-5 comparable studies and report their sample sizes
- The user's N should be in the same range or larger
- Cite the specific studies in the IRB justification
IRB justification template:
Previous studies evaluating [similar topic] with [similar design] enrolled [N1] (Author1
et al., Year), [N2] (Author2 et al., Year), and [N3] (Author3 et al., Year) patients.
Our anticipated sample of [N] patients is [comparable to / larger than] these prior studies.
When to Use Formal Calculation Instead
Even for retrospective studies, a formal sample size calculation is preferred when:
- The study is prospective or will prospectively enroll a subset
- The primary analysis involves hypothesis testing (not just estimation)
- The journal explicitly requires power analysis (check Instructions for Authors)
- The IRB requires it for approval
In these cases, proceed to Phase 3 with the appropriate test from the decision tree.
---
Phase 3: Calculate and Report
1. Read ${CLAUDE_SKILL_DIR}/references/formulas.md for the exact formula. 2. Generate the R code (primary) and Python code (alternative). 3. Run the R code via Bash to produce the actual result. 4. Present results in the output format below.
Phase 4: Sensitivity Analysis (Optional)
If the user is uncertain about parameters, offer a sensitivity table showing N across a range of plausible values (e.g., varying effect size or power from 0.80 to 0.90).
---
Output Format
Always structure the final output as follows:
## Sample Size Calculation Report
### Study Design
[1-2 sentence summary of the design and test selected]
### Parameters
| Parameter | Value | Source |
|-----------|-------|--------|
| ... | ... | user / literature / convention |
### Result
- **Required sample size**: N = [value]
- **With [X]% attrition adjustment**: N_adj = [value]
### R Code (Reproducible)[complete, self-contained R script]
Dependencies: [list packages]
Run: Rscript sample_size_calc.R
### Python Code (Alternative)[complete, self-contained Python script]
Dependencies: [list packages]
Run: python sample_size_calc.py
### IRB Justification Text
> A sample of [N] participants is required to detect [effect description] with [power]% power
> at a [one/two]-sided significance level of [alpha], assuming [key assumptions].
> Accounting for an estimated [X]% attrition rate, we plan to enroll [N_adj] participants.
> This calculation is based on [formula/method reference].
### Effect Size Interpretation
[Cohen's benchmark classification + clinical meaning in the context of this study]---
IRB Justification Text Guidelines
The IRB text must: 1. State the required N clearly. 2. Name the statistical test and its formula source. 3. Specify all assumed parameters (effect size, alpha, power). 4. State the attrition adjustment and final enrollment target. 5. Cite the methodological reference (e.g., "Schoenfeld, 1981" for survival). 6. Use formal, third-person language suitable for an ethics board.
---
Communication Rules
- Communicate with the user in their preferred language.
- Use English for all statistical terminology, effect size names, and test names.
- Be explicit about assumptions and their impact on the result.
- When the user provides vague effect size estimates, flag the uncertainty and suggest a sensitivity analysis.
- Never fabricate references. Cite only verified methodological sources from
formulas.md.
Anti-Hallucination
- Never fabricate file paths, URLs, DOIs, or package names. Verify existence before recommending.
- Never invent journal metadata, impact factors, or submission policies without verification at the journal's website.
- If a tool, package, or resource does not exist or you are unsure, say so explicitly rather than guessing.
Sample Size Formulas Reference
Mathematical formulas, R/Python implementations, and effect size conventions for all 10 supported tests.
---
Test 1: Diagnostic Accuracy (Sensitivity/Specificity Precision)
Formula
For estimating a single proportion p with desired 95% CI half-width w:
n_positive = ceil( (z_{alpha/2} / w)^2 * p * (1 - p) )
n_total = ceil( n_positive / prevalence )Where:
z_{alpha/2}= 1.96 for alpha = 0.05p= expected sensitivity (or specificity)w= desired CI half-widthprevalence= disease prevalence in the study population
R Implementation
z <- qnorm(1 - alpha / 2)
n_pos <- ceiling((z / ci_half_width)^2 * se_expected * (1 - se_expected))
n_total <- ceiling(n_pos / prevalence)
n_adj <- ceiling(n_total / (1 - attrition_rate))Python Implementation
from scipy.stats import norm
import math
z = norm.ppf(1 - alpha / 2)
n_pos = math.ceil((z / ci_half_width)**2 * se_expected * (1 - se_expected))
n_total = math.ceil(n_pos / prevalence)
n_adj = math.ceil(n_total / (1 - attrition_rate))R Package
Base R (no additional packages needed).
Key Reference
Buderer NMF. Statistical methodology: I. Incorporating the prevalence of disease into the sample size calculation for sensitivity and specificity. Acad Emerg Med. 1996;3(9):895-900.
---
Test 2: ICC Agreement (Bonett 2002)
Formula
Fisher z-transformation approach:
z_1 = 0.5 * ln((1 + rho_1) / (1 - rho_1)) # expected ICC
z_0 = 0.5 * ln((1 + rho_0) / (1 - rho_0)) # null ICC
n = ceil( ((z_{alpha} + z_{beta}) / (z_1 - z_0))^2 + 3 )Where:
rho_1= expected ICCrho_0= null hypothesis ICCz_{alpha}= qnorm(1 - alpha) for one-sided, qnorm(1 - alpha/2) for two-sidedz_{beta}= qnorm(power)
R Implementation
# Option A: MKpower package (preferred)
library(MKpower)
result <- sampleSize.ICC(rho0 = icc_null, rho1 = icc_expected,
k = n_raters, alpha = alpha, power = power)
n <- result$n
# Option B: Manual Fisher z (if MKpower unavailable)
z_exp <- 0.5 * log((1 + icc_expected) / (1 - icc_expected))
z_null <- 0.5 * log((1 + icc_null) / (1 - icc_null))
n <- ceiling(((qnorm(1 - alpha) + qnorm(power)) / (z_exp - z_null))^2 + 3)Python Implementation
from scipy.stats import norm
import math
import numpy as np
z_exp = 0.5 * np.log((1 + icc_expected) / (1 - icc_expected))
z_null = 0.5 * np.log((1 + icc_null) / (1 - icc_null))
z_alpha = norm.ppf(1 - alpha)
z_beta = norm.ppf(power)
n = math.ceil(((z_alpha + z_beta) / (z_exp - z_null))**2 + 3)R Package
MKpower (preferred), or base R for manual calculation.
Key Reference
Bonett DG. Sample size requirements for estimating intraclass correlations with desired precision. Stat Med. 2002;21(9):1331-1335.
---
Test 3: Kappa Agreement (Donner & Eliasziw 1992)
Formula
Z-test approximation for testing kappa_1 vs kappa_0:
n = ceil( ((z_{alpha/2} + z_{beta})^2 * kappa_1 * (1 - kappa_1)) / (kappa_1 - kappa_0)^2 + 1 )Where:
kappa_1= expected kappakappa_0= null hypothesis kappape= expected chance agreement = (po - kappa) / (1 - kappa)
R Implementation
n_kappa <- ceiling(
((qnorm(1 - alpha / 2) + qnorm(power))^2 *
kappa_expected * (1 - kappa_expected)) /
(kappa_expected - kappa_null)^2 + 1
)Python Implementation
from scipy.stats import norm
import math
z_a = norm.ppf(1 - alpha / 2)
z_b = norm.ppf(power)
n = math.ceil(((z_a + z_b)**2 * kappa_exp * (1 - kappa_exp)) /
(kappa_exp - kappa_null)**2 + 1)R Package
Base R. Also available via kappaSize package.
Key Reference
Donner A, Eliasziw M. A goodness-of-fit approach to inference procedures for the kappa statistic: confidence interval construction, significance-testing and sample size estimation. Stat Med. 1992;11(11):1511-1519.
---
Test 4: Two-Proportion Comparison (Chi-Square)
Formula
Based on Cohen's h effect size (arcsine transformation):
h = 2 * arcsin(sqrt(p1)) - 2 * arcsin(sqrt(p2))
n_per_group = ceil( ((z_{alpha/2} + z_{beta}) / h)^2 )R Implementation
library(pwr)
h <- ES.h(p1, p2)
result <- pwr.2p.test(h = h, sig.level = alpha, power = power)
n_per_group <- ceiling(result$n)
n_total <- n_per_group * 2Python Implementation
from statsmodels.stats.power import NormalIndPower
import numpy as np
import math
h = 2 * np.arcsin(np.sqrt(p1)) - 2 * np.arcsin(np.sqrt(p2))
analysis = NormalIndPower()
n_per_group = math.ceil(analysis.solve_power(effect_size=h, alpha=alpha, power=power,
ratio=1, alternative='two-sided'))
n_total = n_per_group * 2R Package
pwr
Key Reference
Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Lawrence Erlbaum Associates; 1988.
---
Test 5: McNemar Test (Paired Proportions)
Formula
n = ceil(
(z_{alpha/2} * sqrt(p01 + p10) + z_{beta} * sqrt(p01 + p10 - (p10 - p01)^2))^2
/ (p10 - p01)^2
)Where:
p01= P(Method A negative, Method B positive)p10= P(Method A positive, Method B negative)
R Implementation
n_mc <- ceiling(
(qnorm(1 - alpha / 2) * sqrt(p01 + p10) +
qnorm(power) * sqrt(p01 + p10 - (p10 - p01)^2))^2 /
(p10 - p01)^2
)Python Implementation
from scipy.stats import norm
import math
z_a = norm.ppf(1 - alpha / 2)
z_b = norm.ppf(power)
disc_sum = p01 + p10
disc_diff = p10 - p01
n = math.ceil((z_a * math.sqrt(disc_sum) +
z_b * math.sqrt(disc_sum - disc_diff**2))**2 / disc_diff**2)R Package
Base R. Also available via exact2x2 package.
Key Reference
Connor RJ. Sample size for testing differences in proportions for the paired-sample design. Biometrics. 1987;43(1):207-211.
---
Test 6: Independent t-Test
Formula
d = mean_diff / pooled_sd (Cohen's d)
n_per_group = ceil( 2 * ((z_{alpha/2} + z_{beta}) / d)^2 )R Implementation
library(pwr)
d <- mean_diff / pooled_sd
result <- pwr.t.test(d = d, sig.level = alpha, power = power, type = "two.sample")
n_per_group <- ceiling(result$n)
n_total <- n_per_group * 2Python Implementation
from statsmodels.stats.power import TTestIndPower
import math
d = mean_diff / pooled_sd
analysis = TTestIndPower()
n_per_group = math.ceil(analysis.solve_power(effect_size=d, alpha=alpha, power=power,
ratio=1, alternative='two-sided'))
n_total = n_per_group * 2R Package
pwr
Key Reference
Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Lawrence Erlbaum Associates; 1988.
---
Test 7: Survival / Log-Rank Test (Schoenfeld 1981)
Formula
Step 1 -- Required number of events:
d = ceil( ((z_{alpha/2} + z_{beta}) / ln(HR))^2 )Step 2 -- Total sample size:
lambda_ctrl = ln(2) / median_ctrl
lambda_trt = lambda_ctrl * HR
p_event_ctrl = 1 - exp(-lambda_ctrl * follow_up)
p_event_trt = 1 - exp(-lambda_trt * follow_up)
avg_p_event = (p_event_ctrl + p_event_trt) / 2
n_total = ceil( d / avg_p_event )R Implementation
n_events <- ceiling((qnorm(1 - alpha / 2) + qnorm(power))^2 / (log(hr))^2)
lambda_ctrl <- log(2) / median_ctrl
lambda_trt <- lambda_ctrl * hr
p_event_ctrl <- 1 - exp(-lambda_ctrl * follow_up)
p_event_trt <- 1 - exp(-lambda_trt * follow_up)
avg_p_event <- (p_event_ctrl + p_event_trt) / 2
n_total <- ceiling(n_events / avg_p_event)
n_adj <- ceiling(n_total / (1 - drop_rate))Python Implementation
from scipy.stats import norm
import math
import numpy as np
z_a = norm.ppf(1 - alpha / 2)
z_b = norm.ppf(power)
n_events = math.ceil((z_a + z_b)**2 / np.log(hr)**2)
lambda_ctrl = np.log(2) / median_ctrl
lambda_trt = lambda_ctrl * hr
p_event_ctrl = 1 - np.exp(-lambda_ctrl * follow_up)
p_event_trt = 1 - np.exp(-lambda_trt * follow_up)
avg_p_event = (p_event_ctrl + p_event_trt) / 2
n_total = math.ceil(n_events / avg_p_event)
n_adj = math.ceil(n_total / (1 - drop_rate))R Package
Base R. Also available via gsDesign, survival packages.
Key Reference
Schoenfeld DA. The asymptotic properties of nonparametric tests for comparing survival distributions. Biometrika. 1981;68(1):316-319.
---
Test 8: One-Way ANOVA
Formula
Using Cohen's f effect size:
f = sigma_between / sigma_withinWhere:
sigma_between= SD of group meanssigma_within= pooled within-group SD
From eta-squared: f = sqrt(eta_sq / (1 - eta_sq))
The sample size per group is obtained via the F-test power formula (implemented in pwr).
R Implementation
library(pwr)
result <- pwr.anova.test(k = k, f = f, sig.level = alpha, power = power)
n_per_group <- ceiling(result$n)
n_total <- n_per_group * k
n_adj <- ceiling(n_total / (1 - attrition_rate))Python Implementation
from statsmodels.stats.power import FTestAnovaPower
import math
analysis = FTestAnovaPower()
n_per_group = math.ceil(analysis.solve_power(effect_size=f, nobs=None, alpha=alpha,
power=power, k_groups=k))
n_total = n_per_group * k
n_adj = math.ceil(n_total / (1 - attrition_rate))R Package
pwr
Key Reference
Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Lawrence Erlbaum Associates; 1988. (Chapter 8: F tests for ANOVA)
---
Test 9: Logistic Regression
Approach A: Peduzzi Rule of Thumb (EPV >= 10)
N_events = 10 * p (where p = number of predictor variables)
N_total = N_events / event_rateThis ensures at least 10 events per predictor variable (EPV), the widely accepted minimum for stable logistic regression estimates.
Approach B: Hsieh (1989) Formula
For detecting a specific odds ratio (OR) for a continuous or binary predictor:
# For a binary predictor (proportion B exposed):
n_unadj = ((z_{alpha/2} + z_{beta})^2) / (B * (1-B) * ln(OR)^2)
# Adjusted for correlation with other predictors:
n_adj = n_unadj / (1 - R^2)Where:
OR= odds ratio of interestB= proportion of subjects exposed (for binary predictor) or use p*(1-p) for the outcomeR^2= multiple correlation of the predictor with other covariates
For a continuous predictor, the formula uses the standard normal density.
R Implementation
# Approach A: Peduzzi
n_events_peduzzi <- 10 * n_predictors
n_total_peduzzi <- ceiling(n_events_peduzzi / event_rate)
# Approach B: Hsieh (binary predictor)
z_a <- qnorm(1 - alpha / 2)
z_b <- qnorm(power)
n_hsieh <- ceiling((z_a + z_b)^2 /
(event_rate * (1 - event_rate) * log(or_interest)^2))
n_hsieh_adj <- ceiling(n_hsieh / (1 - r2_other))
# Report the larger of the two
n_final <- max(n_total_peduzzi, n_hsieh_adj)Python Implementation
from scipy.stats import norm
import math
import numpy as np
# Approach A: Peduzzi
n_events_peduzzi = 10 * n_predictors
n_total_peduzzi = math.ceil(n_events_peduzzi / event_rate)
# Approach B: Hsieh (binary predictor)
z_a = norm.ppf(1 - alpha / 2)
z_b = norm.ppf(power)
n_hsieh = math.ceil((z_a + z_b)**2 /
(event_rate * (1 - event_rate) * np.log(or_interest)**2))
n_hsieh_adj = math.ceil(n_hsieh / (1 - r2_other))
n_final = max(n_total_peduzzi, n_hsieh_adj)R Package
Base R. Also see powerMediation package for Hsieh's formula.
Key References
- Peduzzi P, Concato J, Kemper E, Holford TR, Feinstein AR. A simulation study of the number of events per variable in logistic regression analysis. J Clin Epidemiol. 1996;49(12):1373-1379.
- Hsieh FY. Sample size tables for logistic regression. Stat Med. 1989;8(7):795-802.
---
Test 10: Non-Inferiority / Equivalence
Non-Inferiority (Proportions)
n_per_group = ceil(
((z_{1-alpha} + z_{beta})^2 * (p_ref*(1-p_ref) + p_new*(1-p_new))) /
(margin - |p_new - p_ref|)^2
)When assuming p_new = p_ref (no true difference):
n_per_group = ceil( ((z_{1-alpha} + z_{beta})^2 * 2 * p*(1-p)) / margin^2 )Note: alpha is one-sided (typically 0.025) for non-inferiority.
Non-Inferiority (Continuous)
n_per_group = ceil( ((z_{1-alpha} + z_{beta})^2 * 2 * sd^2) / margin^2 )Equivalence / TOST (Proportions)
n_per_group = ceil(
((z_{1-alpha/2} + z_{beta})^2 * 2 * p*(1-p)) / margin^2
)Note: For TOST, each one-sided test uses alpha (e.g., alpha = 0.05 for overall 5% type I error).
Equivalence / TOST (Continuous)
n_per_group = ceil( ((z_{1-alpha} + z_{beta})^2 * 2 * sd^2) / margin^2 )R Implementation
# Non-inferiority for proportions (assuming no true difference)
z_a <- qnorm(1 - alpha) # one-sided, alpha = 0.025
z_b <- qnorm(power)
p <- p_reference
n_per_group <- ceiling(((z_a + z_b)^2 * 2 * p * (1 - p)) / margin^2)
n_total <- n_per_group * 2
# Non-inferiority for continuous
n_per_group <- ceiling(((z_a + z_b)^2 * 2 * sd^2) / margin^2)
n_total <- n_per_group * 2
# Equivalence / TOST for continuous
n_per_group <- ceiling(((z_a + z_b)^2 * 2 * sd^2) / margin^2)
n_total <- n_per_group * 2
n_adj <- ceiling(n_total / (1 - attrition_rate))Python Implementation
from scipy.stats import norm
import math
# Non-inferiority for proportions (assuming no true difference)
z_a = norm.ppf(1 - alpha) # one-sided, alpha = 0.025
z_b = norm.ppf(power)
p = p_reference
n_per_group = math.ceil(((z_a + z_b)**2 * 2 * p * (1 - p)) / margin**2)
n_total = n_per_group * 2
# Non-inferiority for continuous
n_per_group = math.ceil(((z_a + z_b)**2 * 2 * sd**2) / margin**2)
n_total = n_per_group * 2
# Equivalence / TOST for continuous
# Same formula; the difference is in the hypothesis and alpha interpretation
n_per_group = math.ceil(((z_a + z_b)**2 * 2 * sd**2) / margin**2)
n_total = n_per_group * 2
n_adj = math.ceil(n_total / (1 - attrition_rate))R Package
Base R. Also see TrialSize, PowerTOST packages.
Key References
- Julious SA. Sample sizes for clinical trials with normal data. Stat Med. 2004;23(12):1921-1986.
- Schuirmann DJ. A comparison of the two one-sided tests procedure and the power approach for assessing the equivalence of average bioavailability. J Pharmacokinet Biopharm. 1987;15(6):657-680.
---
Test 11: Cox Regression EPV (Events Per Variable)
Formula
N_events = EPV × k (where k = number of predictor variables)
N_total = ceil( N_events / event_rate )
N_adj = ceil( N_total / (1 - attrition_rate) )Where:
EPV= events per variable (minimum 10, recommended 20)k= number of predictors in the Cox modelevent_rate= proportion of subjects experiencing the event
R Implementation
n_events <- epv * n_predictors
n_total <- ceiling(n_events / event_rate)
n_adj <- ceiling(n_total / (1 - attrition_rate))
cat(sprintf("EPV = %d, Predictors = %d\n", epv, n_predictors))
cat(sprintf("Required events = %d\n", n_events))
cat(sprintf("Total N = %d (event rate = %.0f%%)\n", n_total, event_rate * 100))
cat(sprintf("Adjusted N = %d (attrition = %.0f%%)\n", n_adj, attrition_rate * 100))Python Implementation
import math
n_events = epv * n_predictors
n_total = math.ceil(n_events / event_rate)
n_adj = math.ceil(n_total / (1 - attrition_rate))R Package
Base R (no additional packages needed).
Key References
- Peduzzi P, Concato J, Feinstein AR, Holford TR. Importance of events per independent variable in proportional hazards regression analysis. II. Accuracy and precision of regression estimates. J Clin Epidemiol. 1995;48(12):1503-1510.
- Vittinghoff E, McCulloch CE. Relaxing the rule of ten events per variable in logistic and Cox regression. Am J Epidemiol. 2007;165(6):710-718.
---
Cohen's Effect Size Conventions
| Measure | Small | Medium | Large | Context |
|---|---|---|---|---|
| d (t-test) | 0.20 | 0.50 | 0.80 | Difference in means / pooled SD |
| f (ANOVA) | 0.10 | 0.25 | 0.40 | SD of group means / within-group SD |
| h (proportions) | 0.20 | 0.50 | 0.80 | Arcsine-transformed proportion difference |
| w (chi-square) | 0.10 | 0.30 | 0.50 | Chi-square contingency effect |
| OR (logistic) | 1.5 | 2.0 | 3.0+ | Odds ratio (approximate equivalence) |
| HR (survival) | 0.80 | 0.65 | 0.50 | Hazard ratio (values < 1 favor treatment) |
| ICC | 0.50-0.75 | 0.75-0.90 | > 0.90 | Poor/moderate/good/excellent |
| Kappa | 0.21-0.40 | 0.41-0.60 | 0.61-0.80 | Fair/moderate/substantial |
Important: Cohen's conventions are rules of thumb. Always prefer effect sizes estimated from prior literature or pilot data. When conventions are used, explicitly state this limitation in the IRB justification.
---
Common Attrition Rates by Study Type
| Study Type | Typical Attrition | Recommended Adjustment |
|---|---|---|
| Randomized controlled trial (RCT) | 15-20% | 20% |
| Prospective observational / cohort | 10-15% | 15% |
| Cross-sectional / survey | 5-10% | 10% |
| Retrospective chart review | 3-5% | 5% |
| Diagnostic accuracy (imaging) | 5-10% | 10% |
| Inter-rater agreement study | 5-10% | 10% |
| Survival / long follow-up (> 2 yr) | 15-25% | 20% |
Note: Attrition rates vary widely by disease, population, and follow-up duration. Use study-specific estimates when available.
---
Key References
1. Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Hillsdale, NJ: Lawrence Erlbaum Associates; 1988.
- Foundation for effect size conventions (d, f, h, w) and power analysis methodology.
2. Schoenfeld DA. The asymptotic properties of nonparametric tests for comparing survival distributions. Biometrika. 1981;68(1):316-319.
- Formula for required number of events in log-rank test.
3. Bonett DG. Sample size requirements for estimating intraclass correlations with desired precision. Stat Med. 2002;21(9):1331-1335.
- ICC-based sample size using Fisher z-transformation.
4. Hsieh FY. Sample size tables for logistic regression. Stat Med. 1989;8(7):795-802.
- Power-based sample size for detecting a specific odds ratio.
5. Peduzzi P, Concato J, Kemper E, Holford TR, Feinstein AR. A simulation study of the number of events per variable in logistic regression analysis. J Clin Epidemiol. 1996;49(12):1373-1379.
- EPV >= 10 rule for logistic regression model stability.
6. Donner A, Eliasziw M. A goodness-of-fit approach to inference procedures for the kappa statistic: confidence interval construction, significance-testing and sample size estimation. Stat Med. 1992;11(11):1511-1519.
- Sample size for testing kappa against a null value.
7. Buderer NMF. Statistical methodology: I. Incorporating the prevalence of disease into the sample size calculation for sensitivity and specificity. Acad Emerg Med. 1996;3(9):895-900.
- Prevalence-adjusted sample size for diagnostic accuracy.
8. Julious SA. Sample sizes for clinical trials with normal data. Stat Med. 2004;23(12):1921-1986.
- Comprehensive non-inferiority and equivalence sample size formulas.
9. Schuirmann DJ. A comparison of the two one-sided tests procedure and the power approach for assessing the equivalence of average bioavailability. J Pharmacokinet Biopharm. 1987;15(6):657-680.
- TOST (two one-sided tests) procedure for equivalence testing.
10. Koo TK, Li MY. A guideline of selecting and reporting intraclass correlation coefficients for reliability research. J Chiropr Med. 2016;15(2):155-163.
- ICC interpretation benchmarks.
11. Landis JR, Koch GG. The measurement of observer agreement for categorical data. Biometrics. 1977;33(1):159-174.
- Kappa interpretation benchmarks.
12. Connor RJ. Sample size for testing differences in proportions for the paired-sample design. Biometrics. 1987;43(1):207-211.
- McNemar test sample size formula.
13. Peduzzi P, Concato J, Feinstein AR, Holford TR. Importance of events per independent variable in proportional hazards regression analysis. II. Accuracy and precision of regression estimates. J Clin Epidemiol. 1995;48(12):1503-1510.
- EPV >= 10 rule for Cox regression model stability.
14. Vittinghoff E, McCulloch CE. Relaxing the rule of ten events per variable in logistic and Cox regression. Am J Epidemiol. 2007;165(6):710-718.
- Evidence that EPV 5-10 may be acceptable with careful validation.
Sample-size justification — worked prose exemplars (IRB / Methods)
Reviewer-safe justification paragraphs for the prospective designs this skill computes, complementing formulas.md (the math) and the retrospective/experience-based templates in SKILL.md Phase 2b. Each shows the same five elements a methods reviewer or IRB looks for; fill the [brackets] from the actual calculation — never invent the inputs. These are synthetic teaching models of standard justification structure, not copied text.
The five elements (every justification states all five)
1. The primary outcome and its effect/precision target (with the source of the assumed value — prior study, pilot, or a minimal clinically important difference, cited). 2. α (and one- vs two-sided) and power (or the target CI half-width for a precision aim). 3. The test/method the calculation matches (it must match the planned primary analysis). 4. The resulting n, including any inflation for attrition/clustering/multiplicity. 5. The software/approach used (named, so it is reproducible).
Exemplars by design
Two proportions (superiority). "Assuming an event rate of [p1] in the control arm (from [cited source]) and a clinically meaningful absolute reduction to [p2], a two-sided α = 0.05 and 80% power require [n/arm] per arm (two-proportion test). Allowing for [d]% attrition, we will enrol [N]."
Two means (superiority). "To detect a between-group difference of [Δ] in [outcome] (SD [s], from [source]; standardised effect [d]) with two-sided α = 0.05 and 90% power requires [n/arm] per arm (two-sample t-test)."
Diagnostic accuracy (precision aim). "To estimate sensitivity with a 95% CI half-width of [w], assuming sensitivity [Se] and disease prevalence [π], [N_total] participants ([N_diseased] with the target condition) are needed; the specificity target is checked separately from the non-diseased count [N_nondiseased] and is satisfied at this n. The aim is precision, not power — no comparison hypothesis is tested." (Cite Hajian-Tilaki / Buderer.)
Survival (log-rank). "To detect a hazard ratio of [HR] (median [m1] vs [m2]) with two-sided α = 0.05 and 80% power, [E] events are required (Schoenfeld); with an accrual of [a] over [t] and follow-up [f], this needs [N] participants. The event count, not N, drives power."
Agreement / reliability (ICC). "Assuming a true ICC of [ρ] with [k] raters per subject, [n] subjects give a 95% CI half-width of [w] (a precision aim, Bonett/Walter) — or, framed as assurance, [n] subjects so the 95% CI lower bound exceeds the minimally acceptable [ρ0]. State which of the two aims you used; report the CI target, not power."
Non-inferiority. "With a non-inferiority margin of [m] (justified clinically and by [regulatory/prior] precedent), assuming true equivalence and a control rate [p], one-sided α = 0.025 and 90% power require [n/arm] per arm. The margin and its rationale are pre-specified."
Discipline
- The calculation must match the planned primary analysis (do not power for a t-test and
analyse with a mixed model); state any clustering (design effect) or multiplicity adjustment.
- For a precision aim (DTA, agreement, single-arm), report the CI half-width, not power —
do not invent a comparison hypothesis to manufacture a power statement.
- Never reverse-engineer the effect size from an achievable n (post-hoc justification); the
assumed effect comes from a cited source or an MCID. Post-hoc/observed power is uninformative.
Observational Cohort Sample Size: Precision Branch
Use this reference when a cohort study is extraction-constrained or when the goal is precision rather than formal power.
When To Use
- Retrospective hospital-based cohort with all eligible records included.
- National database cohort where the sample is fixed by release permissions.
- Sparse-event outcome where the real question is whether confidence intervals are narrow enough to support a claim.
Core Checks
1. Primary estimand: risk difference, odds ratio, hazard ratio, incidence rate, or mean difference. 2. Event count: total events and events per modeled parameter. 3. Precision target: acceptable confidence interval half-width or maximum acceptable upper bound. 4. Model complexity: covariate count relative to events. 5. Fragility: subgroup and sensitivity analyses with smaller denominators.
Rule-of-Thumb Gates
| Situation | Minimum check |
|---|---|
| Logistic or Cox model | Events per parameter and shrinkage/penalization consideration |
| Sparse binary outcome | Exact or profile-likelihood confidence intervals |
| Incidence rate | Poisson exact CI around event rate |
| Null association claim | Upper CI bound must exclude clinically meaningful effect |
| Subgroup analysis | Interaction test plus event count per subgroup |
Manuscript Phrase
"The study size was determined by all eligible participants in the released cohort. We therefore evaluated statistical informativeness by the number of outcome events, events per modeled parameter, and the width of the 95% confidence intervals around the primary estimate rather than by a conventional a priori recruitment target."
Minimal R Sketch
events <- 130
parameters <- 8
epv <- events / parameters
rate <- 130 / 250000
poisson.test(130, T = 250000)$conf.intReviewer-Safe Interpretation
- If events are sparse, do not write "no association" without discussing the upper confidence bound.
- If EPV is below 10, state that estimates are exploratory or use penalized/sparse models.
- If a subgroup has few events, report it descriptively even when the p-value looks attractive.
schema_version: 2
name: calc-sample-size
layer: A
owner_domain: study_design
maturity: official
when_to_use:
- User asks for a sample size, power calculation, or "how many patients/subjects do I need"
- Drafting an IRB sample size justification before /write-protocol Methods
- Re-deriving N when a reviewer challenges the original power assumption
- Estimating events-per-variable (EPV) for survival or logistic regression
when_NOT_to_use:
- Statistical analysis of collected data (use /analyze-stats)
- Choosing the test itself rather than its N (use /design-study)
- Replicating a prior study's reported N without recomputation (still re-derive)
inputs:
- study_design (proportions, continuous, agreement, survival, ANOVA, logistic, NI/equivalence, diagnostic accuracy, repeated measures, Cox EPV)
- parameters (effect size, alpha, power, attrition rate, etc.)
outputs:
- protocol/sample_size_justification.md # IRB-ready prose, Output Format §"IRB Justification Text"
- protocol/sample_size_calc.R # reproducible R script
- protocol/sample_size_calc.py # alternative reproducible Python script
deterministic_scripts:
- inline R/Python code blocks (skill-emitted, not packaged)
side_effects:
- none # no external API calls; pure computation + literature anchoring
downstream_consumers:
- write-protocol # embeds Output §"IRB Justification Text" verbatim into Methods §Sample Size
- write-paper # embeds same text into Methods (post-IRB)
- design-study # cross-reference for analysis-unit / cohort-logic alignment
ssot_boundary:
- protocol/sample_size_justification.md is the canonical sample size text. write-protocol and write-paper EMBED VERBATIM; do not rephrase numbers.
quality_gates:
- parameters_documented: every parameter has a Source column entry (user / literature / convention)
- effect_size_interpretation: Cohen's benchmark classification present
- methodological_reference: cited (e.g., "Schoenfeld, 1981" for survival)
- reproducible_code: both R and Python emitted (skill default), runnable standalone
forbidden_actions:
- fabricate_effect_size_from_unverified_assumption
- omit_attrition_or_loss_to_followup
- silent_protocol_modification # changes to N must update both justification.md and protocol Methods
# v2.1 quality card
purpose: "Compute sample size / power with decision-tree test selection and reproducible R/Python code plus IRB-ready justification."
safety_boundaries:
- "Effect-size assumptions are justified and sourced, not fabricated; attrition/loss is accounted for."
- "Any change to N updates both the justification and the protocol Methods (no silent change)."
known_limitations:
- "Emits inline R/Python, not a packaged script; the user runs it."
- "Output is only as valid as the assumed effect size and design."
validation_commands:
- "re-run the emitted power code and confirm N matches the justification"
evidence_surface: manual_workflow
Related skills
FAQ
What designs does calc-sample-size support?
Diagnostic accuracy, agreement (ICC/kappa), proportions, continuous outcomes, survival, ANOVA, logistic regression, and non-inferiority/equivalence.
Does it produce IRB text?
Yes, it produces IRB-ready justification prose stating the five required elements per design.