2
$\begingroup$

So, the idea is that I use linear regression and I get an equation y = a * x + b. So when I give a value x I get a predicted value y. However, what I want to achieve is instead of a single value y to get a range of values, such as [val_1 - val_2].Can this be done? Also I have found this question: Regression analysis with range (instead of single value) as independent variable which did not help...

$\endgroup$
5
  • 1
    $\begingroup$ Can you explain what your val_1 and val_2 would be? $\endgroup$ Sep 10, 2022 at 10:45
  • $\begingroup$ The values of the range: [min to max]... $\endgroup$ Sep 10, 2022 at 10:46
  • $\begingroup$ Hm. Linear regression usually assumes normally distributed errors, which go from minus to plus infinity, and your regression will not tell you that there is a max value your $y$ cannot exceed, so the best you can do would be to always output $(-\infty,\infty)$. This is probably not helpful. Would a prediction-interval work for you, i.e., an interval that contains the future realization with (say) 95% probability? $\endgroup$ Sep 10, 2022 at 10:54
  • $\begingroup$ @Stephan Kolassa: If I calculate the MSE of my model and get the SD = sqrt(MSE) so a range: [y-SD, y+SD] ? Do we say the same thing? $\endgroup$ Sep 10, 2022 at 10:57
  • 1
    $\begingroup$ Yes, that is a prediction interval. It will be too narrow, though, since it only includes one source of uncertainty, namely residual uncertainty - but not parameter uncertainty. Let me write up an answer. $\endgroup$ Sep 10, 2022 at 10:58

1 Answer 1

1
$\begingroup$

What you are looking for is a prediction interval, i.e., an interval $[a,b]$ such that a new observation falls within it with a certain prespecified probability, e.g., 95%. (Of course, there are multiple such intervals. The typical convention is to have "prediction interval" refer to a symmetric PI, such that $P(y<a)=P(y>b)=0.025$.)

You can find the formulas and explanation in Faraday (2002), section 3.5. Note that Faraday calls PIs "confidence intervals for predictions", which I find unfortunate, because it risks confusion with "normal" confidence intervals, which pertain to unobservable parameters. There is a difference between CIs and PIs.

Your favorite statistics package can probably give you prediction intervals. For instance, here is some toy data in R, and we calculate a central 95% PI at a IV of $x=0.7$:

set.seed(1)
xx <- runif(20)
yy <- 1+xx+rnorm(20)
model <- lm(yy~xx)
xx_pred <- 0.7
predict(model,newdata=data.frame(xx=xx_pred),interval="prediction",level=0.95)
#        fit        lwr      upr
# 1 1.527059 -0.4707293 3.524847

You will get a prediction of the expectation of $y$ of $1.53$, and a prediction interval of $(-0.47, 3.52)$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.