The 95% confidence interval for \(\beta_1\), (0.56, 0.74), means that we can say that the slope of length vs. doy (i.e., the elongation rate) is between those values with 95% confidence.
What’s with the confidence intervals for \(E(y_{new})\) (i.e., stem length) for a given day of the year? That is, what is the confidence interval of \(E(y_{new}|\mathbf{x})\)?
We are looking at \[\hat{\beta_0}+\hat{\beta_1}x_{new} \pm t_{dfe, 1-\alpha/2}s.e. (\hat{\beta_0}+\hat{\beta_1}x_{new}),\] where \(s.e.(\hat{\beta_0}+\hat{\beta_1}x_{new}) = \hat{\sigma}\sqrt{\frac{1}{n}+ \frac{(x-\hat\mu_x)^2}{(n-1)s_x^2}}\).
Note: Remember that \(E(y)\) is the mean of all potentially observable values of \(y\). That is why this interval is somewhat smaller than the prediction interval.
doy <-seq(min(data$doy), max(data$doy), by =1)estim <-predict(m, data.frame(doy), interval="confidence")fitted.data <-bind_cols(estim, doy =doy) fitted.data %>%ggplot(aes(doy, fit))+geom_point(aes(x = doy, y = stm.length_cm), data = data, color ='grey30')+geom_ribbon(aes(ymin = lwr, ymax = upr), fill ='grey60', alpha = .3)+geom_line()+labs(x ="Day of the year", y ="Stem length (cm)")+theme_classic()+theme(aspect.ratio =1)
Prediction uncertainty
What’s with the confidence intervals for \(y\) (i.e., stem length) for a given day of the year? What is the confidence interval of \(\mathbf{y}|\mathbf{x}\)?
Previously, we only had \(\text{Var}(\hat\beta)\). Now we have to include \(\text{Var}(\hat\varepsilon)\):