Interval Estimate of Population Mean with Known Variance
Let us denote the 100(1 −α∕2) percentile of the standard normal distribution as zα∕2. For random sample of sufficiently large size, the end points of the interval estimate at (1 − α) confidence level is given as follows:
Assume the population standard deviation σ of the student height in survey is 9.48. Find the margin of error and interval estimate at 95% confidence level.
We first filter out missing values in survey$Height with the na.omit function, and save it in height.response.
Then we compute the standard error of the mean.
> sigma = 9.48 # population standard deviation
> sem = sigma/sqrt(n); sem # standard error of the mean
Since there are two tails of the normal distribution, the 95% confidence level would imply the 97.5th percentile of the normal distribution at the upper tail. Therefore, zα∕2 is given by qnorm(.975). We multiply it with the standard error of the mean sem and get the margin of error.
We then add it up with the sample mean, and find the confidence interval as told.
Assuming the population standard deviation σ being 9.48, the margin of error for the student height survey at 95% confidence level is 1.2852 centimeters. The confidence interval is between 171.10 and 173.67 centimeters.
Instead of using the textbook formula, we can apply the z.test function in the TeachingDemos package. It is not a core R package, and must be installed and loaded into the workspace beforehand.
> z.test(height.response, sd=sigma)
One Sample z−test
z = 262.88, n = 209.000, Std. Dev. = 9.480,
Std. Dev. of the sample mean = 0.656, p−value < 2.2e−16
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
mean of height.response