.BG
.FN leaps
.TL
All-Subset Regressions by Leaps and Bounds
.CS
leaps(x, y, wt, int=TRUE, method="Cp",
      nbest=10, names, df=nrow(x))
.AG x
matrix of independent variables.  Each column of `x' is a
variable, each row an observation.  There should be
a maximum of 31 columns and fewer columns than rows.
.AG y
vector of dependent variable with the same number of
observations as the number of rows of `x'.
.AG wt
optional vector of weights for the observations.
.AG int
logical flag, should an intercept term be used in the
regressions?
.AG method
character string describing the method used to evaluate a
subset.  Possible values are "Cp", "r2", and "adjr2"
corresponding to Mallows Cp statistic, r-square, and
adjusted r-square.  Only the first character need be
supplied.
.AG nbest
integer describing the number of "best" subsets to be found
for each subset size.  In the case of r2 or Cp methods, the
`nbest' subsets (of any size) are guaranteed to be included
in the output (but note that more subsets will also be
included).
.AG names
optional character vector giving names for the independent
variables.  Default, the names are 1, 2, ... 9, A, B, ...
.AG df
degrees of freedom for `y'.
Useful if, for example, `x' and `y' have already been adjusted
for previous independent variables.
.RT
list with four components:
.RC Cp
the first returned component will be named "Cp", "adjr2", or
"r2" depending on the method used for evaluating the
subsets.  This component gives the values of the desired
statistic.
.RC size
the number of independent variables (including the constant
term if `int' is `TRUE') in each subset.
.RC label
a character vector, each element giving the names of the
variables in the subset.
.RC which
logical matrix with as many rows as there are returned
subsets.  Each row is a logical vector that can be used to
select the columns of `x' in the subset.
.SH REFERENCE
George M. Furnival and Robert W. Wilson, Jr., "Regressions
by Leaps and Bounds",
.ul
Technometrics,
Vol. 16, No. 4, November 1974, pp. 499-511.
.EX
r <- leaps(x,y)
plot(r$size,r$Cp,type="n")
text(r$size,r$Cp,r$label)     # produces Cp plot
lsfit( x[,r$which[3,]], y )     #regression corresponding
                              # to third subset
.KW array
.KW regression
.WR
