Bootstrap linear regression MSE

4 visualizaciones (últimos 30 días)
Moh Aljoh
Moh Aljoh el 27 de Jul. de 2019
Editada: Adam Danz el 28 de Jul. de 2019
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 comentario
Adam Danz
Adam Danz el 28 de Jul. de 2019
Editada: Adam Danz el 28 de Jul. de 2019
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?

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by