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.3.tar.gz
.
File metadata
- Download URL: power_analysis-0.1.3.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 772f7c8dec4661bf08c950a868e8e0bff4a0d53c5ec06ad7ed7e0f790a7b8bb3 |
|
MD5 | 44c8518a54b17d0aa42d133e44deaf23 |
|
BLAKE2b-256 | da15d7949d6cf3488de367be38461b5d56585e40f3e055a53b1c9051b887fe10 |
File details
Details for the file power_analysis-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: power_analysis-0.1.3-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b649683da52a0888a5861d02b85a7c2fad57325c053750a478d7b49e7345ec15 |
|
MD5 | c778c437d2a124738a0fa2f5d1969ac9 |
|
BLAKE2b-256 | 2f1af06bbb9e15e2199261d25ab97be35ce1ffcd2085af6c817761880c340d55 |