Installation¶
This page covers how to install MCPower, its optional dependency groups, and how to verify that everything is working.
Basic Installation¶
pip install mcpower
This installs the core package with all required dependencies. It is sufficient for standard power analyses using linear regression models with continuous, binary, and factor variables.
Updating¶
pip install --upgrade mcpower
To check your current version:
pip show mcpower
Optional Dependency Groups¶
MCPower provides optional dependency groups for features that require additional packages:
Group |
Command |
What It Adds |
|---|---|---|
Core (no extras) |
|
Standard power analysis (OLS, factors, scenarios, mixed models) |
|
|
pandas DataFrame support for |
|
|
statsmodels (legacy LME fallback) |
|
|
pandas (DataFrame support) |
All Optional Dependencies¶
pip install mcpower[all]
Installs pandas for DataFrame support.
Requirements¶
Python: >= 3.10
Core dependencies (installed automatically):
Package |
Purpose |
|---|---|
NumPy |
Array operations, random number generation |
matplotlib |
Power curve plots and visualizations |
joblib |
Parallel execution for mixed-effects models |
tqdm |
Progress bars for simulation runs |
Optional dependencies:
Package |
Install With |
Purpose |
|---|---|---|
pandas |
|
DataFrame input for |
statsmodels |
|
Legacy LME solver fallback |
C++ Backend¶
MCPower includes a native C++ backend built with pybind11 and Eigen for high-performance computation. During installation, pip install mcpower automatically compiles this backend using scikit-build-core and CMake.
The C++ backend is required – it provides ~200x speedups for mixed-effects models and handles all distribution functions via Boost.Math. If compilation fails (e.g., no C++ compiler available), MCPower will not work.
For more details, see Performance & Backends.
Verifying Your Installation¶
Run a quick power analysis to confirm everything is working:
from mcpower import MCPower
model = MCPower("y = x1 + x2")
model.set_simulations(400)
model.set_effects("x1=0.5, x2=0.3")
result = model.find_power(sample_size=100, return_results=True, progress_callback=False)
print(f"MCPower is working. Power for x1: {result['results']['individual_powers']['x1']:.1f}%")
Effects: x1=0.5, x2=0.3
Model settings applied successfully
================================================================================
MONTE CARLO POWER ANALYSIS RESULTS
================================================================================
Power Analysis Results (N=100):
Test Power Target Status
-------------------------------------------------------------------
overall 100.0 80 ✓
x1 99.5 80 ✓
x2 80.5 80 ✓
Result: 3/3 tests achieved target power
MCPower is working. Power for x1: 99.5%
Desktop GUI Application¶
If you prefer a graphical interface, MCPower GUI is a standalone desktop application for Windows, Linux, and macOS. Download ready-to-run executables from the releases page. No Python installation required.