2024-06-04

Exploring Point Estimates and Confidence Intervals with Dataset ‘airquality’

  • A point estimate is used in inferential statistics, and serves as a value that we can calculate to approximate an unknown population parameter such as the population mean, standard deviation, variance, or proportion.
  • For the sake of this presentation, I will focus on how we can calculate the sample mean, which serves as the point estimate for the population mean. See Eq. Below:

\[ \bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i \]

Requirements of Confidence Intervals

  • To calculate a useful confidence interval, the data points from the sample must form a approximate normal distribution when plotted.

R Code for (x,y) values of Temp. Frequency Plot

  • Using the airquality dataset as an example, we will calculate the point estimate of the temperature on a given day in the span of months from May - Sept, using the data from airquality’s year as a sample. Below is shown how the x and y values for the coming plot were calculated. Note: The point estimate calculated here would be used to predict, for example, the temperature of a given day in the same span of months in a future year.
data(airquality)

x_values = (min(airquality$Temp):max(airquality$Temp))

y_values = numeric(length(x_values))

for (i in 1:length(x_values)) {
  y_values[i] = sum(airquality$Temp == x_values[i])
}

Temperature Frequency Plot

Can we form a confidence interval from this data?

  • Though somewhat left-skewed, the temperature frequency plot could most likely be treated as normally distributed, hence making it possible to calculate a point estimate and confidence interval on the sample. To calculate a confidence interval, we use the below formula:


\[ \mu = \bar{x} \pm Z \times \frac{\sigma}{\sqrt{n}} \]

Calculation confidence interval

  • To calculate the confidence interval for the population standard deviation, we will use the z critical value corresponding to the 90% confidence level, and n = 153 days for the sample size. The standard deviation calculation along with the full pop. mean confidence interval calculation are shown in the code below.
point_estimate = mean(airquality$Temp) #Point estimate = Sample mean
std_dev = sd(airquality$Temp)
z_score = 1.645

confidence_int = c(point_estimate - z_score * std_dev / sqrt(153),
                        point_estimate + z_score * std_dev / sqrt(153))

print(confidence_int)
[1] 76.62356 79.14114

Box and whisker plot of the temperatures in the dataset:

Comparing our confidence interval to the box and whisker plot of temperature data:

  • By comparing our calculated confidence interval to the box and whisker plot, we can observe that the confidence interval falls well within the interquartile range of the plot (Q3-Q1), meaning our point estimate and confidence interval are likely an accurate estimation of the true population mean.