model for fitting polynomial of degree 3

7 ビュー (過去 30 日間)
Sumera Yamin
Sumera Yamin 2020 年 8 月 20 日
コメント済み: Sumera Yamin 2020 年 8 月 21 日
Hi, i want to use 'fitlm' for fitting polynomial of degree 3. Is there some builtin name for the model? For example, for degree 2, matlab used model 'Quadratic'. I tried 'Quartic' but it did not worked.

採用された回答

John D'Errico
John D'Errico 2020 年 8 月 20 日
編集済み: John D'Errico 2020 年 8 月 20 日
Just read the help.
x = rand(10,1);
>> y = rand(10,1);
>> D = dataset(x,y);
>> fitlm(D,'poly3')
ans =
Linear regression model:
y ~ 1 + x + x^2 + x^3
Estimated Coefficients:
Estimate SE tStat pValue
__________________ _________________ __________________ __________________
(Intercept) 0.883325330921357 0.269610952016709 3.27629617533717 0.0169006334507573
x -0.905689721171103 2.50947007046528 -0.36090875592837 0.73053441711432
x^2 2.97715513265619 5.78699413259576 0.514456221043511 0.625326610386953
x^3 -2.49404374290891 3.78096082734174 -0.659632261956649 0.53397526842927
Number of observations: 10, Error degrees of freedom: 6
Root Mean Squared Error: 0.182
R-squared: 0.222, Adjusted R-Squared: -0.167
F-statistic vs. constant model: 0.57, p-value = 0.655
I could also have written the model as:
fitlm(D,'y ~ 1 + x + x^2 + x^3')
which produces the same result.
  1 件のコメント
Sumera Yamin
Sumera Yamin 2020 年 8 月 21 日
many thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRegression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by