Description Usage Arguments Value Note References See Also Examples
leaps() performs an exhaustive search for the best subsets of the
variables in x for predicting y in linear regression, using an efficient
branch-and-bound algorithm. It is a compatibility wrapper for
regsubsets
does the same thing better.
Since the algorithm returns a best model of each size, the results do not depend on a penalty model for model size: it doesn't make any difference whether you want to use AIC, BIC, CIC, DIC, ...
1 2 |
x |
A matrix of predictors |
y |
A response vector |
wt |
Optional weight vector |
int |
Add an intercept to the model |
method |
Calculate Cp, adjusted R-squared or R-squared |
nbest |
Number of subsets of each size to report |
names |
vector of names for columns of |
df |
Total degrees of freedom to use instead of |
strictly.compatible |
Implement misfeatures of leaps() in S |
A list with components
which |
logical matrix. Each row can be used to select the columns of |
size |
Number of variables, including intercept if any, in the model |
cp |
or |
label |
vector of names for the columns of x |
With strictly.compatible=T
the function will stop with an error if x
is not of full rank or if it has more than 31 columns. It will ignore the column names of x
even if names==NULL
and will replace them with "0" to "9", "A" to "Z".
Alan Miller "Subset Selection in Regression" Chapman \& Hall
regsubsets
, regsubsets.formula
,
regsubsets.default
1 2 3 |
$which
1 2 3 4
1 FALSE TRUE FALSE FALSE
1 FALSE FALSE FALSE TRUE
1 FALSE FALSE TRUE FALSE
1 TRUE FALSE FALSE FALSE
2 FALSE TRUE FALSE TRUE
2 FALSE TRUE TRUE FALSE
2 FALSE FALSE TRUE TRUE
2 TRUE TRUE FALSE FALSE
2 TRUE FALSE FALSE TRUE
2 TRUE FALSE TRUE FALSE
3 FALSE TRUE TRUE TRUE
3 TRUE TRUE FALSE TRUE
3 TRUE TRUE TRUE FALSE
3 TRUE FALSE TRUE TRUE
4 TRUE TRUE TRUE TRUE
$label
[1] "(Intercept)" "1" "2" "3" "4"
$size
[1] 2 2 2 2 3 3 3 3 3 3 4 4 4 4 5
$Cp
[1] 2.498063 2.821867 3.819938 4.405012 1.680219 3.464118 3.962207 4.088471
[9] 4.511572 4.991564 3.116723 3.607326 4.981476 5.567344 5.000000
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.