2024-03-21

Introduction to Interval Estimation

  • Interval estimation is a statistical technique used to estimate an unknown parameter of a population based on sample data.
  • It provides a range of plausible values for the parameter, along with a level of confidence in the estimate.
  • Example: Estimating the average height of students in a school using a sample of students.

Confidence Intervals for the Mean

  • Confidence intervals for the mean are commonly used in inferential statistics to estimate the population mean based on sample data.
  • The formula for calculating a confidence interval for the mean is: \[ \bar{x} \pm t_{\alpha/2} \left( \frac{s}{\sqrt{n}} \right) \],where \(\bar{x}\) is the sample mean, \(s\) is the sample standard deviation, \(n\) is the sample size, and \(t_{\alpha/2}\) is the critical value of the t-distribution for a given confidence level and degrees of freedom.
  • Example: Calculating a 95% confidence interval for the population mean height of students in a school.
# R code for confidence interval calculation
set.seed(123)
data <- rnorm(30, mean = 70, sd = 5)
mean(data) + c(-1, 1) * qt(0.975, df = length(data) - 1) * sd(data) / sqrt(length(data))
## [1] 67.93287 71.59610

Interpreting Confidence Intervals

  • Definition: A confidence interval is a range of values that is likely to contain the true population parameter.
  • Interpretation: If we were to repeat this study many times, we would expect the true population parameter to fall within the confidence interval in about 95% of the studies (for a 95% confidence level).
  • Example: A 95% confidence interval of (68.21, 72.12) means we are 95% confident that the true population mean falls within this interval.

Confidence Intervals for Proportions

  • Formula and calculation of confidence intervals for proportions.
  • Example: Calculating a 90% confidence interval for a population proportion.
# R code for confidence interval calculation for proportions
n <- 100
x <- 60
p_hat <- x / n
SE <- sqrt(p_hat * (1 - p_hat) / n)
p_hat + c(-1, 1) * qnorm(0.95) * SE
## [1] 0.519419 0.680581

Factors Affecting Interval Estimation

  • Sample Size: Larger samples lead to narrower confidence intervals, as they provide more information about the population.
  • Confidence Level: Higher confidence levels result in wider intervals, as they require a greater range of values to be included.
  • Example: Comparing the width of 90%, 95%, and 99% confidence intervals.

Scatter Plot with Trend Line

library(ggplot2)
plot_data <- mtcars
Scatter <- ggplot(plot_data, aes(x = mpg, y = disp)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE) +
  labs(title = "Scatter plot of mpg vs disp with trend line")

Scatter plot with Trend Line:

## `geom_smooth()` using formula = 'y ~ x'

Box Plot

# Box plot
box <- ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
  geom_boxplot() +
  labs(title = "Box plot of Sepal Length by Species")

Box plot:

Histogram

# Histogram

Histogram <- ggplot(diamonds, aes(x = price)) +
  geom_histogram(binwidth = 500) +
  labs(title = "Histogram of Diamond Prices")

Histogram:

3D Plotly Plot

# 3D Plotly Plot

x <- faithful$waiting
y <- faithful$eruptions
z <- rep(1, length(x))
p <- plot_ly(x = x, y = y, z = z, type = "scatter3d", mode = "markers")

3D Plot:

Mathematical Formulas in Interval Estimation

The formula for a confidence interval for the mean is given by:

\[ \bar{x} \pm t_{\alpha/2} \left( \frac{s}{\sqrt{n}} \right) \]

  • Where:

  • here \(\bar{x}\) is the sample mean,

  • here \(s\) is the sample standard deviation,

  • here \(n\) is the sample size,

  • here \(t_{\alpha/2}\) is the critical value from the t-distribution for the desired confidence level.

Formula for Confidence Interval for Proportions

The formula for a confidence interval for a proportion is: \[ \hat{p} \pm z_{\alpha/2} \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \]

  • Where:

  • here \(\hat{p}\) is the sample proportion,

  • here \(n\) is the sample size,

  • here \(z_{\alpha/2}\) is the critical value from the standard normal distribution for the desired confidence level.

Key Takeaways

  • Interval estimation is a fundamental concept in statistics that allows us to estimate unknown population parameters.
  • Confidence intervals provide a range of values within which we believe the true population parameter lies.
  • Factors such as sample size and confidence level impact the width of confidence intervals.
  • Understanding interval estimation is crucial for making informed decisions based on data.