I have fitted a polynomial to a data set that I have. Thus I have obtained coefficients $\beta_i$ for $i=0,1,2$ and have a relationship of the form is $$Y=\beta_0+\beta_{1}X+\beta_{2}X^{2}+\varepsilon$$ between the predictor $X$ and the response $Y$, where $\varepsilon$ is the error term.
My question is about computing confidence intervals.
I can compute for each of the coefficients $\beta_i$ the confidence interval using the confint()
function from R. This gets me three (95%) confidence intervals $[a_0,b_0]$,$[a_1,b_1]$ and $[a_2,b_2]$ for $\beta_0$,$\beta_1$ and $\beta_2$.
Lets say I would like to predict the average value that I will obtain for $Y$ for a new sample point $x=0.25$, that is, I would like to know the confidence interval around this point.
Using the previously obtained confidence intervals for coefficients, I can compute that $x$ has to lie in (with probability 95%) in the interval $$[a_0+a_{1}0.25+a_{2}0.25^{2},b_0+b_{1}\tilde 0.25+b_{2}0.25^{2}].$$
Unfortunately, when I compare the values that I obtain in this way with the output of the R command predict(my_fitted_data, data.frame(x=0.25),interval = 'confidence')
, that interval is way smaller than the one I obtaind by computing the interval, as described, by hand.
Did I do anything wrong? If so, what?
Thank you.
vcov(my_fitted_data)
shows you the variance-covariance matrix of the parameter estimates,cov2cor(vcov(my_fitted_data))
the correlation matrix. Your approach ignores this correlation. $\endgroup$