2024-03-18

Confidence Intervals

Confidence intervals (CI) provide a range of values which is estimated to contain a population parameter, like the mean, with a certain confidence level. It’s expressed as:

\[ CI = (\bar{x} - Z_{\frac{\alpha}{2}} \cdot \frac{\sigma}{\sqrt{n}}, \bar{x} + Z_{\frac{\alpha}{2}} \cdot \frac{\sigma}{\sqrt{n}}) \]

  • \(\bar{x}\) is the sample mean,
  • \(Z_{\frac{\alpha}{2}}\) is the critical value from the Z-distribution,
  • \(\sigma\) is the population standard deviation,
  • \(n\) is the sample size.

95% Confidence Intervals

Calculating Confidence Intervals for the Mean

To calculate a 95% confidence interval for the population mean when the population standard deviation is known, we use the Z-distribution:

\[ CI = (\bar{x} - 1.96 \cdot \frac{\sigma}{\sqrt{n}}, \bar{x} + 1.96 \cdot \frac{\sigma}{\sqrt{n}}) \]

For unknown population standard deviation and sample size less than 30, we use the t-distribution:

\[ CI = (\bar{x} - t_{\frac{\alpha}{2}, n-1} \cdot \frac{s}{\sqrt{n}}, \bar{x} + t_{\frac{\alpha}{2}, n-1} \cdot \frac{s}{\sqrt{n}}) \]

Confidence Interval of Murder in USArrest

Summary

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.800   4.075   7.250   7.788  11.250  17.400

Confidence Interval

##                2.5 %   97.5 %
## (Intercept) 6.550178 9.025822

Confidence Interval of Assault in USArrest

Summary

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    45.0   109.0   159.0   170.8   249.0   337.0

Confidence Interval

##                2.5 %   97.5 %
## (Intercept) 147.0757 194.4443

ggplot - Plot of Confidence Interval of Murder in USArrest

ggplot - Plot of Confidence Interval of Assault in USArrest

plotly - Plot of Confidence Interval of Murder in USArrest

plotly - Plot of Confidence Interval of Assault in USArrest

Further Analysis - Murder vs Assualt(ggplot)

Further Analysis - Murder vs Assualt(plotly)