# Can one get fitted value without going to predict?

1 view (last 30 days)
alpedhuez on 29 Jul 2021
Commented: alpedhuez on 30 Jul 2021
I have a regression
mdl=fitlm(X,Y)
How can one obtain the fitted value of the regression without going for predict?
Scott MacKenzie on 30 Jul 2021
I had posted an answer but then read Jeff's answer, posted a few hours after mine. As Jeff is "guessing" so was I.
If it's not what you are looking for, then please explain what you want. Explain what you mean by "fitted value" (why singular? coefficients? predictions? just one prediction? closeness of fit? etc.) and "without going for predict".

Jeff Miller on 30 Jul 2021
From your reference to 'predict', I'm guessing you have a vector of observed x values and you want to compute the predicted y for those x's. If so, then you want something like this:
xwithintercept = [1 x]; % maybe x' depending on row vs column vector
predictedY = sum( xwithintercept .* mdl.Coeffificent.Estimate)
alpedhuez on 30 Jul 2021
fitlm
had saved the value so that one can just reference it.