[R] Stepwise analysis with fixed variables

PIKAL Petr petr.pikal at precheza.cz
Wed Nov 21 17:11:30 CET 2012


Hi

I am not at all an expert in step. From the help page I inferred that

step(lm1, scope=list(lower=~Catholic))

keeps Catholic in model.

So something like

step(RegModel, direction ="backward",scope=list(lower=~sex+height))

shall leave those two in a model.

AFAIK there is no parameter alpha in a step function.

Regards
Petr

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Einat
> Sent: Wednesday, November 21, 2012 1:41 PM
> To: r-help at r-project.org
> Subject: Re: [R] Stepwise analysis with fixed variables
> 
> These are my questions:
> 
> 1. For example, if this is my code:
> 
> >RegModel =
> lm(glucose~sex+BMI+height+weight+education+ses,weight=w_without_non_res
> ponse)
>   >summary(RegModel)
> >step(RegModel, direction ="backward",scope=list(lower=?,upper=?))
> 
> and I want the sex and height variables to be fixed, but the rest of
> the variables to go into the backward analysis, how should I write the
> scope function?
> 
> 2.How can I add an alpha level to the step function as a criterion for
> the backward regression analysis?
> 
> Thank you :)
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Stepwise-
> analysis-with-fixed-variables-tp4650015p4650283.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.




More information about the R-help mailing list