regrAllEqns: All Equations of a Linear Model

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Selection of best linear models by exhaustive search

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
regrAllEqns(formula, data, weights = NULL, nbest = 50, nvmax = 20,
  force.in = NULL, force.out = NULL, codes = NULL, really.big = FALSE,
  ...)
regrAllEqnsXtr(object, nbest=1, criterion="cp")
## S3 method for class 'regrAllEqns'
print(x, nbest = 20, criterion = "cp",
  printcriteria = FALSE, printcodes = TRUE, ...) 
## S3 method for class 'regrAllEqns'
plot(x, criterion = "cp", critrange = 10,
  minnumber = 10, nbest=10, codes = x$codes, ncharhorizontal = 6,
  col="blue", legend = TRUE, mar = 6, main = "", cex = 0.7*par("cex"),
  cex.lab = par("cex.lab"), ...) 

Arguments

formula

formula for the full model

data

data.frame where the variables are found

weights

weights for weighted LS estimation

nbest

number of equations to record for each size. For print.regrAllEqns, number of equations printed in total.

nvmax

maximum size of subsets to examine

force.in

formula for terms to be kept in all models

force.out

formula for terms to be excluded from all models

codes

codes for the terms to be used for identifying the equations in the result 'outmat' and in the plot. Preferably one letter each.

really.big

Must be TRUE to perform exhaustive search on more than 50 variables.

criterion

Criterion to be used to rank the equations and for the vertical axis in plotting.

object, x

result of regrAllEqns to be used by regrAllEqnsXrt or print or plot

printcriteria

logicel: should the table of criteria be printed?

printcodes

logical: should the short codes for the terms (columns in the primary output 'outmat') be listed?

critrange

range of criterion that determines how many equations will be used in plotting: those that are less than critrange worse than the best.

minnumber

minimum number of equations shown; overrides critrange if needed.

ncharhorizontal

maximum length of string on margin 3 to be shown horizontally. Use ncharhorizontal=0 to get all codes shown vertically. This avoids overwriting.

col

color used for the equation identifiers in the plot

legend

logical: Should a list of short and long codes for terms be shown as a legend? Alternatively, a position for the legend: keyword like "bottomleft" or 2 coordinates.

mar

margins: either all 4 margins of the plot or 1 number for the top margin.

main

main title

cex, cex.lab

character expansion for codes in the plot and on the upper margin

...

Other arguments, to be passed to regsubsets, print or plot, respectively.

Details

This is a wrapper function for function regsubsets od package leaps. When factors (and other multicolumn terms) occur in the full model, it returns models that either include the factor or exclude it, and avoids those that contain some, but not all dummy variables related to it.

regrAllEqns also provides convenient information for the the plotting method. The results of regsubsets and its summary, which include the "avoided" eaquations, are also contained in the value.

Value

regrAllEqns returns a list, containing

which
criteria
codes
force.in
force.out
outmat
allsubsets
obj

see ?regsubsets

regrAllEqnsXtr returns a formula or a list of formulas (if nbest>1). plot.regrAllEqns invisibly returns the coordinates of the models used in the plot.

Note

For further details and notes, see ?regsubsets

Author(s)

Werner A. Stahel

See Also

regsubsets, leaps, step,

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(d.birthrates)
t.formula <- fertility ~ catholic + single24 + single49 + eAgric + eIndustry +
eCommerce + eTransport + eAdmin + gradeHigh + gradeLow + educHigh +
bornLocal + bornForeign + altitude + language
## altitude and language are factors

r.ae <- regrAllEqns(t.formula, data=d.birthrates, nbest=100, really.big=TRUE)
print(r.ae)
plot(r.ae, mar=9, ncharhorizontal=0, main="birthrates example",
     legend="bottomright", xlim=c(4,20))

## extract the formula of the best model
( t.formula <- regrAllEqnsXtr(r.ae) )
## ... and fit it
regr(t.formula, data=d.birthrates)

regr0 documentation built on May 2, 2019, 4:52 p.m.

Related to regrAllEqns in regr0...