Simple Individual Random Assignment (IRA)¶
Assignment | Clustering Level | Treatment Assignment | Treatment Level | Cluster Effect |
---|---|---|---|---|
simple | 1 | individual | 1 | NA |
[1]:
from pypowerup import effect_size, power, sample_size
[2]:
# effect size, i.e., minimum detectable effect sizes (MDES):
effect_size(design='ira', n=787, power=0.8, alpha=0.05, two_tailed=True, p=0.5, r21=0, g=0)
[2]:
0.19997988869985736
[3]:
# sample size, i.e., minimum required samples sizes (MRSS):
sample_size(design='ira', es=0.2, power=0.8, alpha=0.05, two_tailed=True, p=0.5, r21=0, g=0)
[3]:
787.0
[4]:
# power
power(design='ira', es=0.2, n=787, alpha=0.05, two_tailed=True, p=0.5, r21=0, g=0)
[4]:
0.8000799952735076
Parameters for IRA
Parameters | effect_size |
sample_size |
power |
---|---|---|---|
design | ✓ | ✓ | ✓ |
es | ✓ | ✓ | |
n | ✓ | ✓ | |
power | ✓ | ✓ | |
alpha | ✓ | ✓ | ✓ |
two_tailed | ✓ | ✓ | ✓ |
p | ✓ | ✓ | ✓ |
r21 | ✓ | ✓ | ✓ |
g | ✓ | ✓ | ✓ |
Output validation with statsmodels
Here we used statsmodels
with the same parameters to validate our model results. Note nobs1 in statsmodels
is the sample size for treatment group, which is half of the total sample size output from our model. Thus, we define nobs1=787/2=393.5
in the models beflow.
[5]:
from statsmodels.stats.power import TTestIndPower
[6]:
# effect size
analysis = TTestIndPower()
analysis.solve_power(power=0.8, nobs1=393.5, ratio=1, alpha=0.05, alternative='two-sided')
[6]:
0.19997768751017836
[7]:
# sample size (statsmodels output treatment sample size only, which is the half of our computed total sample size)
analysis.solve_power(0.2, power=0.8, nobs1=None, ratio=1, alpha=0.05,alternative='two-sided')
[7]:
393.4056989990335
[8]:
# power
analysis.solve_power(0.2, nobs1=393.5, ratio=1.0, alpha=0.05, alternative='two-sided')
[8]:
0.8000942129794306
With the same parameters, we get the same results as the statsmodels
. However, statsmodels
does not do power analysis for more complicated designs, which we will cover next.