stepwiseglm modelspec specified as 'linear' but behaving like 'interactions'

3 ビュー (過去 30 日間)
Jim
Jim 2017 年 1 月 11 日
コメント済み: Jyotish Robin 2017 年 1 月 18 日
I have a binary response vector y (N x 1) and a real-valued matrix X (N x t) of predictors. I want to estimate y with logistic regression via a stepping procedure. I'm executing the following statement:
stepwiseglm(X,y,'linear','distribution','binomial')
but the behavior seems more to follow the 'interactions' modelspec rather than the 'linear' that I've specified. For example, the function gives me the generalized linear regression model:
logit(y) ~ 1 + x3 + x1*x2
that is, it's testing products of individual predictors in the stepping procedure. The modelspec states that 'linear' means: "Model contains an intercept and linear terms for each predictor", while 'interactions' means "Model contains an intercept, linear terms for each predictor, and all products of pairs of distinct predictors (no squared terms)."
So it seems that either I'm doing something dumb, which has high probability, or stepwiseglm is behaving oddly and applying the 'interactions' modelspec instead of 'linear'. Any feedback would be appreciated.

採用された回答

Jyotish Robin
Jyotish Robin 2017 年 1 月 17 日
編集済み: Jyotish Robin 2017 年 1 月 17 日
Hi Jim,
I understand that though you specified "modelspec" as linear in "stepwiseglm", the generalized linear regression model seems to contain product terms.
This is because the 'ModelSpec' option just specifies the starting model for the stepwise regression.
"stepwiseglm" basically creates a generalized linear regression model by stepwise regression. So, it performs a regression, takes a look at the predictors and decides whether adding the predictors will improve the fit.
The following doc is worth taking a look at:
You could use the 'Upper' and 'Lower' parameters to specify the largest set of items in the fit (parameters not included in this list will not be included in the model) and the items that cannot be removed from the model (these terms must be there in the model)
Hope this helps!
  2 件のコメント
Jim
Jim 2017 年 1 月 17 日
Hi Jyotish,
Thanks very much for your helpful reply. I did read the documentation prior to my forum query, but I was misinterpreting Upper and Lower as constraints on the number of predictors, while now I understand that they can constrain the multiplicative order of the predictors. Re-reading the documentation now, it becomes more obvious. My problem was easily solved using:
regmod=stepwiseglm(xpred,ypred,'linear','upper','linear', 'Distribution','binomial');
Thanks again.
Jyotish Robin
Jyotish Robin 2017 年 1 月 18 日
Glad that your issue is resolved. :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSupport Vector Machine Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by