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

5 views (last 30 days)
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.

Accepted Answer

Jyotish Robin
Jyotish Robin on 17 Jan 2017
Edited: Jyotish Robin on 17 Jan 2017
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 Comments
Jim
Jim on 17 Jan 2017
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!