model for fitting polynomial of degree 3

조회 수: 9 (최근 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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by