Skip to main content

power-analysis 💪🔍

power-analysis is a Python package for performing power analysis and calculating sample sizes for statistical models. The package provides classes for defining statistical models, performing power analysis, calculating sample sizes for two-sample t-tests, and conducting power analysis on observational panel data using a clustered bootstrap method.

Installation 📥

You can install the power_analysis package using pip:

pip install power-analysis

Usage 🧑‍💻

Panel Data Power Analysis

To use the PanelBootstrap class for power analysis on observational panel data, you can follow these steps:

  1. Import the required packages and classes:
import numpy as np
import pandas as pd
from power_analysis import PanelBootstrap
  1. Load your panel data into a pandas DataFrame:
data = pd.read_csv('your_data.csv')
  1. Create a PanelBootstrap object with the required parameters:
power_analysis = PanelBootstrap(data, outcome_var='outcome', treatment_var='treatment', individual_var='individual', random_seed=42)
  1. Use the fit_model method to fit a linear regression model and obtain the treatment effect and p-value:
treatment_effect, p_value = power_analysis.fit_model(data)
  1. Perform a clustered bootstrap analysis to obtain the mean effect size, standard deviation of effect sizes, and a list of p-values:
mean_effect_size, std_effect_size, p_values = power_analysis.clustered_bootstrap(n_bootstrap=1000)
  1. Calculate the statistical power when varying the number of observations (N) or effect sizes:
n_values = [50, 100, 150, 200, 250, 300]
alpha = 0.05
n_bootstrap = 1000

power_by_n = power_analysis.calculate_power_by_n(n_values, alpha, n_bootstrap)
power_by_effect_size = power_analysis.calculate_power_by_effect_size(effect_sizes, alpha, n_bootstrap)

Contributing 🤝

Contributions to power-analysis are welcome! If you find a bug or would like to suggest a new feature, please open an issue on GitHub.

License 📜

power-analysis is licensed under the MIT license. See LICENSE for more information.

Metadata

Release files for power-analysis 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for power-analysis 0.1.5
File Size Uploaded Provenance Actions
power_analysis-0.1.5.tar.gz 5.2 kB Without provenance Details for power_analysis-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for power-analysis 0.1.5
File Interpreter ABI Platform Actions
power_analysis-0.1.5-py3-none-any.whl Python 3 none any Details for power_analysis-0.1.5-py3-none-any.whl

Total release size: 11.8 kB

Release files / power_analysis-0.1.5.tar.gz

Download URL power_analysis-0.1.5.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bfabdb8f752120a882708469d919d879bb60b697a23fe1261691f802a9cfd54f
BLAKE2b-256 checksum
How to use checksums
050a6b915f469371b62d8beb60579e7ee441bbd0e31d4297a3f565cd4631a400
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.8 Windows/10

Release files / power_analysis-0.1.5-py3-none-any.whl

Download URL power_analysis-0.1.5-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f17c17d44c13381ee97231f46ac641a420320c1ffc0cc6b0efc3c7b54d1f8a4
BLAKE2b-256 checksum
How to use checksums
9201e7360cd621404c75090edddbe1619cac8171fe1ce7853202fe0793bcb056
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.8 Windows/10

Security for power-analysis 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page