LinearModel.stepwise uses interactions

1 view (last 30 days)
John Layne
John Layne on 6 Feb 2016
Commented: the cyclist on 8 Feb 2016
Hello, LinearModel.stepwise produces a model with some interactions, even when set to 'linear'. It does not result in the same model as when it IS set to 'interactions'. Can someone please explain this, and perhaps the difference between these? Many thanks, JEL

Answers (1)

the cyclist
the cyclist on 7 Feb 2016
Edited: the cyclist on 7 Feb 2016
I can't fully answer your question, because I don't fully understand it. But let me try to say some helpful things.
It is important to understand that the word "linear" in the phrase "linear model" means that the model is linear in the coefficients. It has nothing to do with the powers of the explanatory variables. So, for example,
y(x) = alpha + beta1*x + beta2*x^2
is a linear model (assuming y is the response variable, and x is the explanatory variable).
y(x) = alpha * sin(beta * x)
is not, because of the non-linear dependence on the coefficient beta.
A linear model can have interaction terms:
y(x1,x2) = A + B*x1 + C*x2 + D*x1*x2
is a linear model with interactions.
When describing models that have interactions, you will sometimes refer to the linear terms. In the above, B*x1 and C*x2 are the linear terms, and D*x1*x2 is the interaction term. (The terminology can definitely be confusing.)
Regarding different calls to LinearModel.stepwise giving different results ... I think it would be best if you gave a couple distilled examples. Otherwise, we're just guessing at exactly what you mean.
  4 Comments
John Layne
John Layne on 7 Feb 2016
Many thanks, Cyclist! Can you tell me how I can gain access to the contents of a model object? As in, the output from LinearModel.stepwise. I can't even tell what it contains.
the cyclist
the cyclist on 8 Feb 2016
The documentation for the Linear Model class discusses Properties and Methods. I took only a quick glance, but it looks like you are most interested in
mdl.Steps.History
where mdl is the model object.
Here's an example from the documentation of stepwiselm:
load hald
mdl = stepwiselm(ingredients,heat,'PEnter',0.06)
mdl.Steps.History

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!