# Difference between confidence intervals and prediction intervals

For a prediction interval in linear regression you still use $\hat{E}[Y|x] = \hat{\beta_0}+\hat{\beta}_{1}x$ to generate the interval. You also use this to generate a confidence interval of $E[Y|x_0]$. What's the difference between the two?

• $\hat{E}[Y|x] = \hat{\beta_0}+\hat{\beta}_{1}x$ doesn't "generate the interval". – Glen_b Nov 21 '15 at 7:47
• I do not see a reason for the divergence between the two methods in any of the answers above. Regression results are typically estimated based upon parametric Student's t distribution parameters and typically regression, especially from poorly matched to the data regression models, lead to residuals that are not studentized, e.g., skewed but especially with heavy tails typically (if not always) making the parametric measures of data dispersion larger than their corresponding anticipated measured quantiles. A rule of thumb I have found useful: If I see residuals with outliers, long tails, and u – Carl Jan 22 '17 at 23:56
• – Scortchi - Reinstate Monica Jan 23 '17 at 11:34

Your question isn't quite correct. A confidence interval gives a range for $\text{E}[y \mid x]$, as you say. A prediction interval gives a range for $y$ itself. Naturally, our best guess for $y$ is $\text{E}[y \mid x]$, so the intervals will both be centered around the same value, $x\hat{\beta}$.

As @Greg says, the standard errors are going to be different---we guess the expected value of $\text{E}[y \mid x]$ more precisely than we estimate $y$ itself. Estimating $y$ requires including the variance that comes from the true error term.

To illustrate the difference, imagine that we could get perfect estimates of our $\beta$ coefficients. Then, our estimate of $\text{E}[y \mid x]$ would be perfect. But we still wouldn't be sure what $y$ itself was because there is a true error term that we need to consider. Our confidence "interval" would just be a point because we estimate $\text{E}[y \mid x]$ exactly right, but our prediction interval would be wider because we take the true error term into account.

Hence, a prediction interval will be wider than a confidence interval.

One is a prediction of a future observation, and the other is a predicted mean response. I will give a more detailed answer to hopefully explain the difference and where it comes from, as well as how this difference manifests itself in wider intervals for prediction than for confidence.

This example might illustrate the difference between confidence and prediction intervals: suppose we have a regression model that predicts the price of houses based on number of bedrooms, size, etc. There are two kinds of predictions we can make for a given $x_0$:

1. We can predict the price for a specific new house that comes on the market with characteristics $x_0$ ("what is the predicted price for this house $x_0$?"). Its true price will be $$y = x_0^T\beta+\epsilon$$. Since $E(\epsilon)=0$, the predicted price will be $$\hat{y} = x_0^T\hat{\beta}$$ In assessing the variance of this prediction, we need to include our uncertainty about $\hat{\beta}$, as well as our uncertainty about our prediction (the error of our prediction) and so must include the variance of $\epsilon$ (the error of our prediction). This is typically called a prediction of a future value.

2. We can also predict the average price of a house with characteristics $x_0$ ("what would be the average price for a house with characteristics $x_0$?"). The point estimate is still $$\hat{y} = x_0^T\hat{\beta}$$, but now only the variance in $\hat{\beta}$ needs to be accounted for. This is typically called prediction of the mean response.

Most times, what we really want is the first case. We know that $$var(x_0^T\hat{\beta}) = x_0^T(X^TX)^{-1}x_0\sigma^2$$

This is the variance for our mean response (case 2). But, for a prediction of a future observation (case 1), recall that we need the variance of $x_0^T\hat{\beta} + \epsilon$; $\epsilon$ has variance $\sigma^2$ and is assumed to be independent of $\hat{\beta}$. Using some simple algebra, this results in the following confidence intervals:

1. CI for a single future response for $x_0$: $$\hat{y}_0\pm t_{n-p}^{(\alpha/2)}\hat{\sigma}\sqrt{x_0^T(X^TX)^{-1}x_0 + 1}$$

2. CI for the mean response given $x_0$: $$\hat{y}_0\pm t_{n-p}^{(\alpha/2)}\hat{\sigma}\sqrt{x_0^T(X^TX)^{-1}x_0}$$

Where $t_{n-p}^{\alpha/2}$ is a t-statistic with $n-p$ degrees of freedom at the $\alpha/2$ quantile.

