[R] scope argument in step function

From: Young Cho <iidn01_at_yahoo.com>
Date: Sat 02 Jul 2005 - 09:22:18 EST


Thanks a lot for help in advance. I am switching from matlab to R and I guess I need some time to get rolling. I was wondering why this code :  

> fit.0 <- lm( Response ~ 1, data = ds3)
> step(fit.0,scope=list(upper=~.,lower=~1),data=ds3)
Start: AIC= -32.66
 Response ~ 1

Call:
lm(formula = Response ~ 1, data = ds3)
Coefficients:
(Intercept)

      1.301    

is not working different from the following:  

>
> cnames <- dimnames(ds3)[[2]]
> cnames <- cnames[-444] # last col is Response
>
> fmla <- as.formula(paste(" ~ ",paste(cnames,collapse="+")))
> step(fit.0,scope=list(upper=fmla,lower=~1),data=ds3)
Start: AIC= -32.66
 Response ~ 1
> fmla <- as.formula(paste(" ~ ",paste(cnames,collapse="+")))
> fit.s <- step(fit.0,scope=list(upper=fmla,lower=~1),data=ds3)

Step: AIC= -Inf
 Response ~ ENTP9324 + CH1W0281

           Df Sum of Sq     RSS  AIC
<none>                        0 -Inf
- CH1W0281  3   0.00381 0.00381 -115
- ENTP9324  9         1       1  -34

The dataframe ds3 is 17 by 444 and I understand it is not smart thing to run stepwise regression. What I wondered is if I pass the 'upper=~.' , it seems step() thinks the full model is current one. Not adding anymore. If this is the right answer, is there a better way than creating fmla argument in the above?  

Thanks!  

-Young.                   


        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 02 09:26:09 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:11 EST