Calculating Residual Values in a Regression
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sarath l
am 10 Nov. 2018
Beantwortet: Jeff Miller
am 10 Nov. 2018
I have a doubt in calculating Residual values for a given regression model. Consider this case (first table with x and y values). As we know that residual values are (y-y_hat), I calculated them using the same formula and the values i got are same as mentioned in the website i linked. But, when i try to find the residuals using fitlm/LinearModel.fit methods, I get different values. please see the code and help me where I'm wrong.
y=[70 65 70 95 85]';
x=[60 70 80 85 95]';
mdl=LinearModel.fit(y,x);
disp(mdl.Residuals.('Raw'))
The Output I'm getting for the above code is,
-12.7778
0.9524
7.2222
-6.4286
11.0317
which doesn't match with the residuals given in the website
4.5890
-6.8493
-8.2877
13.4932
-2.9452
0 Kommentare
Akzeptierte Antwort
Jeff Miller
am 10 Nov. 2018
In MATLAB's linearmodel.fit command, x is the first parameter and y is the second. You have them reversed.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!