What is a confidence interval?
Confidence is another term for probability in statistics. A confidence interval (CI) is the mean of your estimate plus and minus the variation in that estimate.
Confidence is another term for probability in statistics. A confidence interval (CI) is the mean of your estimate plus and minus the variation in that estimate.
The confidence interval for data which follows a standard normal distribution is:
\(CI = \bar{X} \pm \text{t*} \frac{\sigma}{\sqrt{n}}\)
Where:
In reality, the population values are usually unknown, so the population values need to be replaced with sample values. As a result, the formula is changed to:
\(CI = \hat{x} \pm \text{t*} \frac{s}{\sqrt{n}}\)
Where:
USAccDeaths Datasetdeaths_df <- tibble (
date = seq(from = as.Date("1973-01-01"),
to = as.Date("1978-12-01"),
by = "month"),
deaths = as.vector(USAccDeaths)
)
deaths_summary <- summary(USAccDeaths)
Goal: Estimate the pop. mean monthly accidental deaths with a 95% CI.
alpha <- 0.05 # 1-alpha = 95% confidence n <- length(USAccDeaths) sample_mean <- mean(USAccDeaths) sample_sd <- sd(USAccDeaths) # Calc margin of error using t-dist margin_error <- qt(1-alpha/2, df=n-1) * sample_sd/sqrt(n) # Calc confidence interval lower_ci <- sample_mean - margin_error upper_ci <- sample_mean + margin_error
8789 deaths per month8564, 9014]