Is there a way to restrict interactions to a subset GeneralizedLinearRegression.stepwise
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Tom Lane
le 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".
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Gaussian Process Regression dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!