Title: | Power and Sample Size Calculations for Completely Randomized and Rerandomized Experiments |
---|---|
Description: | Computes the power resulting from completely randomized and rerandomized experiments with two groups. Furthermore, computes the sample size necessary to obtain a desired level of power for completely randomized and rerandomized experiments. |
Authors: | Zach Branson [aut, cre], Xinran Li [aut] |
Maintainer: | Zach Branson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1 |
Built: | 2024-12-11 06:46:09 UTC |
Source: | CRAN |
power.rand
computes the power of the mean-difference estimator for a completely randomized experiment with two treatment groups. The power depends on the sample size in each group, the potential outcome variation in each group, the variation of individual treatment effects (i.e., treatment effect heterogeneity), and the magnitude of the average treatment effect.
power.rand(N1, N0, s1, s0, s.tau = 0, tau, alpha = 0.05, exact = FALSE)
power.rand(N1, N0, s1, s0, s.tau = 0, tau, alpha = 0.05, exact = FALSE)
N1 |
The number of subjects in the treatment group. |
N0 |
The number of subjects in the control group. |
s1 |
Standard deviation of the potential outcomes in the treatment group. |
s0 |
Standard deviation of the potential outcomes in the control group. |
s.tau |
Standard deviation of individual treatment effects. The default is 0, denoting an additive treatment effect. |
tau |
Magnitude of the average treatment effect. |
alpha |
Level at which we reject the null. The default is 0.05. |
exact |
Whether power is computed exactly or approximately. As shown in Theorem 1 of Branson, Li, and Ding (2022), power is the sum of the right-tail of a Normal distribution (which is usually large) and the left-tail (which is usually small). When exact = FALSE, power equals just the right-tail, which corresponds to the right-hand bound in Theorem 1 of Branson, Li, and Ding (2022). When exact = TRUE, power equals the sum, which corresponds to the left-hand side of Theorem 1. The default is FALSE. |
The power of the mean-difference estimator for a completely randomized experiment with two treatment groups. In other words, the probability that we reject the null hypothesis of no treatment effect (when there truly is a treatment effect), given particular settings for a randomized experiment.
Zach Branson
Branson, Z., Li, X., and Ding, P. (2022). Power and Sample Size Calculations for Rerandomized Experiments.
#Power when 100 subjects are in each group, #the standard deviation is 4 in each group, #and the average treatment effect is 2. power.rand(N1 = 100, N0 = 100, s1 = 4, s0 = 4, tau = 2) #same as before, but when #the average treatment effect is 0.8. power.rand(N1 = 100, N0 = 100, s1 = 4, s0 = 4, tau = 0.8) #The same examples as above, #but now with treatment effect heterogeneity. #We set the standard deviation of treatment effects #to be that of potential outcomes. #Note that, compared to the previous examples, #power increases for large treatment effects but #decreases for small treatment effects. #This phenomenon is discussed in Branson, Li, and Ding (2022). power.rand(N1 = 100, N0 = 100, s1 = 4, s0 = 4, s.tau = 4, tau = 2) #same as before, but when #the average treatment effect is 0.8. power.rand(N1 = 100, N0 = 100, s1 = 4, s0 = 4, s.tau = 4, tau = 0.8)
#Power when 100 subjects are in each group, #the standard deviation is 4 in each group, #and the average treatment effect is 2. power.rand(N1 = 100, N0 = 100, s1 = 4, s0 = 4, tau = 2) #same as before, but when #the average treatment effect is 0.8. power.rand(N1 = 100, N0 = 100, s1 = 4, s0 = 4, tau = 0.8) #The same examples as above, #but now with treatment effect heterogeneity. #We set the standard deviation of treatment effects #to be that of potential outcomes. #Note that, compared to the previous examples, #power increases for large treatment effects but #decreases for small treatment effects. #This phenomenon is discussed in Branson, Li, and Ding (2022). power.rand(N1 = 100, N0 = 100, s1 = 4, s0 = 4, s.tau = 4, tau = 2) #same as before, but when #the average treatment effect is 0.8. power.rand(N1 = 100, N0 = 100, s1 = 4, s0 = 4, s.tau = 4, tau = 0.8)
power.rerand
computes the power of the mean-difference estimator for a rerandomized experiment with two treatment groups, where the Mahalanobis distance is constrained to be below a prespecified threshold. The power depends on the sample size in each group, the potential outcome variation in each group, the variation of individual treatment effects (i.e., treatment effect heterogeneity), the magnitude of the average treatment effect, the number of covariates, the linear association between covariates and potential outcomes, and the acceptance probability used for rerandomization.
power.rerand(N1, N0, s1, s0, s.tau = 0, tau, alpha = 0.05, K, pa, R2, exact = FALSE)
power.rerand(N1, N0, s1, s0, s.tau = 0, tau, alpha = 0.05, K, pa, R2, exact = FALSE)
N1 |
The number of subjects in the treatment group. |
N0 |
The number of subjects in the control group. |
s1 |
Standard deviation of the potential outcomes in the treatment group. |
s0 |
Standard deviation of the potential outcomes in the control group. |
s.tau |
Standard deviation of individual treatment effects. The default is 0, denoting an additive treatment effect. |
tau |
Magnitude of the average treatment effect. |
alpha |
Level at which we reject the null. The default is 0.05. |
K |
The number of covariates. |
pa |
The acceptance probability used for rerandomization. |
R2 |
The R-squared between covariates and potential outcomes. |
exact |
Whether power is computed exactly or approximately. As shown in Theorem 3 of Branson, Li, and Ding (2022), power is the sum of the right-tail of a non-Normal distribution (which is usually large) and the left-tail (which is usually small). When exact = FALSE, power equals just the right-tail, which corresponds to the right-hand bound in Theorem 3 of Branson, Li, and Ding (2022). When exact = TRUE, power equals the sum, which corresponds to the left-hand side of Theorem 3. The default is FALSE. |
The power of the mean-difference estimator for a rerandomized experiment with two treatment groups, where the Mahalanobis distance is constrained to be below a prespecified threshold. In other words, the probability that we reject the null hypothesis of no treatment effect (when there truly is a treatment effect), given particular settings for a rerandomized experiment.
Zach Branson
Branson, Z., Li, X., and Ding, P. (2022). Power and Sample Size Calculations for Rerandomized Experiments.
#Power when 50 subjects are in each group, #the standard deviation is 4 in each group, #the average treatment effect is 2, #there are 10 covariates, #covariates are moderately related with outcomes, #and the acceptance probability is 0.01. power.rerand(N1 = 50, N0 = 50, s1 = 4, s0 = 4, tau = 2, K = 10, pa = 0.01, R2 = 0.3) #same as before, but when #the average treatment effect is 0.8. power.rerand(N1 = 50, N0 = 50, s1 = 4, s0 = 4, tau = 0.8, K = 10, pa = 0.01, R2 = 0.3) #The same examples as above, #but now with treatment effect heterogeneity. #We set the standard deviation of treatment effects #to be that of potential outcomes. #Note that, compared to the previous examples, #power increases for large treatment effects but #decreases for small treatment effects. #This phenomenon is discussed in Branson, Li, and Ding (2022). power.rerand(N1 = 50, N0 = 50, s1 = 4, s0 = 4, s.tau = 4, tau = 2, K = 10, pa = 0.01, R2 = 0.3) #same as before, but when #the average treatment effect is 0.8. power.rerand(N1 = 50, N0 = 50, s1 = 4, s0 = 4, s.tau = 4, tau = 0.8, K = 10, pa = 0.01, R2 = 0.3)
#Power when 50 subjects are in each group, #the standard deviation is 4 in each group, #the average treatment effect is 2, #there are 10 covariates, #covariates are moderately related with outcomes, #and the acceptance probability is 0.01. power.rerand(N1 = 50, N0 = 50, s1 = 4, s0 = 4, tau = 2, K = 10, pa = 0.01, R2 = 0.3) #same as before, but when #the average treatment effect is 0.8. power.rerand(N1 = 50, N0 = 50, s1 = 4, s0 = 4, tau = 0.8, K = 10, pa = 0.01, R2 = 0.3) #The same examples as above, #but now with treatment effect heterogeneity. #We set the standard deviation of treatment effects #to be that of potential outcomes. #Note that, compared to the previous examples, #power increases for large treatment effects but #decreases for small treatment effects. #This phenomenon is discussed in Branson, Li, and Ding (2022). power.rerand(N1 = 50, N0 = 50, s1 = 4, s0 = 4, s.tau = 4, tau = 2, K = 10, pa = 0.01, R2 = 0.3) #same as before, but when #the average treatment effect is 0.8. power.rerand(N1 = 50, N0 = 50, s1 = 4, s0 = 4, s.tau = 4, tau = 0.8, K = 10, pa = 0.01, R2 = 0.3)
sampleSize.rand
computes the sample size needed to obtain a desired level of power when we use the mean-difference estimator for a completely randomized experiment with two groups. The sample size depends on the proportion of subjects assigned to each group, the potential outcome variation in each group, the variation of individual treatment effects (i.e., treatment effect heterogeneity), and the magnitude of the average treatment effect.
sampleSize.rand(power = 0.8, p1 = 0.5, p0 = 0.5, s1, s0, s.tau = 0, tau, alpha = 0.05)
sampleSize.rand(power = 0.8, p1 = 0.5, p0 = 0.5, s1, s0, s.tau = 0, tau, alpha = 0.05)
power |
The desired level of power, ranging between 0 and 1. The default is 0.8. |
p1 |
The proportion of subjects in the treatment group. The default is 0.5. |
p0 |
The proportion of subjects in the control group. The default is 0.5. |
s1 |
Standard deviation of the potential outcomes in the treatment group. |
s0 |
Standard deviation of the potential outcomes in the control group. |
s.tau |
Standard deviation of individual treatment effects. The default is 0, denoting an additive treatment effect. |
tau |
Magnitude of the average treatment effect. |
alpha |
Level at which we reject the null. The default is 0.05. |
The sample size needed to obtain a desired level of power when we use the mean-difference estimator for a completely randomized experiment with two groups. In other words, given a particular power
, this yields the sample size such that the probability we reject the null hypothesis of no treatment effect (when there truly is a treatment effect) is equal to power
.
Zach Branson
Branson, Z., Li, X., and Ding, P. (2022). Power and Sample Size Calculations for Rerandomized Experiments.
#The sample size needed for 0.8 power when #the standard deviation is 4 in each group, #and the average treatment effect is 2. sampleSize.rand(s1 = 4, s0 = 4, tau = 2) #same as before, but when #the average treatment effect is 0.8. sampleSize.rand(s1 = 4, s0 = 4, tau = 0.8) #The same examples as above, #but now with treatment effect heterogeneity. #We set the standard deviation of treatment effects #to be that of potential outcomes. #Note that, compared to the previous examples, #sample size always decreases. #This will always happen when power > 0.5; #this is discussed in Branson, Li, and Ding (2022). sampleSize.rand(s1 = 4, s0 = 4, s.tau = 4, tau = 2) #same as before, but when #the average treatment effect is 0.8. sampleSize.rand(s1 = 4, s0 = 4, s.tau = 4, tau = 0.8)
#The sample size needed for 0.8 power when #the standard deviation is 4 in each group, #and the average treatment effect is 2. sampleSize.rand(s1 = 4, s0 = 4, tau = 2) #same as before, but when #the average treatment effect is 0.8. sampleSize.rand(s1 = 4, s0 = 4, tau = 0.8) #The same examples as above, #but now with treatment effect heterogeneity. #We set the standard deviation of treatment effects #to be that of potential outcomes. #Note that, compared to the previous examples, #sample size always decreases. #This will always happen when power > 0.5; #this is discussed in Branson, Li, and Ding (2022). sampleSize.rand(s1 = 4, s0 = 4, s.tau = 4, tau = 2) #same as before, but when #the average treatment effect is 0.8. sampleSize.rand(s1 = 4, s0 = 4, s.tau = 4, tau = 0.8)
sampleSize.rerand
computes the sample size needed to obtain a desired level of power when we use the mean-difference estimator for a rerandomized experiment with two groups, where the Mahalanobis distance is constrained to be below a prespecified threshold. The sample size depends on the proportion of subjects assigned to each group, the potential outcome variation in each group, the variation of individual treatment effects (i.e., treatment effect heterogeneity), the magnitude of the average treatment effect, the number of covariates, the linear association between covariates and potential outcomes, and the acceptance probability used for rerandomization.
sampleSize.rerand(power = 0.8, p1 = 0.5, p0 = 0.5, s1, s0, s.tau = 0, tau, alpha = 0.05, K, pa, R2)
sampleSize.rerand(power = 0.8, p1 = 0.5, p0 = 0.5, s1, s0, s.tau = 0, tau, alpha = 0.05, K, pa, R2)
power |
The desired level of power, ranging between 0 and 1. The default is 0.8. |
p1 |
The proportion of subjects in the treatment group. The default is 0.5. |
p0 |
The proportion of subjects in the control group. The default is 0.5. |
s1 |
Standard deviation of the potential outcomes in the treatment group. |
s0 |
Standard deviation of the potential outcomes in the control group. |
s.tau |
Standard deviation of individual treatment effects. The default is 0, denoting an additive treatment effect. |
tau |
Magnitude of the average treatment effect. |
alpha |
Level at which we reject the null. The default is 0.05. |
K |
The number of covariates. |
pa |
The acceptance probability used for rerandomization. |
R2 |
The R-squared between covariates and potential outcomes. |
The sample size needed to obtain a desired level of power when we use the mean-difference estimator for a rerandomized experiment with two groups, where the Mahalanobis distance is constrained to be below a prespecified threshold. In other words, given a particular power
, this yields the sample size such that the probability we reject the null hypothesis of no treatment effect (when there truly is a treatment effect) is equal to power
.
Zach Branson
Branson, Z., Li, X., and Ding, P. (2022). Power and Sample Size Calculations for Rerandomized Experiments.
#The sample size needed for 0.8 power when #the standard deviation is 4 in each group, #the average treatment effect is 2, #there are 50 covariates, and R2 = 0.3. sampleSize.rerand(s1 = 4, s0 = 4, tau = 2, K = 50, R2 = 0.3, pa = 0.01) #same as before, but when #the average treatment effect is 0.8. sampleSize.rerand(s1 = 4, s0 = 4, tau = 0.8, K = 50, R2 = 0.3, pa = 0.01) #The same examples as above, #but now with treatment effect heterogeneity. #We set the standard deviation of treatment effects #to be that of potential outcomes. #Note that, compared to the previous examples, #sample size always decreases. #This will always happen when power > 0.5; #this is discussed in Branson, Li, and Ding (2022). sampleSize.rerand(s1 = 4, s0 = 4, s.tau = 4, tau = 2, K = 50, R2 = 0.3, pa = 0.01) #same as before, but when #the average treatment effect is 0.8. sampleSize.rerand(s1 = 4, s0 = 4, s.tau = 4, tau = 0.8, K = 50, R2 = 0.3, pa = 0.01)
#The sample size needed for 0.8 power when #the standard deviation is 4 in each group, #the average treatment effect is 2, #there are 50 covariates, and R2 = 0.3. sampleSize.rerand(s1 = 4, s0 = 4, tau = 2, K = 50, R2 = 0.3, pa = 0.01) #same as before, but when #the average treatment effect is 0.8. sampleSize.rerand(s1 = 4, s0 = 4, tau = 0.8, K = 50, R2 = 0.3, pa = 0.01) #The same examples as above, #but now with treatment effect heterogeneity. #We set the standard deviation of treatment effects #to be that of potential outcomes. #Note that, compared to the previous examples, #sample size always decreases. #This will always happen when power > 0.5; #this is discussed in Branson, Li, and Ding (2022). sampleSize.rerand(s1 = 4, s0 = 4, s.tau = 4, tau = 2, K = 50, R2 = 0.3, pa = 0.01) #same as before, but when #the average treatment effect is 0.8. sampleSize.rerand(s1 = 4, s0 = 4, s.tau = 4, tau = 0.8, K = 50, R2 = 0.3, pa = 0.01)