Simple Monte Carlo power analysis for complex models. Find the sample size you need or check if your study has enough power — even with complex models that traditional power analysis can’t handle.

Tests PyPI Python License: GPL v3 DOI Windows macOS Linux
MCPower ASCII art

Why MCPower?

Traditional power analysis breaks down with interactions, correlated predictors, categorical variables, or non-normal data. MCPower uses simulation instead of formulas — it generates thousands of datasets exactly like yours, then sees how often your analysis finds real effects.

  • Works with complexity: Interactions, correlations, factors, any distribution
  • R-style formulas: outcome = treatment + covariate + treatment*covariate
  • Categorical variables: Multi-level factors automatically handled
  • Two simple commands: Find sample size or check power
  • Scenario analysis: Test robustness under realistic conditions
  • Minimal math required: Just specify your model and effects

Desktop Application

Prefer a graphical interface? MCPower GUI is a standalone desktop app — no Python installation required. Download ready-to-run executables for Windows, Linux, and macOS.

PlatformDownload
WindowsMCPower.exe
LinuxMCPower-linux
macOSMCPower-macos
AlternativeSourceForge

The GUI walks you through three steps: Model (define your study design), Analysis (choose mode and settings), and Results (view power tables, charts, and a replication script).


Get Started in 2 Minutes

Installation

pip install mcpower

Your First Power Analysis

# python

import mcpower

# 1. Define your model (just like R)
model = mcpower.MCPower("satisfaction = treatment + motivation")

# 2. Set effect sizes (how big you expect effects to be)
model.set_effects("treatment=0.5, motivation=0.3")

# 3. Change the treatment to "binary" (people receive treatment or not)
model.set_variable_type("treatment=binary")

# 4. Find the sample size you need
model.find_sample_size(target_test="treatment", from_size=50, to_size=200)

Output: “You need N=75 for 80% power to detect the treatment effect”


Scenario Analysis: Test Your Assumptions

Real studies rarely match perfect assumptions. MCPower’s scenario analysis tests how robust your power calculations are under realistic conditions.

# python

model.find_sample_size(
    target_test="treatment",
    from_size=50, to_size=300,
    scenarios=True  # The magic happens here
)
SCENARIO SUMMARY
================================================================================

Uncorrected Sample Sizes:
Test                                     Optimistic   Realistic    Doomer
-------------------------------------------------------------------------------
treatment                                75           85           100
================================================================================
  • Optimistic: Your ideal conditions (original settings)
  • Realistic: Moderate real-world complications (recommended for planning)
  • Doomer: Conservative estimate (if this is acceptable, you’re really safe!)

Copy-Paste Examples

Randomized Controlled Trial

# python

import mcpower

model = mcpower.MCPower("outcome = treatment + age + baseline_score")
model.set_effects("treatment=0.6, age=0.2, baseline_score=0.8")
model.set_variable_type("treatment=binary")

model.find_sample_size(target_test="treatment", from_size=100, to_size=500,
                      by=50, scenarios=True)

A/B Test with Interaction

# python

import mcpower

model = mcpower.MCPower("conversion = treatment + user_type + treatment*user_type")
model.set_effects("treatment=0.4, user_type=0.3, treatment:user_type=0.5")
model.set_variable_type("treatment=binary, user_type=binary")

model.find_power(sample_size=400, target_test="treatment:user_type", scenarios=True)

Multi-Group Study with Categorical Variables

# python

import mcpower

model = mcpower.MCPower("wellbeing = treatment + education + age")
model.set_variable_type("treatment=(factor,3), education=(factor,4)")
model.set_effects("treatment[2]=0.4, treatment[3]=0.6, education[2]=0.3, education[3]=0.5, education[4]=0.7, age=0.2")

model.find_sample_size(target_test="treatment[2], treatment[3]", scenarios=True)

Survey with Correlated Predictors

# python

import mcpower

model = mcpower.MCPower("wellbeing = income + education + social_support")
model.set_effects("income=0.4, education=0.3, social_support=0.6")
model.set_correlations("corr(income, education)=0.5, corr(income, social_support)=0.3")

model.find_sample_size(target_test="all", from_size=200, to_size=800,
                      by=100, scenarios=True)

Mixed-Effects Model (Random Intercept)

# python

import mcpower

model = mcpower.MCPower("satisfaction ~ treatment + motivation + (1|school)")
model.set_cluster("school", ICC=0.2, n_clusters=20)
model.set_effects("treatment=0.5, motivation=0.3")
model.set_variable_type("treatment=binary")

# Total sample_size is split across clusters: 1000 / 20 = 50 per cluster
model.find_power(sample_size=1000)

Quick Reference

Want to…Use this
Find required sample sizemodel.find_sample_size(target_test="effect_name")
Check power for specific Nmodel.find_power(sample_size=150, target_test="effect_name")
Test robustnessAdd scenarios=True to either method
Detailed output with plotsAdd summary="long" to either method
Test overall modeltarget_test="overall"
Test multiple effectstarget_test="effect1, effect2" or "all"
Binary variablesmodel.set_variable_type("var=binary")
Factor variablesmodel.set_variable_type("var=(factor,3)")
Factor effectsmodel.set_effects("var[2]=0.5, var[3]=0.7")
Correlated predictorsmodel.set_correlations("corr(var1, var2)=0.4")
Multiple testing correctionAdd correction="FDR", "Holm", or "Bonferroni"
Mixed model (random intercept)MCPower("y ~ x + (1|group)") + model.set_cluster(...)
Upload your own datamodel.upload_data(dataframe)
Reproducible resultsmodel.set_seed(42)
Get results as dictAdd return_results=True to either method
Stricter significancemodel.set_alpha(0.01)
Target 90% powermodel.set_power(90)

When to Use MCPower

Use MCPower when you have:

  • Interaction terms (treatment*covariate)
  • Categorical variables with multiple levels
  • Binary or non-normal variables
  • Correlated predictors
  • Multiple effects to test
  • Need to test assumption robustness
  • Complex models where traditional power analysis fails

Use traditional power analysis for:

  • Models that are not yet implemented in MCPower
  • Simple models where all assumptions are clearly met
  • Very large analyses with tens of thousands of observations

Roadmap

  • Done: Linear Regression, Scenarios & robustness analysis, Factor variables, C++ native backend (3x speedup)
  • In progress: Mixed-Effects Models (random intercept), Logistic Regression, ANOVA
  • Planned: Two-group comparison with alternative tests, Robust regression methods

Links & Resources


Citation

GPL v3. If you use MCPower in research, please cite:

Lenartowicz, P. (2025). MCPower: Monte Carlo Power Analysis for Statistical Models. Zenodo. DOI: 10.5281/zenodo.16502734

@software{mcpower2025,
  author = {Pawel Lenartowicz},
  title = {MCPower: Monte Carlo Power Analysis for Statistical Models},
  year = {2025},
  publisher = {Zenodo},
  doi = {10.5281/zenodo.16502734},
  url = {https://doi.org/10.5281/zenodo.16502734}
}