[R] regsubsets() [leaps package] - please share some good examples of use

Thomas Lumley tlumley at uw.edu
Tue Mar 15 22:26:10 CET 2011


On Wed, Mar 16, 2011 at 3:18 AM, agent dunham <crosspide at hotmail.com> wrote:
> Does it mean that regsubsets doesn't work with categorical variables?

No.

> It's because I'm trying the following and I don't know what happens. Any
> help would be appreciated.
>
> varin <- data.frame(v1,v2,...,v7, factor1,..., factor4)
>
> Dependent variable: height
>
> Then:
>
> eu.subsets <- regsubsets(varinc , height,
> method=c("exhaustive"),nvmax=3,nbest =1)
>
> It gives me this errror:
>
> Error en leaps.setup(x, y, wt = weights, nbest = nbest, nvmax = nvmax,  :
>  character variables must be duplicated in .C / .Fortran

As the help says, the first argument x must be either a design matrix
or a model formula.  If you want R to make a design matrix for
categorical variables for you, use a model formula

> By the way, if you introduce weights in regsubsets, is the same as doing
> some kind of robust regression?

No. It's weighted least squares.

    -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland



More information about the R-help mailing list