フィルターのクリア

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

1 回表示 (過去 30 日間)
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

採用された回答

Tom Lane
Tom Lane 2012 年 11 月 9 日
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 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by