[R] Backward elimination in regression

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Tue Mar 22 10:54:22 CET 2011


Hi Denis,
how about this:

to.drop<-"x1"
update(mod,as.formula(paste(".~.-",to.drop,sep="")))

hth.

Am 22.03.2011 08:12, schrieb Denis.Aydin at unibas.ch:
> Dear all
> 
> I want to run a simple multiple linear regression model, say:
> 
> mod <- lm(y~x1+x2+x3+x4)
> 
> I have programmed a custom algorithm to calculate the p-values, because 
> there is clustering present.
> 
> I ordered the variables according to their p-value and want to stepwise 
> eliminate the variables with the highest p-values.
> 
> My question: How can I use "update" when I have only the variable name als 
> string (e.g., "x1")? Or is there another convenient way to update the 
> model?
> 
> Thanks!
> 
> Sincerely,
> Denis
> 
> --------------------------------------------------------------------------
> This email and any files transmitted with it are confide...{{dropped:8}}
> 
> ______________________________________________
> R-help at 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.

-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790



More information about the R-help mailing list