There's more...

A valid question is whether we are losing power due to Welch's correction when the variances are the same. Intuition would suggest that Welch's should be worse than the standard t-test, even when the variances are the same. The t-test (its standard version) is a uniform that's very powerful to test, meaning that, for any possible alternative, it has the greatest power. How can we assess the loss in statistical power when we use Welch's test?

In this case, we will study what happens when we have two samples with different means (12 versus 10) and the same variance:

calc_power <- function(n,sd1,sd2,equalvar){
rejected <- 0
for (x in 1:100000){
data1 <- rnorm(n,12,sd1)
data2 <- rnorm(n,10,sd2)
result <- t.test(data1,data2,var.equal=equalvar)$p.value
if (result < 0.05){
rejected <- rejected + 1
}
}
return (rejected/100000)
}
print(paste("n=10 / sd1=2 / sd2=20/ effective power=",calc_power(10,2,2,TRUE)))
print(paste("n=10 / sd1=2 / sd2=20/ effective power=",calc_power(10,2,2,FALSE)))

The preceding code generates the following output of effective power:

The power here is the proportion of cases that have been rejected (we know that, since the means are different, we should be rejecting 100% of them). As we can see, the power is almost the same (for this alternative at least) when we use Welch's test with equal variances.

We can conclude that Welch's test works well when the variances are different, and almost as good as the t-test when the variances are the same.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.247.68