Save regression output (fitlm) into table

30 ビュー (過去 30 日間)
Dobs
Dobs 2022 年 5 月 19 日
回答済み: Nathan 2023 年 9 月 15 日
Hello,
Is there any way to save the output from multiple linear regression into a table? (I don't mean exporting it into excel).
So for example, if I use the patients data set and calculate regression of weight and age on diastolic blood pressure, is there a way to save "Model_1" into a table (a table within matlab)? I realize that the output already looks like a table, but I mean an "actual" table (something like table (a, b, c, ..... ) ).
Many thanks!
P.S.: this is not a homework assignment, I just want to know if it's possible and if so, how to do it :)
load patients Weight Age Diastolic
x = [Weight, Age];
Model_1 = fitlm (x, Diastolic, 'VarNames', {'Weight', 'Age', 'DBP'})
Model_1 =
Linear regression model: DBP ~ 1 + Weight + Age Estimated Coefficients: Estimate SE tStat pValue ________ ________ _______ __________ (Intercept) 72.001 5.1971 13.854 1.0078e-24 Weight 0.056651 0.025884 2.1887 0.03102 Age 0.058378 0.095319 0.61245 0.54167 Number of observations: 100, Error degrees of freedom: 97 Root Mean Squared Error: 6.81 R-squared: 0.0533, Adjusted R-Squared: 0.0337 F-statistic vs. constant model: 2.73, p-value = 0.0704

回答 (2 件)

David Hill
David Hill 2022 年 5 月 19 日
Save in a cell array. I might not be understanding you completely.
for k=1:10
Model=%your code
c{k}=Model;
end

Nathan
Nathan 2023 年 9 月 15 日
If you're looking for what I was looking for Model_1.Coefficients contained a table of coefficients
load patients Weight Age Diastolic
x = [Weight, Age];
Model_1 = fitlm (x, Diastolic, 'VarNames', {'Weight', 'Age', 'DBP'})
Model_1 =
Linear regression model: DBP ~ 1 + Weight + Age Estimated Coefficients: Estimate SE tStat pValue ________ ________ _______ __________ (Intercept) 72.001 5.1971 13.854 1.0078e-24 Weight 0.056651 0.025884 2.1887 0.03102 Age 0.058378 0.095319 0.61245 0.54167 Number of observations: 100, Error degrees of freedom: 97 Root Mean Squared Error: 6.81 R-squared: 0.0533, Adjusted R-Squared: 0.0337 F-statistic vs. constant model: 2.73, p-value = 0.0704
Model_1.Coefficients
ans = 3×4 table
Estimate SE tStat pValue ________ ________ _______ __________ (Intercept) 72.001 5.1971 13.854 1.0078e-24 Weight 0.056651 0.025884 2.1887 0.03102 Age 0.058378 0.095319 0.61245 0.54167

カテゴリ

Help Center および File ExchangeGaussian Process Regression についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by