rfunctionmatrixs-plus

"Leaps" function from Splus to R


I have a code in Splus, but have to convert it into R, which is not a big thing. However I am very new to both softwares. This is the code I am struggling with:

 a <- leaps(xfit, y, wt = wt, method = "adjr2", keep=keep1, nbest=nbest, 

      names = dimnames(x)[[2]], int=F, keep.int = F)

x is a matrix of independent variables where first length(keep1) columns correspond to variables that are always kept in BMA (Bayesian Model Averaging -- this isn't important. Essentially, x is a matrix), and y is a matrix too.

This is part of a function, and when I try to use that function, R says that it could not find the function "leaps". It isn't defined in my program, so I am assuming it is something that is inbuilt in S-Plus. Is there an equivalent thing in R? Or do I have to install a package? Help appreciated!


Solution

  • You can use the leaps package to do subset regressions by leaps and bounds.

    But you will need to read the documentation from S-PLUS and carefully compare the use of the function and the arguments to the R-package arguments.