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...
1 Answer
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)$.
val_1
andval_2
would be? $\endgroup$min
tomax
]... $\endgroup$MSE
of my model and get theSD = sqrt(MSE)
so a range:[y-SD, y+SD]
? Do we say the same thing? $\endgroup$