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, and calculating sample sizes for two-sample t-tests.
Installation 📥
You can install the power_analysis
package using pip:
pip install power-analysis
Usage 🧑💻
To use the power-analysis
package, you first need to define a statistical model using a Python function that takes a sample size as input and returns the estimated effect size of the model. For example:
def my_model(n):
# define your model here
effect_size = ...
return effect_size
You can then create a Model
object using this function:
from power_analysis import Model
model = Model(my_model)
You can perform a power analysis for this model using the PowerAnalysis
class:
from power_analysis import PowerAnalysis
power_analysis = PowerAnalysis(model, n=100, alpha=0.05, power=0.8, effect_size=0.5, iterations=1000)
results = power_analysis.results()
This will calculate the minimum detectable effect and sample size required to achieve a power of 0.8 for the given model, starting with an initial sample size of 100.
You can also calculate the sample size required for a two-sample t-test using the TTestSampleSize
class:
from power_analysis import TTestSampleSize
mean_diff = 1.5
sd = 2.0
alpha = 0.05
power = 0.8
sample_size = TTestSampleSize(mean_diff, sd, alpha, power, n=None)
n = sample_size.result()
This will calculate the sample size required to achieve a power of 0.8 for a two-sample t-test with a difference in means of 1.5, a standard deviation of 2.0, and a significance level of 0.05.
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
Built Distribution
File details
Details for the file power_analysis-0.1.1.tar.gz
.
File metadata
- Download URL: power_analysis-0.1.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f96fad7e21d9398813ce673c926fef7585144f493d96837c3a2ce122b2c0c30 |
|
MD5 | 909ec01a03051152fedec0303daed109 |
|
BLAKE2b-256 | 9c24d3071b00e61aeec2bb9b9deb74bcf573e4e8b56c5e5fde1c8cd3e4056f26 |
File details
Details for the file power_analysis-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: power_analysis-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72f73fcedeb0a5cd8d2f94df24dc517a10b2ec1ad98338cf601076b099fe6bea |
|
MD5 | 6c4e66e2529a28a97349a73225e34f25 |
|
BLAKE2b-256 | 849d9c53f66eb3ac2256986c7bc458ad44b76e2b23c58be70ba45d343ef4e094 |