[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6MB79BM7183AQMPYS73W7TS":3,"skill-same:01M6MB79BM7183AQMPYS73W7TS":114},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":31,"publishedAt":54,"linkOnly":55,"markdownContent":56,"markdownBody":57,"frontMatter":58,"refName":66,"commitSha":67,"skillDirectory":68,"forksCount":69,"repositoryHtmlUrl":70,"repositoryHomepageUrl":71,"ownerHtmlUrl":72,"ownerBlogUrl":73,"ownerDescription":74,"updatedAt":75,"install":76,"resources":89},"01M6MB79BM7183AQMPYS73W7TS","statistical-power",null,"Sample-size and statistical power calculations for planning studies. Use whenever someone asks \"how many subjects\u002Fsamples\u002Freplicates do I need\", wants an a priori power analysis, a minimum detectable effect (MDE), a power curve, or needs to justify a sample size for a grant, IRB protocol, or pre-registration. Covers closed-form power for t-tests, ANOVA, proportions, correlations, chi-square, and regression, plus simulation-based (Monte Carlo) power for designs with no formula — logistic\u002FPoisson regression, mixed models, cluster-randomized trials, survival, and interactions. Use this skill even when the request only mentions an effect size, alpha, or \"80% power\" without saying \"power analysis\" explicitly. For laying out the study (randomization, blocking, factorial\u002FDOE, crossover, sequential designs) use experimental-design; for analyzing data already collected and reporting it use statistical-analysis.","hashgraph-online\u002Fawesome-codex-plugins","hashgraph-online","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160371962?v=4","01M6CNB6NRJVNNGN14TR01Q6D3","HOL (Hashgraph Online)","01M6JT1HSKKG9V68KQAQGBA7XP",1571,"MIT","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Fstatistical-power\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53],"statistical power","power","only","when","analyzing data","request","chi-square","ANOVA","statistics","sample","scipy","formula","design","sample-size","effect","regression","Bash","how","simulation","analysis","MDE","alpha","2026-11-10 10:12:30",false,"---\nname: statistical-power\ndescription: Sample-size and statistical power calculations for planning studies. Use whenever someone asks \"how many subjects\u002Fsamples\u002Freplicates do I need\", wants an a priori power analysis, a minimum detectable effect (MDE), a power curve, or needs to justify a sample size for a grant, IRB protocol, or pre-registration. Covers closed-form power for t-tests, ANOVA, proportions, correlations, chi-square, and regression, plus simulation-based (Monte Carlo) power for designs with no formula — logistic\u002FPoisson regression, mixed models, cluster-randomized trials, survival, and interactions. Use this skill even when the request only mentions an effect size, alpha, or \"80% power\" without saying \"power analysis\" explicitly. For laying out the study (randomization, blocking, factorial\u002FDOE, crossover, sequential designs) use experimental-design; for analyzing data already collected and reporting it use statistical-analysis.\nlicense: MIT\ncompatibility: Requires Python >=3.10. Examples target statsmodels >=0.14.6, scipy >=1.11, pingouin >=0.6, numpy >=1.26, and matplotlib. Optional extras are statsmodels mixed models and lifelines for simulation-based power.\nallowed-tools: Read Write Edit Bash\nmetadata:\n  version: '1.1'\n  category: ideation-and-design\n  maintainer: Kalaris Labs\n  tags: power analysis, sample size, study design, statistics\n---\n\n# Statistical Power & Sample Size\n\n## Overview\n\nPower analysis answers one of the most consequential questions in study planning: **how large a sample do you need to reliably detect an effect of a given size, and what could you detect with the sample you can afford?** An underpowered study wastes resources and produces inconclusive or irreproducible results; an overpowered one wastes participants, money, and (in clinical work) exposes more people to risk than necessary. Getting this right *before* data collection is the single highest-leverage statistical decision in a project.\n\nFour quantities are locked together for any given test: **sample size (n)**, **effect size**, **significance level (α)**, and **power (1 − β)**. Fix any three and the fourth is determined. Every calculation in this skill is some rearrangement of that relationship.\n\nThis skill covers the two ways to do power analysis:\n- **Closed-form** formulas (fast, exact for standard tests) — see `references\u002Fclosed_form_recipes.md`.\n- **Simulation \u002F Monte Carlo** (works for *any* design or model you can simulate and analyze) — see `references\u002Fsimulation_based_power.md`.\n\nFor choosing and converting effect sizes — usually the hardest part — see `references\u002Feffect_sizes.md`.\n\n## When to Use This Skill\n\n- Determining required sample size before collecting data (a priori power analysis)\n- Finding the minimum detectable effect (MDE) for a fixed, already-determined sample size\n- Producing power curves (power vs. n, or power vs. effect size) for a grant or protocol\n- Justifying a sample size for an IRB submission, grant, or pre-registration\n- Powering designs with unequal group sizes or non-1:1 allocation\n- Powering anything without a textbook formula (mixed models, logistic\u002FPoisson regression, cluster-randomized trials, survival analysis, mediation, interactions) via simulation\n- Accounting for multiple comparisons, attrition\u002Fdropout, or clustering in the sample-size estimate\n\n## Installation\n\nUse **uv**. Pin versions in production; unpinned is fine for exploration.\n\n```bash\nuv pip install \"statsmodels>=0.14.6\" \"scipy>=1.11\" \"pingouin>=0.6\" \"numpy>=1.26\" matplotlib pandas\n# For simulation-based power of advanced models (optional, add as needed):\nuv pip install lifelines            # survival\n# mixed models and GLMs come with statsmodels\n```\n\n**Compatibility note:** use `statsmodels>=0.14.6` with `scipy>=1.11` to avoid `_lazywhere` import errors on SciPy 1.16+. Pingouin 0.5+ renamed power-function arguments to match the names used below.\n\n---\n\n## The one decision that drives everything: the effect size\n\nPower calculations are only as trustworthy as the effect size you feed them. **Do not invent a number.** Use, in rough order of preference:\n\n1. A **minimally important effect** — the smallest effect that would actually change a decision or matter scientifically\u002Fclinically (the \"smallest effect size of interest\", SESOI). This is the most defensible basis: you power to detect what matters, not what you hope to see.\n2. A **pilot or prior-study estimate**, but shrink it — published and pilot effects are inflated by publication bias and the winner's curse. Powering on a raw pilot estimate routinely underpowers the real study.\n3. A **convention** (Cohen's small\u002Fmedium\u002Flarge) only as a last resort, and say so explicitly.\n\nWhatever you pick, run a **sensitivity analysis**: report how required n changes across a plausible range of effect sizes, not a single point. A power analysis presented as one number hides its biggest source of uncertainty. See `references\u002Feffect_sizes.md` for benchmarks and conversions between d, f, r, η², odds ratios, and Cohen's h\u002Fw.\n\n> **Avoid post-hoc (\"observed\") power.** Computing power from the effect size you just estimated is circular: it is a deterministic function of the p-value and tells you nothing new. If a study is already done and you want to know what it could have detected, report a **sensitivity analysis** (MDE at the achieved n) or, better, the confidence interval around the observed effect. This is a common reviewer complaint — do not produce observed power even if asked without flagging the issue.\n\n---\n\n## Quick recipes (closed-form)\n\nThe bundled `scripts\u002Fpower.py` wraps statsmodels into one consistent interface so you don't have to remember which solver belongs to which test. Run from the skill directory or add `scripts\u002F` to `sys.path`.\n\n```python\nfrom power import sample_size, power, mde, power_curve\n\n# 1. How many per group to detect Cohen's d = 0.5, two-sided, 80% power?\nsample_size(test=\"t_ind\", effect_size=0.5, power=0.80, alpha=0.05)\n# -> required n per group\n\n# 2. Two groups, 3:1 allocation (e.g. more controls than cases)\nsample_size(test=\"t_ind\", effect_size=0.5, power=0.80, ratio=3.0)\n\n# 3. Fixed n=30\u002Fgroup — what's the minimum detectable d at 80% power?\nmde(test=\"t_ind\", nobs1=30, power=0.80, alpha=0.05)\n\n# 4. One-way ANOVA, 4 groups, detect Cohen's f = 0.25\nsample_size(test=\"anova\", effect_size=0.25, k_groups=4, power=0.80)\n\n# 5. Two proportions: 0.40 vs 0.55 (auto-converts to Cohen's h)\nsample_size(test=\"two_proportions\", prop1=0.40, prop2=0.55, power=0.80)\n\n# 6. Correlation: detect r = 0.30\nsample_size(test=\"correlation\", effect_size=0.30, power=0.80)\n\n# 7. Power curve for the grant figure\npower_curve(test=\"t_ind\", effect_size=0.5, n_range=range(10, 120, 5),\n            save=\"power_curve.png\")\n```\n\nSupported `test=` values: `t_ind` (two independent means), `t_paired`\u002F`t_one` (paired or one-sample mean), `anova` (one-way), `two_proportions`, `one_proportion`, `correlation`, `chi2` (goodness-of-fit \u002F contingency via effect size *w*), `linear_regression` (R² increment \u002F f²). Full argument tables and the underlying statsmodels calls are in `references\u002Fclosed_form_recipes.md`.\n\n---\n\n## When there is no formula: simulate\n\nClosed-form power exists only for a handful of simple tests. For **logistic\u002FPoisson regression, mixed-effects \u002F repeated-measures models, cluster-randomized trials, survival analysis, mediation, multi-way interactions, or any non-standard analysis**, the right tool is simulation. The logic is always the same three steps:\n\n1. **Simulate** a dataset from your assumed truth (the effect you want to detect, plus realistic noise, baseline rates, cluster structure, etc.).\n2. **Analyze** it with the *exact* test\u002Fmodel you plan to use on the real data.\n3. **Repeat** many times (≥1,000; 5,000–10,000 for a stable estimate near 80%). Power is the fraction of replicates in which the test is significant.\n\n`scripts\u002Fsimulate_power.py` provides a reusable harness plus worked examples (two-group difference, logistic regression, cluster-randomized trial with an ICC, and a linear mixed model). The core is just:\n\n```python\nfrom simulate_power import simulate_power\n\ndef gen_and_test(n, rng):\n    # build a dataset of size n under the assumed effect, run the planned test,\n    # return True if the result is significant\n    ...\n\nest = simulate_power(gen_and_test, n=200, n_sims=2000, alpha=0.05)\nprint(f\"Power at n=200: {est.power:.3f} (95% CI {est.ci_low:.3f}-{est.ci_high:.3f})\")\n```\n\nReport the **Monte Carlo confidence interval** on the estimate (the harness returns it) so the reader knows whether 0.81 vs. 0.79 is signal or simulation noise. See `references\u002Fsimulation_based_power.md` for the full patterns, including how to search for the n that hits target power and how to model dropout and clustering.\n\n---\n\n## Adjustments people forget\n\nThese routinely make the difference between an adequately powered study and an underpowered one. Apply them explicitly and state that you did.\n\n- **Multiple comparisons.** If the analysis tests *m* hypotheses with a Bonferroni-style correction, power each test at the corrected α (e.g. α\u002Fm), which raises n. Better: power on the family-wise or FDR-controlled procedure directly via simulation. Ignoring this silently underpowers every secondary endpoint.\n- **Attrition \u002F dropout \u002F unusable samples.** Power gives the n you need *analyzed*. Inflate the *enrolled* n: `n_enroll = ceil(n_analyzed \u002F (1 − dropout_rate))`. A 20% dropout rate means enrolling 25% more than the formula returns.\n- **Clustering (design effect).** When observations are nested (patients within clinics, cells within animals, repeated measures within subject), the effective sample size is smaller than the raw count. Inflate by the design effect `DEFF = 1 + (m − 1)·ICC`, where *m* is cluster size and ICC the intraclass correlation. Treating clustered data as independent is **pseudoreplication** and badly overstates power — for cluster-randomized designs, simulate instead.\n- **One- vs. two-sided.** Two-sided is the default and almost always the right choice; a one-sided test buys power only by refusing to detect an effect in the unexpected direction. Justify any one-sided test.\n- **Unequal allocation.** Equal groups are most efficient for a fixed total n. If allocation is fixed by design (e.g. 2:1 treatment:control), pass `ratio=` so the calculation reflects it.\n\n---\n\n## Workflow\n\n1. **State the design and the planned analysis.** The test you will run determines the power method. If the analysis is a mixed model or GLM, go straight to simulation.\n2. **Choose the effect size** on a defensible basis (SESOI > shrunk pilot > convention) and write down the justification.\n3. **Set α and target power.** Conventional defaults are α = 0.05 (two-sided) and power = 0.80; 0.90 is common for confirmatory\u002Fclinical work. State them.\n4. **Compute** with `scripts\u002Fpower.py` (closed-form) or `scripts\u002Fsimulate_power.py` (simulation).\n5. **Sensitivity analysis.** Recompute across a range of plausible effect sizes and produce a power curve. This is the deliverable, not a single number.\n6. **Apply adjustments** for dropout, clustering, and multiplicity.\n7. **Report** following the template below.\n\n---\n\n## Reporting template\n\nA defensible power statement contains every input, so a reader could reproduce it. Adapt:\n\n```\nA priori power analysis was conducted to determine the sample size needed to detect\na [between-group difference of Cohen's d = 0.50], which we considered the smallest\neffect of clinical interest. With α = .05 (two-sided) and power = .80, a two-sample\nt-test requires n = 64 per group (128 total; computed with statsmodels 0.14).\nAllowing for 20% attrition, we will enrol 160 participants. A sensitivity analysis\nshowed required n ranges from 45 to 105 per group across plausible effects\nd = 0.40–0.60 (Figure X).\n```\n\nFor simulation: also state the data-generating assumptions (baseline rate, residual SD, ICC, cluster sizes), the number of simulations, and the Monte Carlo CI.\n\n---\n\n## Common pitfalls\n\n1. **Inventing the effect size** or copying an inflated pilot estimate — the most common way power analyses go wrong.\n2. **Reporting a single n** instead of a sensitivity range \u002F power curve.\n3. **Post-hoc \u002F observed power** — circular and uninformative; use sensitivity analysis or the effect-size CI instead.\n4. **Ignoring clustering** (pseudoreplication) — counting cells\u002Fmeasurements as if they were independent subjects.\n5. **Forgetting dropout** — powering the analyzed n but enrolling the same number.\n6. **Confusing α with power**, or one-sided with two-sided.\n7. **Powering only the primary endpoint** while reporting secondary\u002Finteraction tests that need far larger n.\n8. **Using a t-test formula for a model you won't actually fit** (e.g. planning a logistic regression with a means-based calculation) — match the power method to the planned analysis.\n\n---\n\n## Resources\n\n### Scripts\n- `scripts\u002Fpower.py` — unified closed-form interface (`sample_size`, `power`, `mde`, `power_curve`) over statsmodels\u002Fpingouin for all standard tests.\n- `scripts\u002Fsimulate_power.py` — Monte Carlo power harness with `simulate_power()` and `find_sample_size()`, plus worked examples (two-group, logistic regression, cluster-randomized, linear mixed model).\n\n### References\n- `references\u002Fclosed_form_recipes.md` — per-test argument tables and exact statsmodels\u002Fpingouin calls, including proportions, chi-square, and regression.\n- `references\u002Fsimulation_based_power.md` — full simulation patterns for GLMs, mixed models, cluster designs, survival, and dropout.\n- `references\u002Feffect_sizes.md` — choosing effect sizes (SESOI), Cohen's benchmarks, and conversions between d, f, r, η²\u002Ff², OR, h, and w.\n\n### Related skills\n- **experimental-design** — once you know n, lay out the actual study (randomization, blocking, factorial\u002FDOE, crossover, sequential designs).\n- **statistical-analysis** — assumption checks, running the test, effect sizes, and APA reporting after data collection.\n- **statsmodels** \u002F **pymc** — fitting the models referenced here.\n\n### Key references\n- Cohen, J. (1988). *Statistical Power Analysis for the Behavioral Sciences* (2nd ed.).\n- Lakens, D. (2022). *Sample Size Justification*. Collabra: Psychology, 8(1).\n- Arnold, B. F. et al. (2011). Simulation methods to estimate design power. *BMC Medical Research Methodology*, 11:94.\n\n## Agent operating procedure\n\n1. **Check the environment.** Clarify the research goal, constraints (budget, time, ethics) and the decision the user needs to make.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Propose a short shortlist of options with explicit assumptions before expanding any of them.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Assumptions are stated, alternatives are compared on explicit criteria, and statistical plans include power and analysis choices.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| A design choice depends on unknown effect sizes or costs | Present scenarios (optimistic, expected, pessimistic) instead of a single guess. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Label speculation as speculation; separate established evidence from new hypotheses.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n","# Statistical Power & Sample Size\n\n## Overview\n\nPower analysis answers one of the most consequential questions in study planning: **how large a sample do you need to reliably detect an effect of a given size, and what could you detect with the sample you can afford?** An underpowered study wastes resources and produces inconclusive or irreproducible results; an overpowered one wastes participants, money, and (in clinical work) exposes more people to risk than necessary. Getting this right *before* data collection is the single highest-leverage statistical decision in a project.\n\nFour quantities are locked together for any given test: **sample size (n)**, **effect size**, **significance level (α)**, and **power (1 − β)**. Fix any three and the fourth is determined. Every calculation in this skill is some rearrangement of that relationship.\n\nThis skill covers the two ways to do power analysis:\n- **Closed-form** formulas (fast, exact for standard tests) — see `references\u002Fclosed_form_recipes.md`.\n- **Simulation \u002F Monte Carlo** (works for *any* design or model you can simulate and analyze) — see `references\u002Fsimulation_based_power.md`.\n\nFor choosing and converting effect sizes — usually the hardest part — see `references\u002Feffect_sizes.md`.\n\n## When to Use This Skill\n\n- Determining required sample size before collecting data (a priori power analysis)\n- Finding the minimum detectable effect (MDE) for a fixed, already-determined sample size\n- Producing power curves (power vs. n, or power vs. effect size) for a grant or protocol\n- Justifying a sample size for an IRB submission, grant, or pre-registration\n- Powering designs with unequal group sizes or non-1:1 allocation\n- Powering anything without a textbook formula (mixed models, logistic\u002FPoisson regression, cluster-randomized trials, survival analysis, mediation, interactions) via simulation\n- Accounting for multiple comparisons, attrition\u002Fdropout, or clustering in the sample-size estimate\n\n## Installation\n\nUse **uv**. Pin versions in production; unpinned is fine for exploration.\n\n```bash\nuv pip install \"statsmodels>=0.14.6\" \"scipy>=1.11\" \"pingouin>=0.6\" \"numpy>=1.26\" matplotlib pandas\n# For simulation-based power of advanced models (optional, add as needed):\nuv pip install lifelines            # survival\n# mixed models and GLMs come with statsmodels\n```\n\n**Compatibility note:** use `statsmodels>=0.14.6` with `scipy>=1.11` to avoid `_lazywhere` import errors on SciPy 1.16+. Pingouin 0.5+ renamed power-function arguments to match the names used below.\n\n---\n\n## The one decision that drives everything: the effect size\n\nPower calculations are only as trustworthy as the effect size you feed them. **Do not invent a number.** Use, in rough order of preference:\n\n1. A **minimally important effect** — the smallest effect that would actually change a decision or matter scientifically\u002Fclinically (the \"smallest effect size of interest\", SESOI). This is the most defensible basis: you power to detect what matters, not what you hope to see.\n2. A **pilot or prior-study estimate**, but shrink it — published and pilot effects are inflated by publication bias and the winner's curse. Powering on a raw pilot estimate routinely underpowers the real study.\n3. A **convention** (Cohen's small\u002Fmedium\u002Flarge) only as a last resort, and say so explicitly.\n\nWhatever you pick, run a **sensitivity analysis**: report how required n changes across a plausible range of effect sizes, not a single point. A power analysis presented as one number hides its biggest source of uncertainty. See `references\u002Feffect_sizes.md` for benchmarks and conversions between d, f, r, η², odds ratios, and Cohen's h\u002Fw.\n\n> **Avoid post-hoc (\"observed\") power.** Computing power from the effect size you just estimated is circular: it is a deterministic function of the p-value and tells you nothing new. If a study is already done and you want to know what it could have detected, report a **sensitivity analysis** (MDE at the achieved n) or, better, the confidence interval around the observed effect. This is a common reviewer complaint — do not produce observed power even if asked without flagging the issue.\n\n---\n\n## Quick recipes (closed-form)\n\nThe bundled `scripts\u002Fpower.py` wraps statsmodels into one consistent interface so you don't have to remember which solver belongs to which test. Run from the skill directory or add `scripts\u002F` to `sys.path`.\n\n```python\nfrom power import sample_size, power, mde, power_curve\n\n# 1. How many per group to detect Cohen's d = 0.5, two-sided, 80% power?\nsample_size(test=\"t_ind\", effect_size=0.5, power=0.80, alpha=0.05)\n# -> required n per group\n\n# 2. Two groups, 3:1 allocation (e.g. more controls than cases)\nsample_size(test=\"t_ind\", effect_size=0.5, power=0.80, ratio=3.0)\n\n# 3. Fixed n=30\u002Fgroup — what's the minimum detectable d at 80% power?\nmde(test=\"t_ind\", nobs1=30, power=0.80, alpha=0.05)\n\n# 4. One-way ANOVA, 4 groups, detect Cohen's f = 0.25\nsample_size(test=\"anova\", effect_size=0.25, k_groups=4, power=0.80)\n\n# 5. Two proportions: 0.40 vs 0.55 (auto-converts to Cohen's h)\nsample_size(test=\"two_proportions\", prop1=0.40, prop2=0.55, power=0.80)\n\n# 6. Correlation: detect r = 0.30\nsample_size(test=\"correlation\", effect_size=0.30, power=0.80)\n\n# 7. Power curve for the grant figure\npower_curve(test=\"t_ind\", effect_size=0.5, n_range=range(10, 120, 5),\n            save=\"power_curve.png\")\n```\n\nSupported `test=` values: `t_ind` (two independent means), `t_paired`\u002F`t_one` (paired or one-sample mean), `anova` (one-way), `two_proportions`, `one_proportion`, `correlation`, `chi2` (goodness-of-fit \u002F contingency via effect size *w*), `linear_regression` (R² increment \u002F f²). Full argument tables and the underlying statsmodels calls are in `references\u002Fclosed_form_recipes.md`.\n\n---\n\n## When there is no formula: simulate\n\nClosed-form power exists only for a handful of simple tests. For **logistic\u002FPoisson regression, mixed-effects \u002F repeated-measures models, cluster-randomized trials, survival analysis, mediation, multi-way interactions, or any non-standard analysis**, the right tool is simulation. The logic is always the same three steps:\n\n1. **Simulate** a dataset from your assumed truth (the effect you want to detect, plus realistic noise, baseline rates, cluster structure, etc.).\n2. **Analyze** it with the *exact* test\u002Fmodel you plan to use on the real data.\n3. **Repeat** many times (≥1,000; 5,000–10,000 for a stable estimate near 80%). Power is the fraction of replicates in which the test is significant.\n\n`scripts\u002Fsimulate_power.py` provides a reusable harness plus worked examples (two-group difference, logistic regression, cluster-randomized trial with an ICC, and a linear mixed model). The core is just:\n\n```python\nfrom simulate_power import simulate_power\n\ndef gen_and_test(n, rng):\n    # build a dataset of size n under the assumed effect, run the planned test,\n    # return True if the result is significant\n    ...\n\nest = simulate_power(gen_and_test, n=200, n_sims=2000, alpha=0.05)\nprint(f\"Power at n=200: {est.power:.3f} (95% CI {est.ci_low:.3f}-{est.ci_high:.3f})\")\n```\n\nReport the **Monte Carlo confidence interval** on the estimate (the harness returns it) so the reader knows whether 0.81 vs. 0.79 is signal or simulation noise. See `references\u002Fsimulation_based_power.md` for the full patterns, including how to search for the n that hits target power and how to model dropout and clustering.\n\n---\n\n## Adjustments people forget\n\nThese routinely make the difference between an adequately powered study and an underpowered one. Apply them explicitly and state that you did.\n\n- **Multiple comparisons.** If the analysis tests *m* hypotheses with a Bonferroni-style correction, power each test at the corrected α (e.g. α\u002Fm), which raises n. Better: power on the family-wise or FDR-controlled procedure directly via simulation. Ignoring this silently underpowers every secondary endpoint.\n- **Attrition \u002F dropout \u002F unusable samples.** Power gives the n you need *analyzed*. Inflate the *enrolled* n: `n_enroll = ceil(n_analyzed \u002F (1 − dropout_rate))`. A 20% dropout rate means enrolling 25% more than the formula returns.\n- **Clustering (design effect).** When observations are nested (patients within clinics, cells within animals, repeated measures within subject), the effective sample size is smaller than the raw count. Inflate by the design effect `DEFF = 1 + (m − 1)·ICC`, where *m* is cluster size and ICC the intraclass correlation. Treating clustered data as independent is **pseudoreplication** and badly overstates power — for cluster-randomized designs, simulate instead.\n- **One- vs. two-sided.** Two-sided is the default and almost always the right choice; a one-sided test buys power only by refusing to detect an effect in the unexpected direction. Justify any one-sided test.\n- **Unequal allocation.** Equal groups are most efficient for a fixed total n. If allocation is fixed by design (e.g. 2:1 treatment:control), pass `ratio=` so the calculation reflects it.\n\n---\n\n## Workflow\n\n1. **State the design and the planned analysis.** The test you will run determines the power method. If the analysis is a mixed model or GLM, go straight to simulation.\n2. **Choose the effect size** on a defensible basis (SESOI > shrunk pilot > convention) and write down the justification.\n3. **Set α and target power.** Conventional defaults are α = 0.05 (two-sided) and power = 0.80; 0.90 is common for confirmatory\u002Fclinical work. State them.\n4. **Compute** with `scripts\u002Fpower.py` (closed-form) or `scripts\u002Fsimulate_power.py` (simulation).\n5. **Sensitivity analysis.** Recompute across a range of plausible effect sizes and produce a power curve. This is the deliverable, not a single number.\n6. **Apply adjustments** for dropout, clustering, and multiplicity.\n7. **Report** following the template below.\n\n---\n\n## Reporting template\n\nA defensible power statement contains every input, so a reader could reproduce it. Adapt:\n\n```\nA priori power analysis was conducted to determine the sample size needed to detect\na [between-group difference of Cohen's d = 0.50], which we considered the smallest\neffect of clinical interest. With α = .05 (two-sided) and power = .80, a two-sample\nt-test requires n = 64 per group (128 total; computed with statsmodels 0.14).\nAllowing for 20% attrition, we will enrol 160 participants. A sensitivity analysis\nshowed required n ranges from 45 to 105 per group across plausible effects\nd = 0.40–0.60 (Figure X).\n```\n\nFor simulation: also state the data-generating assumptions (baseline rate, residual SD, ICC, cluster sizes), the number of simulations, and the Monte Carlo CI.\n\n---\n\n## Common pitfalls\n\n1. **Inventing the effect size** or copying an inflated pilot estimate — the most common way power analyses go wrong.\n2. **Reporting a single n** instead of a sensitivity range \u002F power curve.\n3. **Post-hoc \u002F observed power** — circular and uninformative; use sensitivity analysis or the effect-size CI instead.\n4. **Ignoring clustering** (pseudoreplication) — counting cells\u002Fmeasurements as if they were independent subjects.\n5. **Forgetting dropout** — powering the analyzed n but enrolling the same number.\n6. **Confusing α with power**, or one-sided with two-sided.\n7. **Powering only the primary endpoint** while reporting secondary\u002Finteraction tests that need far larger n.\n8. **Using a t-test formula for a model you won't actually fit** (e.g. planning a logistic regression with a means-based calculation) — match the power method to the planned analysis.\n\n---\n\n## Resources\n\n### Scripts\n- `scripts\u002Fpower.py` — unified closed-form interface (`sample_size`, `power`, `mde`, `power_curve`) over statsmodels\u002Fpingouin for all standard tests.\n- `scripts\u002Fsimulate_power.py` — Monte Carlo power harness with `simulate_power()` and `find_sample_size()`, plus worked examples (two-group, logistic regression, cluster-randomized, linear mixed model).\n\n### References\n- `references\u002Fclosed_form_recipes.md` — per-test argument tables and exact statsmodels\u002Fpingouin calls, including proportions, chi-square, and regression.\n- `references\u002Fsimulation_based_power.md` — full simulation patterns for GLMs, mixed models, cluster designs, survival, and dropout.\n- `references\u002Feffect_sizes.md` — choosing effect sizes (SESOI), Cohen's benchmarks, and conversions between d, f, r, η²\u002Ff², OR, h, and w.\n\n### Related skills\n- **experimental-design** — once you know n, lay out the actual study (randomization, blocking, factorial\u002FDOE, crossover, sequential designs).\n- **statistical-analysis** — assumption checks, running the test, effect sizes, and APA reporting after data collection.\n- **statsmodels** \u002F **pymc** — fitting the models referenced here.\n\n### Key references\n- Cohen, J. (1988). *Statistical Power Analysis for the Behavioral Sciences* (2nd ed.).\n- Lakens, D. (2022). *Sample Size Justification*. Collabra: Psychology, 8(1).\n- Arnold, B. F. et al. (2011). Simulation methods to estimate design power. *BMC Medical Research Methodology*, 11:94.\n\n## Agent operating procedure\n\n1. **Check the environment.** Clarify the research goal, constraints (budget, time, ethics) and the decision the user needs to make.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Propose a short shortlist of options with explicit assumptions before expanding any of them.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Assumptions are stated, alternatives are compared on explicit criteria, and statistical plans include power and analysis choices.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| A design choice depends on unknown effect sizes or costs | Present scenarios (optimistic, expected, pessimistic) instead of a single guess. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Label speculation as speculation; separate established evidence from new hypotheses.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n",{"name":5,"license":15,"metadata":59,"description":7,"allowed-tools":64,"compatibility":65},{"tags":60,"version":61,"category":62,"maintainer":63},"power analysis, sample size, study design, statistics","1.1","ideation-and-design","Kalaris Labs","Read Write Edit Bash","Requires Python >=3.10. Examples target statsmodels >=0.14.6, scipy >=1.11, pingouin >=0.6, numpy >=1.26, and matplotlib. Optional extras are statsmodels mixed models and lifelines for simulation-based power.","main","2b63f856ce19c2a797929cacabd9e0fc936812fa","plugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Fstatistical-power",490,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins","https:\u002F\u002Fhol.org\u002Fplugins\u002Fbest-codex-plugins","https:\u002F\u002Fgithub.com\u002Fhashgraph-online","https:\u002F\u002Fhol.org","Open-source standards and developer tools for interoperable AI agents: discovery, identity, communication, payments, privacy and security.","2026-11-14 02:12:02",{"source":8,"skillName":5,"commands":77,"prompt":87,"zipAvailable":88},[78,81,84],{"tool":79,"command":80},"npx","npx skills add hashgraph-online\u002Fawesome-codex-plugins --skill statistical-power",{"tool":82,"command":83},"bunx","bunx skills add hashgraph-online\u002Fawesome-codex-plugins --skill statistical-power",{"tool":85,"command":86},"pnpm","pnpm dlx skills add hashgraph-online\u002Fawesome-codex-plugins --skill statistical-power","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Fstatistical-power\u002FSKILL.md",true,[90,96,100,104,110],{"path":91,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":94,"sourceHtmlUrl":95},"references\u002Fclosed_form_recipes.md","REFERENCE","参考文档",6809,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Fstatistical-power\u002Freferences\u002Fclosed_form_recipes.md",{"path":97,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":98,"sourceHtmlUrl":99},"references\u002Feffect_sizes.md",4919,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Fstatistical-power\u002Freferences\u002Feffect_sizes.md",{"path":101,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":102,"sourceHtmlUrl":103},"references\u002Fsimulation_based_power.md",5684,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Fstatistical-power\u002Freferences\u002Fsimulation_based_power.md",{"path":105,"resourceType":106,"resourceTypeDesc":107,"sizeBytes":108,"sourceHtmlUrl":109},"scripts\u002Fpower.py","SCRIPT","脚本",12726,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Fstatistical-power\u002Fscripts\u002Fpower.py",{"path":111,"resourceType":106,"resourceTypeDesc":107,"sizeBytes":112,"sourceHtmlUrl":113},"scripts\u002Fsimulate_power.py",8009,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fskills\u002Fstatistical-power\u002Fscripts\u002Fsimulate_power.py",[115,124,131,138,163,188],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":119,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":123},"01M746ZWACVKMZ1BJXJZHYJSSX","migrate-to-e2e","Moves an existing Playwright, Cypress, Selenium, Appium, Detox, Maestro, or TesterArmy suite to e2e one slice at a time, with the old suite running beside the new one until each ported test is proven. Keeps a MIGRATION.md progress file so any later session resumes where the last stopped. Optionally plants a defect to show both suites catch it. Use for \u002Fmigrate-to-e2e, \"migrate our tests to e2e\", \"port these Maestro flows\", \"move our TesterArmy tests\", or when a project has an e2e config and an older suite still running.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Ftester-army\u002Fe2e\u002Fskills\u002Fmigrate-to-e2e\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":119,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":123},"01M746ZPTAX1Q0FBKAB1CYND7E","e2e","Writes, runs, and debugs end-to-end tests for web and mobile apps with e2e, the agentic test runner, which mixes agent.act goals with exact locator assertions on a Playwright browser or an iOS or Android device. Also drives a project's running app live over the e2e MCP server to look at a screen, check a UI change, take a screenshot or record a video, and try a locator; and runs bug bashes, parallel e2e explore runs with each bug proven by a repro test. Use when a project depends on e2e or has an e2e.config.ts, when asked for end-to-end, browser, mobile, or agentic UI tests, to check a change in the running app, to QA or bug bash an app or branch, or when an e2e run fails.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Ftester-army\u002Fe2e\u002Fskills\u002Fe2e\u002FSKILL.md",[],[],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":119,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":123},"01M746ZJN784HVHMDP9MQGCSGG","create-verification-skill","Generate a project-local verify-\u003Capp> skill on top of e2e, so any coding agent can launch the app, check it is worth driving, exercise a feature the way a user does, keep evidence, and bug bash it. Writes the skill, a feature map with one explore charter per feature, and proves it once. Use for \u002Fcreate-verification-skill, \"make a verification skill for this repo\", or when a project has no scripted way to prove UI behavior.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Ftester-army\u002Fe2e\u002Fskills\u002Fcreate-verification-skill\u002FSKILL.md",[],[],{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":119,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":54},"01M716A6ETNB9B1SQ3GXZC75VR","deja-search","deja-vu memory — search the user's past AI coding sessions with the deja CLI. Holds what they already settled and never wrote into the repo (naming rules, banned or already-tried tools, required checks before merge, preferred values, who owns what). Use before your first edit in a task, before you call a change done or ready to merge, before you recommend a tool, library, design or reviewer, before re-debugging an error that may already be solved, when they say 'didn't we fix this before', 'what did we decide about X' or 'I already have that', and before telling them something on this machine does not exist.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvshulcz\u002Fdeja-vu\u002Fskills\u002Fdeja-search\u002FSKILL.md",[],[145,146,147,148,149,150,151,152,153,44,154,35,155,156,157,158,159,160,161,162],"search","deja search","never","error","ready","memory","re","decide","fix","debugging","you","done","reviewer","io","change","cli","merge","past",{"skillNo":164,"name":165,"nameZh":6,"description":166,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":119,"licenseFileUrl":6,"sourceHtmlUrl":167,"categories":168,"keywords":169,"publishedAt":54},"01M716A3J2W5SENSE9VGMXB375","deja-reflect","End-of-session reflection and memory curation with deja-vu. Review what was decided, what commands broke and what repaired them, and record durable project rules or decisions with deja remember so the next session starts with them.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvshulcz\u002Fdeja-vu\u002Fskills\u002Fdeja-reflect\u002FSKILL.md",[],[170,171,172,158,173,174,175,176,177,178,179,180,181,182,150,183,184,185,186,187],"deja reflect","reflect","review","with","record","github","next","https","node","Rules","decisions","brew","remember","project rules","project","session","end","reflection",{"skillNo":189,"name":190,"nameZh":6,"description":191,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":119,"licenseFileUrl":6,"sourceHtmlUrl":192,"categories":193,"keywords":201,"publishedAt":54},"01M715T3RR4BAYSR57HPPTJ0PF","revid","Make, edit, export and post AI videos with Revid (revid.ai) through the Revid MCP server. Use whenever the user wants a short-form or long-form video made (from an idea, a script, a URL, an article, a PDF, a tweet, a product page, their own clips, or a song), wants to find what is going viral on TikTok, YouTube, Instagram or X before making something, wants to edit or re-export an existing Revid project, generate a standalone AI image or clip, make a series episode, or publish and schedule a finished video to connected social accounts. Covers setup (hosted MCP with OAuth, or an API key), the 36 tools, credits, polling and the rules for publishing. Routes to the more specific revid-* skills when one fits.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Ftmakersas\u002Frevid-skills\u002Fskills\u002Frevid\u002FSKILL.md",[194,197,198],{"categoryNo":195,"categoryName":196,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000016","图像与多媒体",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":199,"categoryName":200,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",[190,202,203,204,205,206,207,184,208,151,209,210,211,212,35,213,214,215,216,217],"URL","Video","short-form","standalone","PDF","viral","tiktok","short","social","MCP","song","image","mcp server","schedule","api","publish"]