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!