adjr2 in regsubsets function in R being an "ambiguous" method name

539 views Asked by At

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 <- regsubsets(x, y, wt = wt, method = "adjr2", nbest=nbest, 
     names = dimnames(x)[[2]], 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.

Initially, this was to use "leaps" function, but the matrices were too big, so R asked me to use regsubsets. Now, it says that "adjr2" is an "Ambiguous or unrecognised method name". I am quite sure this is a recognized method in the leaps function? Is there another command to be used because I am using the regsubset function, and not the leaps function? Help appreciated!

1

There are 1 answers

0
DirtStats On

regsubsets() does not have the same arguments as leaps(). For regsubsets() "method" refers to the type of model selection. From page 5 of the documentation at https://cran.r-project.org/web/packages/leaps/leaps.pdf:

method: Use exhaustive search, forward selection, backward selection or sequential re- placement to search.

so adjr2 is not an option for regsubsets(). If you want to obtain the adjr2 from the model search output of regsubsets(), you can call it like this:

> summary(regsubsets_object)$adjr2