stepwiselm: too many output arguments

19 次查看(过去 30 天)
Running stepwiselm, I get the following results (independent variables are contained in a 5-column matrix called "ingredients" and the dependent variable is Y):
ds = dataset(ingredients(:,1),ingredients(:,2),ingredients(:,3),ingredients(:,4),ingredients(:,5),Y,'Varnames',{'a','b','c','d','e','Growth rate'});
mdl=stepwiselm(ds,'interactions');
[b,se,pval,inmodel,stats,nextstep,history]=stepwiselm(ds,'interactions');
Warning: Variable names were modified to make them valid MATLAB identifiers.
In @dataset\private\setvarnames at 43
In dataset.dataset>dataset.dataset at 384
1. Removing a:e, FStat = 0.36439, pValue = 0.54775
2. Removing a:b, FStat = 0.33757, pValue = 0.56281
3. Removing a:d, FStat = 0.29478, pValue = 0.58861
4. Removing d:e, FStat = 1.3403, pValue = 0.25022
5. Removing b:c, FStat = 2.3391, pValue = 0.12983
6. Removing c:e, FStat = 0.93838, pValue = 0.33538
7. Removing a:c, FStat = 2.4256, pValue = 0.12296
Error using stepwiselm
Too many output arguments.
MY QUESTIONS ARE AS FOLLOWS--First of all, why does it complain about having too many output arguments? And then it returns something for mdl, which actually has more coefficient estimates than described by the growth equation:
mdl =
Linear regression model:
GrowthRate ~ 1 + a + b*d + b*e + c*d
Estimated Coefficients:
Estimate SE tStat pValue
__________ __________ _______ _________
(Intercept) -0.079748 0.042445 -1.8789 0.063534
a -0.22811 0.12251 -1.8619 0.065912
b 0.01196 0.0063717 1.8771 0.063783
c 0.11473 0.064456 1.7799 0.078499
d 0.026636 0.0098081 2.7157 0.007944
e 0.023101 0.008404 2.7489 0.0072412
b:d 0.0012314 0.00060937 2.0207 0.046312
b:e -0.0040564 0.0018181 -2.2311 0.028186
c:d -0.036097 0.012224 -2.953 0.0040246
Number of observations: 98, Error degrees of freedom: 89
Root Mean Squared Error: 0.0236
R-squared: 0.79, Adjusted R-Squared 0.771
F-statistic vs. constant model: 41.9, p-value = 5.73e-27
Any thoughts??? MANY, MANY, MANY thanks in advance!

采纳的回答

Brendan Hamm
Brendan Hamm 2015-9-14
编辑:Brendan Hamm 2015-9-15
It complains about having too many output arguments because stepwiselm only passes back one output argument (a LinearModel). The documentation mentions that the 'interactions' model includes an intercept, all linear terms, and all products of pairs of distinct predictors. If you want to consider only the terms you mention then pass this in as the modelspec.
mdl = stepwiselm(ds,'GrowthRate ~ 1 + a + b:d + b:e + c:d');
Here the colon notation means to only include that specific interaction term, whereby b*d would return the linear termsw for both b and d as well. Refer to the Wilkinson Notation at the bottom of the documentation.
  6 个评论
Janice
Janice 2015-9-22
Oooo, I see. One other question (just in case it comes up in some future interrogation session :): why does the final model say: linear regression model growth ~ 1 + a*c + b*c + b*d + b*e + c*d + c*e when some terms like b, d, etc. show significance but are not included in the equation?
Brendan Hamm
Brendan Hamm 2015-9-22
In the Wilkinson notation:
'response ~ a*c'
is equivalent to:
'response ~ 1 + a + c + a:c'
That is 'a*b' means the interaction terms between a and c (denoted 'a:c') as well as all lower order terms ( a and b ).
Please refer to the documentation on Wilkinson Notation to ensure you understand all terms.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Model Building and Assessment 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by