Vijaya Parthiban
2010-Apr-01 15:11 UTC
[R] Factorial regression with multiple features: how to remove non-significant features?
Hello all, I am trying to do factorial regression using lm() like this (example): model<-lm(y ~ x1 + x2 + x3 + x4 + x1*x2*x3*x4) The final term 'x1*x2*x3*x4' adds all possible interactions between explanatory variables to the model. i.e. x1:x2, x1:x2:x3, etc, etc. Now, the issue is that some of the interactions are significant and some are not. I can manually remove features/interactions using 'update' like this: model1<-update(model,~. - x1:x2:x4) .... one by one as long as all the explanatory variables/features or interactions are significant. But, this is so tedious. There must be a way to say to R automatically 'I want to retain only significant features/interactions' OR to do something to update(remove) all non-significant interactions. model2<-step(model) ..was not very helpful. Are there any options to it? Can someone shed light on how I can do that? Can glm() or gam() or anything else be more powerful to do this? Any help is greatly appreciated! Many thanks, Parthiban. [[alternative HTML version deleted]]
Ista Zahn
2010-Apr-01 15:25 UTC
[R] Factorial regression with multiple features: how to remove non-significant features?
Hi Parthiban, I urge you to rethink your approach, or at least proceed with extreme caution. Lower-order terms involved in higher-order interactions may not be what you think they are. And there are serious problems with stepwise model selection. I encourage you to read a good regression modeling text or consult your local statistician before proceeding. -Ista PS. Yes, the step function has options, which you would know if you had taken the trouble to read the help file... Try ?step at the R prompt. On Thu, Apr 1, 2010 at 4:11 PM, Vijaya Parthiban <vijaya.parthiban@gmail.com> wrote:> Hello all, > > I am trying to do factorial regression using lm() like this (example): > > model<-lm(y ~ x1 + x2 + x3 + x4 + x1*x2*x3*x4) > > The final term 'x1*x2*x3*x4' adds all possible interactions between > explanatory variables to the model. i.e. x1:x2, x1:x2:x3, etc, etc. Now, > the > issue is that some of the interactions are significant and some are not. > > I can manually remove features/interactions using 'update' like this: > > model1<-update(model,~. - x1:x2:x4) > > .... one by one as long as all the explanatory variables/features or > interactions are significant. But, this is so tedious. There must be a way > to say to R automatically 'I want to retain only significant > features/interactions' OR to do something to update(remove) all > non-significant interactions. > > model2<-step(model) > > ..was not very helpful. Are there any options to it? > > Can someone shed light on how I can do that? Can glm() or gam() or anything > else be more powerful to do this? Any help is greatly appreciated! > > Many thanks, > Parthiban. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org [[alternative HTML version deleted]]