model for fitting polynomial of degree 3
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sumera Yamin
le 20 Août 2020
Commenté : Sumera Yamin
le 21 Août 2020
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.
0 commentaires
Réponse acceptée
John D'Errico
le 20 Août 2020
Modifié(e) : John D'Errico
le 20 Août 2020
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Regression dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!