How do I validate multiple linear regression with validation data?
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Mudambi Srivatsa
2017 年 6 月 26 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!