access values in dataset

hi In the results of lm = LinearModel.fit(x, y)
there is lm.Coefficients containing the coefficient values.
E.g.,
>> lm.Coefficients
ans =
Estimate SE tStat pValue
(Intercept) -17.637 0.4574 -38.558 5.5217e-252
x1 0.0037939 0.00039008 9.726 6.0697e-22
>> get(lm.Coefficients)
ans:
Description: ''
VarDescription: {}
Units: {}
DimNames: {'Observations' 'Variables'}
UserData: []
ObsNames: {2x1 cell}
VarNames: {'Estimate' 'SE' 'tStat' 'pValue'}
How do I access the estimated coefficients? For example -17.637 in the table. Thanks!

回答 (2 件)

Matz Johansson Bergström
Matz Johansson Bergström 2014 年 8 月 24 日
編集済み: Matz Johansson Bergström 2014 年 8 月 24 日

0 投票

LinearModel is using tables, so you can write
tmp = table2array(Im.Coefficients)
and access tmp.

1 件のコメント

Matz Johansson Bergström
Matz Johansson Bergström 2014 年 8 月 24 日
Also, Matlab is warning me that LinearModel will be replaced with fitlm in a future release, see fitlm documentation.

サインインしてコメントする。

Peter Perkins
Peter Perkins 2014 年 9 月 2 日

0 投票

Slightly more direct than Mark's suggestion:
Im.Coefficients.Estimates(1)
gets you the estimated intercept as a scalar value.

タグ

質問済み:

2014 年 8 月 24 日

回答済み:

2014 年 9 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by