[R] leaps question

Thomas Lumley tlumley at u.washington.edu
Wed Feb 25 11:22:41 CET 2009


On Wed, 25 Feb 2009, Evelina Naryvska wrote:

> Colleagues,
> please help me with the simple question.
> How can I find R2 and p while doing best subsets regression? Also how
> can I see B and p for coefficients?

You can't see coefficients or their p-values, because these are not computed. The subset selection algorithm does not actually fit all the models, it only works out what the residual sum of squares would be for the models.  That is why it is fast. You have to actually fit the best models separately to get the coefficients, residuals, tests, and everything else.

The summary() method for regsubsets objects returns an object that includes the other things you want.

> names(summary(a))
[1] "which"  "rsq"    "rss"    "adjr2"  "cp"     "bic"    "outmat" "obj"

rsq is the r^2, rss is the residual sum of squares, adjr2 is the adjusted r^2, cp is Mallows' Cp, bic is the Schwartz Information Criterion.

If you believed F-test p-values after subset selection you could compute them from the residual sum of squares. I wouldn't advise it.

You could complain to the author of the package about the documentation. He seems to have forgotten to document summary.regsubsets().


       -thomas

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




More information about the R-help mailing list