How do I validate multiple linear regression with validation data?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I used the following code:
if true
% code
%b=regress(y,X) %returns a p-by-1 vector b of coefficient estimates for a multilinear regression of the responses in y on the predictors in X. X is an n-by-p matrix of p predictors at each of n observations. y is an n-by-1 vector of observed responses.
x1 = TrainingBootstrap;
x2 = TrainingDimension;
x3 = TrainingTNSPEC;
y = TrainingMatrix(:,4);
X = [ones(size(x1)) x1 x2 x3 x1.*x2 x1.*x3 x2.*x3 x1.*x2.*x3]; b = regress(y,X) % Removes NaN data end
I got the following answer: b =
1.0e+03 *
1.1847
-0.0000
-0.0000
-0.0000
0.0000
-0.0000
0.0000
-0.0000
How do I test goodness of fit of that line to validation data?
0 Kommentare
Antworten (1)
Mudambi Srivatsa
am 26 Jun. 2017
One way to verify the goodness of fit is by plotting the fit using validation data. Refer to the following link for plotting the "regress" fit:
https://www.mathworks.com/help/stats/regress.html#btzaffj
In this case, you might have to manually compute the goodness of fit statistics like R-square, adjusted R square, RMSE and so on using the generated model. However, if you would like MATLAB to auto-generate goodness of fit statistics, consider using 'fitlm' to fit the model to your data.
Refer to the following links for more information:
https://www.mathworks.com/help/stats/fitlm.html
https://www.mathworks.com/help/stats/linear-regression-workflow.html
0 Kommentare
Siehe auch
Kategorien
Mehr zu 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!