Bootstrap linear regression MSE

조회 수: 6 (최근 30일)
Moh Aljoh
Moh Aljoh 2019년 7월 27일
편집: Adam Danz 2019년 7월 28일
I am trying to use bootstrap on the MSE, R-squared output generated from linear regression model. However, I am having trouble figuring out how to set it up with the correct arguments.
I tried to do something like:
X1 = outcomes;
X2 = modcomes;
mdl = LinearModel.fit(X1, X2);
resid = outcomes - modcomes;
% Simple bootstrap example
N_Boot = 1000;
SSE = zeros(N_Boot,1);
R_Sqrd = zeros(N_Boot,1);
for i = 1:N_Boot
[foo_b , GoF_b] = LinearModel.fit(modcomes, outcomes + resid);
SSE(i) = GoF_b.sse;
R_Sqrd(i) = GoF_b.rsquare;
end
mean(SSE)
std(SSE)
mean(R_Sqrd)
std(R_Sqrd)
  댓글 수: 1
Adam Danz
Adam Danz 2019년 7월 28일
편집: Adam Danz 2019년 7월 28일
If you're using matlab r2013b or later, you should use fitlm() instead of LinearModel.fit(). They have virtually the same inputs and both produce the LinearModel object. The model contains a field "Residuals" that contains (you guessed it) the residuals of the model. There is no documented second output and I haven't tried doing that myself so I'm not sure what's in the 2nd output in your code.
What are modcomes and outcomes?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Regression에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by