# Confidence intervals for regression interpretation

I have done linear regression and plotted the data, the regression line and also the confidence interval (for 95% confidence). However it seems that most of the data points fall outside the confidence interval. So how am I supposed to interpret the confidence interval. It cannot be I am 95% confident that the data point will be this close to the regression line since a lot more than 5% of the data points do not fall in that area. So what does it mean then?

• What do you mean exactly with confidence interval? A ci is usually calculated for estimates. In your case these are the beta coefficients which describe the effect of your expl. variables on your dependent variable. Sep 18, 2013 at 18:44
• I am using the code here students.ncl.ac.uk/tom.holderness/software/pythonlinearfit I guess I'm just asking how I interpret the confidence intervals in the plot Sep 18, 2013 at 18:50
• Can you clarify what you mean by confidence interval. It sounds to me like you have a confidence interval for the fitted model (the regression line), which would not include on average 95% of the observations or anything close to that value. There is a prediction interval for the OLS model which may be what you were expecting? Sep 18, 2013 at 19:07
• The calculation used to get the confidence interval is in the link from my previous comment. I'm just looking for an intuitive interpretation. Sep 18, 2013 at 19:15
• possible duplicate of Clarification on interpreting confidence intervals?
– Momo
Sep 18, 2013 at 19:28

There are two 95% CI you can derive from your data. One is the 95% CI of the regression line, which is the red one in the attached illustration. The code you provided is intended for plotting this 95% CI. Now, because it's for the line, not for the data points, as you get more data, the precision improves, and the band will narrow down. Your cited code is a somewhat special case because the sample size is only 7, so the 95% CI of the line happened to include about 90% of the data points; it's just a coincidence.

The interval that approximately includes 95% of the data points is shown below in green. I am not sure what it is called, but generally from what I have collected on this site, it should not be called confidence interval. I think you're looking to get these kind of lines, but have been using the incorrect code.

The one that matters more often is the red one. And for proper interpretation, other users have provided links to some useful posts.

• OK so the interpretation is that you can be 95% confident that the regression line is within that interval for those data points. Thanks Sep 18, 2013 at 19:35
• OP no, you cannot. The interpretation of a CI is subtle, follow the links above. @Penguin_Knight the second part of your answer is usually called the prediction interval and should not be called a CI. See robjhyndman.com/hyndsight/intervals
– Momo
Sep 18, 2013 at 19:40
• What are the green lines exactly? If they are intended to include 95% (or whatever) of the distribution, then they are not a confidence interval: they would be a tolerance interval. If they are intended to include a specified number of future (independent) points, they would be a form of prediction interval; and if they must include a given number of the data points, they must be related to empirical quantiles of the residuals. It is, however, unusual for any of these (except the last, perhaps) to consist of lines that are parallel either to the fit or to each other.
– whuber
Sep 18, 2013 at 19:41
• @whuber It's one of the default functions in SPSS graphical editor, called "Confidence Interval for individuals." My guess is that it's the 2.5th and 97.5th percentile of the residual. Sep 18, 2013 at 19:47
• I would have thought "confidence interval for individuals" would be a prediction interval ... but I am pretty sure it isn't that, because a PI 'spreads out in the tails' like a CI does (but relatively less so), while in that picture the green lines seem perfectly straight (I copied the picture and laid a straight line over them and couldn't see any deviation from linearity at all, but I guess it's possible there's just such small a deviation that it's not discernable). Sep 19, 2013 at 1:26