[R] ANother s-plus to R problem

Spencer Graves spencer.graves at pdf.com
Sat Dec 6 17:07:35 CET 2003


      Have you tried something like the following: 

      y.name <- names(data.table)[1]
      null.mdl <- formula(y.name, "~")
      null.fit <- lm(null.mdl, data.table)
      x.names <- paste(names(good.motifs[,1]), collapse="+")
      mdl <- formula(paste("~", x.names))
      library(MASS)
      fit <- stepAIC(null.fit, mdl)

      I have not tried this specific code, but I have done many things 
like this successfully in both S-Plus and R.  If it doesn't produce what 
you want immediately, I suggest you first step through this code one 
line at a time, examine the inputs and outputs to see what you have and 
modify the code accordingly.  Also, have you looked at the documentation 
on "stepAIC", including that in Venables and Ripley (2002) Modern 
Applied Statistics with S, 4th ed. (Springer)? 

      hope this helps. 
      spencer graves

Thomas Lumley wrote:

>On Fri, 5 Dec 2003, Prof Brian Ripley wrote:
>
>  
>
>>On Fri, 5 Dec 2003, Ognen Duzlevski wrote:
>>
>>    
>>
>>>Hi all, thank you for replying so quickly!
>>>
>>>I have another problem:
>>>
>>> step.wise <- stepwise(data.table[,names(good.motifs[,1])], data.table[1],
>>>f.crit=fval.cutoff)
>>>
>>>s-plus has the stepwise() formula but R has step() and stepAIC() from base
>>>and MASS packages. I cannot seem to figure out how to convert the above
>>>stepwise to either step() or stepAIC().
>>>      
>>>
>>You can't.  This is an old-fashioned approach, and the closest equivalent
>>in R is probably that of regsubsets in package leaps (in one of its
>>stepwise modes: it is a little short of detail)
>>
>>    
>>
>
>The default method for stepwise() in S-PLUS seems to be "efroymson". This
>is not provided by regsubsets(), but it is in the Fortran code, so it
>could be added.
>
>	-thomas
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>  
>




More information about the R-help mailing list