Suppose X1, . . . , Xn is a random sample from the Normal(μ, σ2)distribution, where μ is unknown but σ2 is known, and it is ofinterest to test H0: μ = μ0 versus H1: μ ̸= μ0 for some value μ0.The R code below plots the power curve of the test
Reject H0 iff |√n(X ̄n − μ0)/σ| > zα/2
for user-selected values of μ0, n, σ, and α. For a sequence ofvalues of μ, the code computes the probability that the nullhypothesis will be rejected according to the above test. Inaddition, for each value of μ in the sequence, a simulation is run:100 data sets with sample size n are generated from theNormal(μ,σ2) distribution, and for each of the 100 data sets, it isrecorded whether the null hypothesis was rejected. For each valueof μ, the proportion of times the null hypothesis is rejected isrecorded. This gets plotted as a dashed line.
mu.0 <- ??? n <- ??? sigma <- ??? alpha <- ???
mu.seq <- seq(mu.0 - 5,mu.0 + 5,length=50) power.theoretical <- numeric() power.empirical <- numeric() for(j in 1:length(mu.seq))
{ power.theoretical[j] <- 1-(pnorm(qnorm(1-alpha/2)-sqrt(n)*(mu.seq[j] - mu.0)/sigma)
reject <- numeric()for(s in 1:100){
}
-pnorm(-qnorm(1-alpha/2)-sqrt(n)*(mu.seq[j] - mu.0)/sigma))
x <- rnorm(n,mu.seq[j],sigma)x.bar <- mean(x)
reject[s] <- abs(sqrt(n)*(x.bar-mu.0)/sigma) > qnorm(1-alpha/2)
power.empirical[j] <- mean(reject) }
plot(mu.seq,power.theoretical,type=\"l\",ylim=c(0,1),xlab=\"mu\",ylab=\"power\") lines(mu.seq, power.empirical,lty=2) abline(v=mu.0,lty=3) # vert line at null value abline(h=alpha,lty=3) # horiz line at size
(a) Putinμ0 =2,n=5,σ=2,andα=0.05andexecutethecode.Turnintheplot.
(b) Explain why the dashed line follows the solid line closelybut not exactly.
(c) Interpret the height of the solid line at μ = 4.
(d) Interpret the height of the solid line at μ = 2.
(e) Interpret the height of the dashed line at μ = 2.
(f) What would be the effect on the height of the solid line atμ = 4 if i. the sample size n were increased?
ii. the standard deviation σ were increased? iii. the size α ofthe test were increased?
(g) What would be the effect on the height of the solid line atμ = 2 if i. the sample size n were increased?
ii. the standard deviation σ were increased? iii. the size α ofthe test were increased?
(h) What would be the effect on the dashed line of generating500 data sets instead of only 100 data sets for the simulation ateach value of μ?