# Statistics Lab mathematics M7 - fictional calculation
mu0 <- 70; sigma <- 10; n <- 25; xbar <- 74
z <- (xbar - mu0)/(sigma/sqrt(n))
p_two_sided <- 2*pnorm(abs(z), lower.tail=FALSE)
c(z=z, p_value=p_two_sided)
# Illustrative power if true mean were 74 at alpha = 0.05
se <- sigma/sqrt(n)
cut <- qnorm(0.975)*se
power <- pnorm(mu0-cut, mean=74, sd=se) +
  pnorm(mu0+cut, mean=74, sd=se, lower.tail=FALSE)
power
