model spec 'polyijk' o=in fitlm does not work as per MATLAB documentation?

2 次查看(过去 30 天)
Hi, I am trying to use 'polyijk' model spec to specify my linear regression model complexity when using fitlm, but i dont seem to be getting what the documentation suggests i should. As per documentation: 'poly13' has an intercept and x1, x2, x2^2, x2^3, x1*x2, and x1*x2^2 terms. but when i try it, the terms i get are: 1 + x1*x2 + x2^2 + x1:(x2^2) + x2^3. so somehow it is missing the x1 and x2 terms.

采纳的回答

the cyclist
the cyclist 2024-3-22
编辑:the cyclist 2024-3-22
I think you are just misinterpreting the Wilkinson notation of the model spec in the output.
x1*x2 % note the * for interaction, which includes lower-order terms
is short-hand for
x1 + x2 + x1:x2 % note the : for interaction, which does NOT include lower-order terms
Here is an example. Note that all the terms you expect are in the table of estimated coefficients.
load carsmall
X1 = Acceleration;
X2 = Displacement;
X = [X1,X2];
y = Weight;
mdl = fitlm(X,y,"poly13")
mdl =
Linear regression model: y ~ 1 + x1*x2 + x2^2 + x1:(x2^2) + x2^3 Estimated Coefficients: Estimate SE tStat pValue __________ _________ ________ _______ (Intercept) 446.97 1693 0.26401 0.79236 x1 41.114 81.832 0.50242 0.61656 x2 14.69 21.387 0.68685 0.49388 x1:x2 -0.18481 0.92831 -0.19908 0.84263 x2^2 -0.026093 0.068886 -0.37878 0.70571 x1:x2^2 0.0010263 0.0021616 0.47479 0.63605 x2^3 8.6477e-06 5.822e-05 0.14853 0.88224 Number of observations: 100, Error degrees of freedom: 93 Root Mean Squared Error: 315 R-squared: 0.857, Adjusted R-Squared: 0.848 F-statistic vs. constant model: 92.9, p-value = 4.46e-37

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Regression 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by