MATLAB Answers

Is there a way to restrict interactions to a subset Generalize​dLinearReg​​epwise

1 view (last 30 days)
We are fitting a model where we have predictors that belong to three classess: exposures, demographics, expected covariates and covariates. The procedure works well. However, covariate:covaraite interactions are selected, which are hard to interpret.
We would like to restrict interactions to exposure:exposure interactions and exposure:demographics interactions.
I did try defining the complete model with allowable interactions specified. However, there were to many interactions (350) and not enough data to run the procedure.
Is it possible to restrict the number of interactions to a subset?
MATLAB ver 7.14; Statsitics toolbox 8.0

Accepted Answer

Tom Lane
Tom Lane on 9 Nov 2012
Yes, it is possible to specify 'Upper' as a model that is the upper bound of all terms to consider. For example:
y = 1 + x1 + x2 + x3 + x1.*x2 + x2.*x3 + x1.*x3 + randn(100,1)/10;
d = dataset(x1,x2,x3,y);
The first stepwise invocation will give all pairwise interactions. The second will allow only the specified interaction.
If you have too many predictors to make it feasible to write a formula, you can supply an equivalent terms matrix:
GeneralizedLinearModel.stepwise(d,'y~x1+x2+x3','Upper',[0 0 0 0;1 0 0 0;0 1 0 0;0 0 1 0;0 1 1 0])
This matrix option is described in "help".

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by