[R] Error with regsubset in leaps package - vcov and all.best option (plus calculating VIFs for subsets)

Thomas Lumley tlumley at u.washington.edu
Wed May 20 16:28:48 CEST 2009


On Wed, 20 May 2009, lara harrup (IAH-P) wrote:

>
>
> Hi all
>
>
> I am hoping this is just a minor problem, I am trying to implement a best subsets regression procedure on some ecological datasets using the regsubsets function in the leaps package. The dataset contains 43 predictor variables plus the response (logcount) all in a dataframe called environment. I am implementing it as follows:
>
> library(leaps)
>
>
> subsets<-regsubsets(logcount~.,data=environment,nvmax=10,nbest=2,really.big=FALSE,method="exhaustive")
>
> ###the subset regression runs fine when i run it as above and i can get all >the usual summaries
>
> ###The problem comes when i try and get it to output the variance convariance >matric by adding the option vcov=TRUE

Yes, that would be because there is no option vcov=TRUE for regsubsets. There is a vcov= option for the coef() method, which may be what is confusing you.

<snip>

> I was wanting to get the variance - covariance matrix as I believe I need it >to calculate the Variance Inflation Factors (VIFs) for each of the models >reported by regsubsets. As I want to exclude any models that exhibit >multicollinerarity from later analysis, I am hoping to select say the 'best' >10 models and bootstrap them to find out more about how they perform.

As in the example on the help page, once you have run regsubsets() you can use  coef() and vcov() on the object it returns to get coefficient estimates and variance-covariance matrices for any of the best models.

      -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list