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!
regsubsets()
does not have the same arguments asleaps()
. Forregsubsets()
"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:so
adjr2
is not an option forregsubsets()
. If you want to obtain the adjr2 from the model search output ofregsubsets()
, you can call it like this: