Learn R Programming

powerSurvEpi (version 0.1.5)

powerWelchT: Power of Two-Sided Two Sample T Test With Unequal Variances And Unequal Sample Sizes

Description

Power of two-sided 2 sample t test with unequal variances and unequal sample sizes.

Usage

powerWelchT(
  n1, 
  n2, 
  meanDiff, 
  sd1, 
  sd2, 
  alpha = 0.05)

Value

power

Arguments

n1

sample size for group 1

n2

sample size for group 2

meanDiff

mean difference between 2 groups

sd1

standard deviation of group 1

sd2

standard deviation of group 2

alpha

Type I error rate

Details

The power formula is $$ power = Pr\left(|T| > t_{1-\alpha/2, \nu} | T \sim t_{\nu, \lambda}\right), $$ where \(\lambda\) is the noncentrality parameter of the t distribution with degree of freedom \(\nu\). \(t_{1-\alpha/2, \nu}\) is the upper \(100\alpha/2\) percentile of the t distribution with degree of freedom \(\nu\). \(\alpha\) is the significance level. The noncentrality parameter \(\lambda\) is defined as $$ \lambda = \frac{|\mu_1 - \mu_2|}{\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}}. $$

The degree \(\nu\) of freedom is the Satterthwaite approximation and is defined as $$ \nu = \frac{\left(\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}\right)^2}{ \frac{\left(\frac{\sigma_1^2}{n_1}\right)^2}{n_1-1} + \frac{\left(\frac{\sigma_2^2}{n_2}\right)^2}{n_2-1} } $$

Examples

Run this code
powerWelchT(
    n1 = 64, # sample size for group 1 
    n2 = 30, # sample size for group 2
    meanDiff = 1, # mean difference between 2 groups
    sd1 = 2, # SD of group 1
    sd2 = 1, # SD of group 2
    alpha = 0.05 # type I error rate
)
# 0.8918191

Run the code above in your browser using DataLab