If we use the same sampling method to select different samples and computed an interval estimate for each sample, we would expect the true population parameter ( \(\beta_1\) ) to fall within the interval estimates 95% of the time.
Confidence interval for \(\hat\beta_1\)
How do we calculate the confidence interval for the slope?
\[\hat\beta_1\pm t^*SE_{\hat\beta_1}\]
How do we calculate it in R?
In with the confint function:
mod <-lm(battery_percent ~ screen_time, data)summary(mod)
Call:
lm(formula = battery_percent ~ screen_time, data = data)
Residuals:
Min 1Q Median 3Q Max
-61.818 -17.353 2.546 19.108 115.720
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 68.150787 2.503928 27.218 < 2e-16 ***
screen_time -0.022447 0.008347 -2.689 0.00735 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 24.53 on 630 degrees of freedom
Multiple R-squared: 0.01135, Adjusted R-squared: 0.009781
F-statistic: 7.233 on 1 and 630 DF, p-value: 0.007349
There are ✌️ other types of confidence intervals we may want to calculate
The confidence interval for the mean response in \(y\) for a given \(x^*\) value
The confidence interval for an individual response\(y\) for a given \(x^*\) value
Why are these different? Which do you think is easier to estimate? It is harder to predict one response than to predict a mean response. What does this mean in terms of the standard error?
The SE of the prediction interval is going to be larger
Confidence intervals
confidence interval for\(\mu_y\) and prediction interval
\[ \hat{y}\pm t^* SE\]
\(\hat{y}\) is the predicted \(y\) for a given \(x^*\)
\(t^*\) is the critical value for the \(t_{n-2}\) density curve
\(SE\) takes ✌️ different values depending on which interval you’re interested in
\(SE_{\hat\mu}\)
\(SE_{\hat{y}}\)
Which will be larger?
Confidence intervals
confidence interval for\(\mu_y\) and prediction interval
\[\hat{y}\pm t^* SE\]
\(\hat{y}\) is the predicted \(y\) for a given \(x^*\)
\(t^*\) is the critical value for the \(t_{n-2}\) density curve
\(SE\) takes ✌️ different values depending on which interval you’re interested in
You are interested in the predicted Porsche Price for Porsche cars that have 50,000 miles previously driven on average. Calculate this value with an appropriate confidence interval.
You are interested in the predicted Porsche Price for a particular Porsche with 40,000 miles previously driven. Calculate this value with an appropriate confidence interval.