
Nathaniel Z. answered 06/09/24
Ph.D. Candidate in Economics with 4+ Years of Teaching Experience
- var = (std dev)^2. In your case, sample_var <- 3^2
- t = (x - mu)/sigma. In your case, t <- (17.75 - 20)/(3/sqrt(30))
- P-value is the probability of observing a value larger than your test statistic because your alternative hypothesis is mu > 20. In R, pnorm(t) = 2*10^-5 (approximately)
- P-value < 0.05 so reject null
- lower <- 17.75 - 2.045*3/sqrt(30) and upper <- 17.75 + 2.045*3/sqrt(30)
You could use a T-distribution by changing pnorm() to tnorm(), but the differences between a T-distribution with 29 degrees of freedom (30-1) and a normal distribution are negligible.