MATLAB: Stepwiseglm modelspec specified as ‘linear’ but behaving like ‘interactions’

generalized linear modelsMATLABmodelspecregressionStatistics and Machine Learning Toolboxstepwisestepwiseglm

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.

Best Answer

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!