Bootstrap linear regression MSE

7 次查看(过去 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