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

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Tom Lane
Tom Lane il 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);
GeneralizedLinearModel.stepwise(d,'y~x1+x2+x3')
GeneralizedLinearModel.stepwise(d,'y~x1+x2+x3','Upper','y~x1+x2+x3+x2:x3','verb',2)
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 LinearModel.fit".

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by