Skip to main content

This package allows you to perform power analysis computations

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

power_analysis-0.1.5.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

power_analysis-0.1.5-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file power_analysis-0.1.5.tar.gz.

File metadata

  • Download URL: power_analysis-0.1.5.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.8 Windows/10

File hashes

Hashes for power_analysis-0.1.5.tar.gz
Algorithm Hash digest
SHA256 bfabdb8f752120a882708469d919d879bb60b697a23fe1261691f802a9cfd54f
MD5 a1b6262488625e6938e1ed643b68e199
BLAKE2b-256 050a6b915f469371b62d8beb60579e7ee441bbd0e31d4297a3f565cd4631a400

See more details on using hashes here.

File details

Details for the file power_analysis-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: power_analysis-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.8 Windows/10

File hashes

Hashes for power_analysis-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5f17c17d44c13381ee97231f46ac641a420320c1ffc0cc6b0efc3c7b54d1f8a4
MD5 9bb4886ff35d1ed38d2d94972f07b7a6
BLAKE2b-256 9201e7360cd621404c75090edddbe1619cac8171fe1ce7853202fe0793bcb056

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page