The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Confidence interval for a mean

This document is prepared automatically using the following R command.

Problem

Confidence interval of mean

The approach that we used to solve this problem is valid when the following conditions are met.

Since the above requirements are satisfied, we can use the following four-step approach to construct a confidence interval of mean.

Raw data

The first 10 rows of the provided data is as follows.

# A tibble: 10 × 1
     mpg
   <dbl>
 1  21  
 2  21  
 3  22.8
 4  21.4
 5  18.7
 6  18.1
 7  14.3
 8  24.4
 9  22.8
10  19.2

Sample statistics

The sample size is 32, the sample mean is 20.09 and the standard error of sample is 6.03. The confidence level is 95 %.

Find the margin of error

Since we do not know the standard deviation of the population, we cannot compute the standard deviation of the sample mean; instead, we compute the standard error (SE). Because the sample size is much smaller than the population size, we can use the “approximate” formula for the standard error.

\[ SE= \frac{s}{\sqrt{n}}\] where s is the standard deviation of the sample, n is the sample size.

\[SE=\frac{6.03}{\sqrt{32}}=1.07\] Find the critical probability(p*):

\[p*=1-\alpha/2=1-0.05/2=0.975\]

The degree of freedom(df) is: \[df=n-1=32-1=31\]

The critical value is the t statistic having 31 degrees of freedom and a cumulative probability equal to 0.975. From the t Distribution table, we find that the critical value is 2.04.

\[qt(p,df)=qt(0.975,31)=2.04\]

The graph shows the \(\alpha\) values are the tail areas of the distribution.

Compute margin of error(ME):

\[ME=critical\ value \times SE\] \[ME=2.04 \times 1.065=2.173\]

Specify the confidence interval. The range of the confidence interval is defined by the sample statistic \(\pm\)margin of error. And the uncertainty is denoted by the confidence level.

Confidence interval of the mean

Therefore, the 95% confidence interval is 17.92 to 22.26. That is, we are 95% confident that the true population mean is in the range 17.92 to 22.26.

Plot

You can visualize the mean difference:

Result of meanCI()


call: meanCI.data.frame(x = mtcars, mpg) 
method: One sample t-test 
alternative hypothesis:
   true mean  is not equal to  0 

Results
# A tibble: 1 × 7
  m        se     DF    lower    upper    t      p        
  <chr>    <chr>  <chr> <chr>    <chr>    <chr>  <chr>    
1 20.09062 1.0654 31    17.91768 22.26357 18.857 < 2.2e-16

Reference

The contents of this document are modified from StatTrek.com. Berman H.B., “AP Statistics Tutorial”, [online] Available at: https://stattrek.com/estimation/confidence-interval-mean.aspx?tutorial=AP URL[Accessed Data: 1/23/2022].

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.