In: Statistics and Probability
Suppose X1, . . . , Xn is a random sample from the Normal(μ, σ2) distribution, where μ is unknown but σ2 is known, and it is of interest 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 of values of μ, the code computes the probability that the null hypothesis will be rejected according to the above test. In addition, for each value of μ in the sequence, a simulation is run: 100 data sets with sample size n are generated from the Normal(μ,σ2) distribution, and for each of the 100 data sets, it is recorded whether the null hypothesis was rejected. For each value of μ, the proportion of times the null hypothesis is rejected is recorded. 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 closely but 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 α of the 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 α of the test were increased?
(h) What would be the effect on the dashed line of generating 500 data sets instead of only 100 data sets for the simulation at each value of μ?
Here
n =25
If : -0.3 0.3
otherwise
Probability of a Standard normal distribution provides variance between 0 and 1.
In standard distribution mean will be zero and Z mean value =0.5 and Z value will always measured from left to right.
Z1(1.5) is right hand side of Z table right curve. will always be more than mean value. The covered area of Z(1.5) will be meansered from left to right. So, that area was 93.32%
Z2(-1.5), which is less than Mean value and data coveres less than half of the area. Using Left hand Z table value of 1.5 =0.9332
The area of probability is covered between -0.3 and 0.3 and mean value is 0. So, Probability of area covered between which is P(Z1) is area covred from 0 to 93.32%. Means from Left hand to right hand of Standard distribution.
# Example : This is equal to P(Z < 1.96) - P(Z < -1.96) = F(1.96) - F(-1.96) = F(1.96) - (1 - F(1.96)) = 2 F(1.96) - 1
Probability of type 1 error of the test that accepts H0 :
Probability of (-0.3 0.3) = P( Xn0.3)-P(Xn-0.3)
= P(0.3) -(1-P(0.3))
= 0.9332-(1-0.9332)
= 2*0.9332- 1
= 0.8664