Hopefully this makes it a bit clearer why the prediction interval is always wider, and what the underlying difference between the two intervals is. This example was adapted from Faraway, Linear Models with R, Sec. 4.1.

• It is nice to see an old thread considerably improved by a clear and thoughtful response. Welcome to our site! – whuber Apr 1 '17 at 16:17
• Shouldn't this be ...x0 + 1/n +1 (for the prediction interval (1)), and ...x0 + 1/n (for the confidence interval (2)_ www2.stat.duke.edu/~tjl13/s101/slides/unit6lec3H.pdf real-statistics.com/regression/… – user48956 Nov 17 '17 at 22:17
• @jpgard Is the formal difference hence just the result of E(eps) = 0? – Pugl Apr 25 '20 at 1:09
• If I am understanding your question @Pugl, the formal difference here is that epsilon is only associated with a prediction for an individual observation, not with prediction of the mean response. – jpgard Apr 27 '20 at 4:44
• That is helpful thanks @jpgard – Pugl Apr 28 '20 at 5:08

The difference between a prediction interval and a confidence interval is the standard error.

The standard error for a confidence interval on the mean takes into account the uncertainty due to sampling. The line you computed from your sample will be different from the line that would have been computed if you had the entire population, the standard error takes this uncertainty into account.

The standard error for a prediction interval on an individual observation takes into account the uncertainty due to sampling like above, but also takes into account the variability of the individuals around the predicted mean. The standard error for the prediction interval will be wider than for the confidence interval and hence the prediction interval will be wider than the confidence interval.

I found the following explanation helpful:

Confidence intervals tell you about how well you have determined the mean. Assume that the data really are randomly sampled from a Gaussian distribution. If you do this many times, and calculate a confidence interval of the mean from each sample, you'd expect about 95 % of those intervals to include the true value of the population mean. The key point is that the confidence interval tells you about the likely location of the true population parameter.

Prediction intervals tell you where you can expect to see the next data point sampled. Assume that the data really are randomly sampled from a Gaussian distribution. Collect a sample of data and calculate a prediction interval. Then sample one more value from the population. If you do this many times, you'd expect that next value to lie within that prediction interval in 95% of the samples.The key point is that the prediction interval tells you about the distribution of values, not the uncertainty in determining the population mean.

Prediction intervals must account for both the uncertainty in knowing the value of the population mean, plus data scatter. So a prediction interval is always wider than a confidence interval.

• What the heck is meant by "data scatter" here? – tel Jun 5 '17 at 21:56
• @tel: Obviously the variance – vonjd Jun 6 '17 at 6:50
• So, when does the prediction interval converge to the narrower confidence interval? When there is no noise in the data (perfect correlation)? – Florin Andrei Oct 22 '20 at 23:19

A prediction interval is an interval associated with a random variable yet to be observed (forecasting).

A confidence interval is an interval associated with a parameter and is a frequentist concept.

Check full answer here from Rob Hyndman, the creator of forecast package in R.

This answer is for those readers who could not fully understand the previous answers. Let's discuss a specific example. Suppose you try to predict the people's weight from their height, sex (male, female) and diet (standard, low carb, vegetarian). Currently, there are more than 8 billion people on Earth. Of course, you can find many thousands of people having the same height and other two parameters but different weight. Their weights differ wildly because some of them have obesity and others may suffer from starvation. Most of those people will be somewhere in the middle.

One task is to predict the average weight of all the people having the same values of all three explanatory variables. Here we use the confidence interval. Another problem is to forecast the weight of some specific person. And we don't know the living circumstances of that individual. Here the prediction interval must be used. It is centered around the same point, but it must be much wider than the confidence interval.

• Thanks for the good example. So in your example for the first case, we have an uncertainty because we still only have a sample out of the entire population, so is the uncertainty we have here between the estimated mean and the true mean of the population? While in the second case, we have sampling variance as well as the residual error? – Pugl Apr 25 '20 at 1:08
• I'm not sure about your second case. Which interval to use, depends on the goal. – Serhii Kushchenko Apr 25 '20 at 18:34
• In short. Confidence Interval - A range for the expected AVERAGE Prediction Interval - A range for a SINGLE DATA POINT – kiwicomb123 Feb 6 at 21:18