How do I prevent a stepwise multiple linear regression to include interaction terms?

조회 수: 11 (최근 30일)
Hello everyone,
I am trying to do exploratory regression to see which of my recorded variables can be used to predict output. I have 12 predictor variables (stored in X) and 1 outcome/response variable (in y).
The problem is, when I use a constant linear model
mdl1 = stepwiselm(X,y,'constant')
I only get one predictive term, which does not have a very high R_squared value (0.28).
However, if I start off with a linear model,
mdl2 = stepwiselm(X,y,'linear')
the stepwise regression gives me a result with various interaction terms, which seem to be impossible to interpret in this context, albeit with a larger R_squared value.
Is there a way that I can prevent the stepwise analysis from including these interaction terms, and just limit it to linear and quadratic terms? I have a feeling it might have something to do with the 'upper' argument, but I can not figure it out.
Thank you.

채택된 답변

Brendan Hamm
Brendan Hamm 2016년 2월 2일
You are on the right track, it is the Upper input you are looking for:
mdl1 = stepwiselm(X,y,'constant','Upper','linear');
This will create a model which starts at the Constant model and will add only linear terms (no interactions). If however you would like there to be quadratic terms without interactions, us ehte purequadratic option.
mdl2 = stepwiselm(X,y,'constant','Upper','purequadratic');
If you need to further specify which terms are allowed and which aren't, this can be accomplished with Wilkonson notation. It is a bit more complicated, but as an example the following will allow quadratic terms (and lower orders) for only the first 2 predictors and linear terms for the next 2 predictors:
mdl3 = stepwiselm(X,y,'constant','Upper','y ~ x1^2 + x2^2 + x3 + x4');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by