$npx -y skills add Aperivue/medsci-skills --skill calc-sample-sizeInteractive sample size calculator for medical research. Decision-tree guided test selection, reproducible R/Python code, effect size interpretation, and IRB-ready justification text. Supports diagnostic accuracy, agreement, proportions, continuous outcomes, survival, ANOVA, logi
| 1 | # Calc-Sample-Size Skill |
| 2 | |
| 3 | You are assisting a medical researcher with sample size and power calculations. Guide the user |
| 4 | through test selection using the decision tree, generate reproducible code in R (primary) and |
| 5 | Python (alternative), interpret effect sizes clinically, and produce IRB-ready justification text. |
| 6 | |
| 7 | ## Reference Files |
| 8 | |
| 9 | - **Formulas**: `${CLAUDE_SKILL_DIR}/references/formulas.md` -- mathematical formulas, R/Python functions, effect size conventions |
| 10 | - **Observational cohort precision branch**: `${CLAUDE_SKILL_DIR}/references/observational_cohort.md` |
| 11 | - **Prediction-model / medical-AI sample size (Riley)**: `${CLAUDE_SKILL_DIR}/references/prediction_model_sample_size.md` -- the current TRIPOD+AI-aligned standard for a clinical prediction/classification model (development via `pmsampsize`, external validation via `pmvalsampsize`, net-benefit precision). Use this instead of EPV-10 whenever the goal is risk prediction for use rather than a single-predictor hypothesis test (Tests 12-13). |
| 12 | - **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 |
| 13 | - **Existing R template**: See `analyze-stats` skill at `references/templates/sample_size.R` for the 7 original tests |
| 14 | |
| 15 | Read `formulas.md` before generating calculation code. |
| 16 | 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. |
| 17 | |
| 18 | ## Cross-Skill References |
| 19 | |
| 20 | - **design-study** calls **calc-sample-size** when a sample size justification is needed during study design. |
| 21 | - **calc-sample-size** output feeds into **write-protocol** and **write-paper** (Methods section). |
| 22 | - Detailed formulas and references are in `${CLAUDE_SKILL_DIR}/references/formulas.md`. |
| 23 | |
| 24 | --- |
| 25 | |
| 26 | ## Decision Tree |
| 27 | |
| 28 | When the user requests a sample size calculation, walk them through this tree interactively. |
| 29 | Ask one question at a time. Do not assume answers. |
| 30 | |
| 31 | ``` |
| 32 | What is your primary outcome? |
| 33 | | |
| 34 | +-- Binary (yes/no, positive/negative) |
| 35 | | | |
| 36 | | +-- Paired data (same subjects, two methods)? |
| 37 | | | +-- YES --> [5] McNemar test |
| 38 | | | +-- NO --> How many groups? |
| 39 | | | +-- 2 groups, superiority --> [4] Two-proportion comparison (chi-square) |
| 40 | | | +-- 2 groups, non-inferiority --> [10] Non-inferiority / equivalence |
| 41 | | | +-- Multivariable model --> single-predictor hypothesis test? --> [9] Logistic regression |
| 42 | | | --> clinical prediction / AI model for use? |
| 43 | | | +-- developing the model --> [12] Prediction-model development (Riley) |
| 44 | | | +-- externally validating --> [13] External-validation (Riley) |
| 45 | | | |
| 46 | +-- Continuous (measurement, score) |
| 47 | | | |
| 48 | | +-- How many groups? |
| 49 | | +-- 2 groups --> [6] Independent t-test |
| 50 | | +-- 3+ groups --> [8] One-way ANOVA |
| 51 | | |
| 52 | +-- Time-to-event (survival, recurrence) |
| 53 | | | |
| 54 | | +-- Two groups, unadjusted --> [7] Log-rank test |
| 55 | | +-- Multivariable / adjusted HR --> [7] Log-rank (Schoenfeld) + [11] Cox EPV |
| 56 | | |
| 57 | +-- Agreement (inter-rater, reproducibility) |
| 58 | | | |
| 59 | | +-- Continuous measurements --> [2] ICC |
| 60 | | +-- Categorical ratings --> [3] Kappa |
| 61 | | |
| 62 | +-- Diagnostic accuracy (Se, Sp, AUC precision) |
| 63 | | |
| 64 | +--> [1] Diagnostic accuracy (precision-based) |
| 65 | ``` |
| 66 | |
| 67 | --- |
| 68 | |
| 69 | ## Supported Tests |
| 70 | |
| 71 | ### Test 1: Diagnostic Accuracy (Sensitivity/Specificity Precision) |
| 72 | |
| 73 | **When to use**: Estimating required sample size for desired precision of sensitivity or specificity in a diagnostic accuracy study. |
| 74 | |
| 75 | **Required parameters** (ask the user): |
| 76 | | Parameter | Description | Default | |
| 77 | |-----------|-------------|---------| |
| 78 | | `sensitivity_expected` | Expected sensitivity | 0.85 | |
| 79 | | `ci_half_width` | Desired half-width of 95% CI | 0.05 | |
| 80 | | `prevalence` | Disease prevalence in study population | 0.30 | |
| 81 | | `alpha` | Significance level | 0.05 | |
| 82 | | `attrition_rate` | Expected dropout/exclusion rate | 0.15 | |
| 83 | |
| 84 | **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 p |