Is there a way to restrict interactions to a subset GeneralizedLinearRegression.stepwise
2 次查看(过去 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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Gaussian Process Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!