Bootstrap linear regression MSE
7 ビュー (過去 30 日間)
古いコメントを表示
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
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 Center および File Exchange で Linear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!