# Intuition for confidence intervals vs prediction intervals for linear regression

I am having a bit of trouble understanding the difference between a confidence and prediction interval in the context of linear regression, and in what scenario we would use either of them. I've posed a scenario below to show what my current understanding is, can anyone confirm my thinking is correct? If not, can you explain the difference between them and when we would use either?

'Imagine we’re running a study on the IQ scores of children between the ages of 1 and 10. We are doing a simple linear model using only their age as a regressor. Say we’ve studied ‘3 children aged 1, 10 children aged 2, 14 children aged 4 (note I have explicitly skipped children aged 3 for this example) and so on and so forth’. Two new children are to be tested: one who is aged 2 and the other who is aged 3. If I wanted to find their IQ score based on their age would I do it like this:

We already have data about children aged 2, so I would be interested in the confidence interval for the expected mean response, when predicting this childs IQ.

Then, for the other child who is aged 3 (an age we haven’t recorded any data for), here, I would use a prediction interval instead of a confidence interval, because I have no data to work with for children aged 3.'

A confidence interval is for the mean of a group of people who have the same input values for your X. If all assumptions are met, 95% of the confidence intervals you calculate will contain the true group mean.

However, you know, and a linear regression model explicitly states, that individuals drawn from this population won't all have the same value, even if they have the same X's. You expect variation from individual to individual. So if you want to have 95% confidence for individual predictions, you need a wider confidence interval.

That is why there are two different names. A "Confidence Interval" is for the expected value of a group. A "Prediction Interval" is for an individual.

So, for your example, it does not matter* whether you have existing data on children aged 3 or not. If you want an interval for their individual scores, use a prediction interval. If you want an interval for the mean of a group of children who are age 3, use a confidence interval.

"Does not matter" only applies to the question of whether you select a prediction or a confidence interval. You should only predict on the range of your data, so extrapolating to 10-year-olds, for example, would be risky because you are essentially assuming that the change in IQ has the same shape for all ages, and you don't have data to check.

• Okay this makes more sense thank you. My lecturer kinda glossed over this in lectures a bit. So to be clear, confidence for when we just want the mean of a group and prediction if we're interested in predicting what a particular persons IQ would be? May 11, 2022 at 14:18
• An important caveat is that predictions of y for a given x that is outside the span of x's used in the regression may not be useful. That is called extrapolation. For example, if you have a regression model based on data from 2000-2020, the trying to make a prediction for y in 2022 will not necessarily be successful. May 11, 2022 at 14:21
• Hi, Terry. Yes, that's correct. Confidence intervals are for group means. Prediction intervals are for individuals. You can check yourself by calculating both for a given X. The prediction interval should be larger because means have smaller variances (all else constant). May 11, 2022 at 14:45

You can understand the confidence interval as an interval for the mean, which gives information about the uncertainty/variance of the model itself.

A prediction interval is an interval for a single prediction, therefore it takes into account both the variance of the model AND the variance of the data (and thats why the prediction interval is bigger). Most of the time, a prediction interval is what you really need...