Challenge - 5 Problems
Confidence Interval Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Calculate 95% confidence interval for mean
What is the output of this R code that calculates a 95% confidence interval for the mean of a numeric vector?
R Programming
data <- c(5, 7, 8, 6, 9) mean_val <- mean(data) std_err <- sd(data) / sqrt(length(data)) conf_int <- mean_val + c(-1, 1) * qt(0.975, df=length(data)-1) * std_err round(conf_int, 2)
Attempts:
2 left
💡 Hint
Remember to use the t-distribution quantile for the confidence interval with small samples.
✗ Incorrect
The code calculates the mean and standard error, then uses the t-distribution quantile for 95% confidence with 4 degrees of freedom. The resulting interval is [5.04, 8.96].
🧠 Conceptual
intermediate1:30remaining
Interpretation of confidence interval
Which statement correctly describes the meaning of a 95% confidence interval for a population mean?
Attempts:
2 left
💡 Hint
Think about what happens if you take many samples and calculate intervals each time.
✗ Incorrect
A 95% confidence interval means that if we repeat the sampling process many times, about 95% of those intervals will contain the true population mean. It does not mean the probability for a single interval.
❓ Predict Output
advanced2:00remaining
Confidence interval for proportion
What is the output of this R code that calculates a 90% confidence interval for a proportion using the normal approximation?
R Programming
x <- 45 n <- 100 p_hat <- x / n z <- qnorm(0.95) se <- sqrt(p_hat * (1 - p_hat) / n) conf_int <- p_hat + c(-1, 1) * z * se round(conf_int, 3)
Attempts:
2 left
💡 Hint
Use the z-score for 90% confidence and calculate standard error for proportion.
✗ Incorrect
The sample proportion is 0.45. The z-score for 90% confidence is about 1.645. The standard error is sqrt(p*(1-p)/n). The interval is [0.368, 0.532].
🔧 Debug
advanced2:00remaining
Identify error in confidence interval code
What error does this R code produce when calculating a 95% confidence interval for the mean?
R Programming
data <- c(10, 12, 14, 16, 18) mean_val <- mean(data) std_err <- sd(data) / length(data) conf_int <- mean_val + c(-1, 1) * qt(0.975, df=length(data)-1) * std_err conf_int
Attempts:
2 left
💡 Hint
Check the formula for standard error of the mean.
✗ Incorrect
Standard error should be sd(data) divided by the square root of sample size, not by the sample size itself. This makes the interval too narrow and misleading.
🚀 Application
expert3:00remaining
Calculate and interpret confidence interval for difference of means
Given two independent samples, what is the 95% confidence interval for the difference of their means? Use this R code and select the correct output.
R Programming
group1 <- c(20, 22, 19, 24, 21) group2 <- c(18, 17, 20, 16, 19) mean_diff <- mean(group1) - mean(group2) se_diff <- sqrt(var(group1)/length(group1) + var(group2)/length(group2)) t_val <- qt(0.975, df=min(length(group1), length(group2)) - 1) conf_int <- mean_diff + c(-1, 1) * t_val * se_diff round(conf_int, 2)
Attempts:
2 left
💡 Hint
Calculate difference of means, standard error of difference, then use t-value for confidence interval.
✗ Incorrect
The difference of means is 21.2 - 18 = 3.2. The standard error of difference is about 1.11. Using t-value ~2.776 for df=4, the interval is [0.11, 6.29].