## Transcribed Text

Some have argued that the F test for equality of variances should be used to decide whether to use the pooled
t-test or the non-pooled t-test. Others have argued that the variances should never be assumed to be exactly
equal, and the non-pooled t-test should always be used. You will explore this here via simulation.
We will consider testing the following hypotheses (using either a pooled or a non-pooled t-test) at the 5%
level.
H0: µ1 - µ2 = 0
H1: µ1 - µ2 ¹ 0
Assume that we take independent simple random samples of size 20 from each of two populations. The
populations are N(0,12) and a N(µ,52). Use a simulation-based method to plot the power curves for the pooled
and non-pooled t-tests (on the same graph) as a function of a sequence of µ values from -5 to 5.
mu.vals <- seq(-5,5,by=.25)
nsim <- 10000
reject.mat.pooled <- matrix(NA,length(mu.vals),nsim)
reject.mat.nonpooled <- matrix(NA,length(mu.vals),nsim)
for (i in 1:length(mu.vals)){
sim.mat1 <- matrix(rnorm(nsim*20,mean=0,sd=1),nrow=nsim,ncol=20)
sim.mat2 <- matrix(rnorm(nsim*20,mean=mu.vals[i],sd=5),nrow=nsim,ncol=20)
reject.mat.pooled[i,] <- unlist(lapply(1:nsim,FUN=function(x){
pval1<-t.test(sim.mat1[x,],sim.mat2[x,],alt="two.sided",var.equal=TRUE)$p.value;ifelse(pval1<.05,1,0)}))
reject.mat.nonpooled[i,] <- unlist(lapply(1:nsim,FUN=function(x){
pval1<-t.test(sim.mat1[x,],sim.mat2[x,],alt="two.sided",var.equal=FALSE)$p.value;ifelse(pval1<.05,1,0)}))
}
power.vals.pooled <- rowMeans(reject.mat.pooled)
power.vals.nonpooled <- rowMeans(reject.mat.nonpooled)
plot(c(-5,5),c(0,1),type="n",xlab="True Difference in Means",ylab="Approx Prob of Rejecting")
lines(mu.vals,power.vals.pooled)
lines(mu.vals,power.vals.nonpooled,col="blue",lty=2)
abline(h=.05,lty=2,col="red")
1. Which test would you recommend using, the pooled or non-pooled test? Why? Base your answer on the
power curves plotted above?
2. Now, assume that the two populations are N(0,12
) and a N(µ,12).
a) Use a simulation-based method to plot the power curves for the pooled and non-pooled t-tests (on the
same graph) as a function of a sequence of µ values from -5 to 5. You may want to use portions of the above R
code.
b) When the populations are N(0,12
) and a N(µ,12
), which test would you recommend using, the pooled or
non-pooled test? Why? Base your answer on the power curves plotted above?
3. Now, assume that the two populations are N(0,12) and a N(µ,102).
a) Use a simulation-based method to plot the power curves for the pooled and non-pooled t-tests (on the
same graph) as a function of a sequence of µ values from -5 to 5. You may want to use portions of the above R
code.
b) When the populations are N(0,12
) and a N(µ,102
), which test would you recommend using, the pooled or
non-pooled test? Why? Base your answer on the power curves plotted above?
4. If you have no idea whether the variances are equal or not, which test do you recommend based on your
answers for 1-3? Explain your answer.

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.