allpossregs: Calculates all possible regressions

Description Usage Arguments Value Note Author(s) Examples

Description

Calculates all possible regressions for subset selection

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
allpossregs(f, best = 1, Cp.plot = TRUE, text.cex = 0.8, dp = 3,
       cv.rep = 50, nvmax = 20, ...)
## S3 method for class 'lm'
allpossregs(f, best = 1, Cp.plot = TRUE, text.cex = 0.8, dp = 3,
       cv.rep = 50, nvmax = 20, ...)
## S3 method for class 'formula'
allpossregs(f, best = 1, Cp.plot = TRUE, text.cex = 0.8, dp = 3,
       cv.rep = 50, nvmax = 20, data, subset, weights, na.action,
       method = "qr", model = TRUE, x = FALSE, y = FALSE, qr = TRUE,
       singular.ok = TRUE, contrasts = NULL, offset, ...)
          

Arguments

f

an lm object or model formula

best

the number of models for each size (size=number of variables) to be printed

Cp.plot

print Cp plot? (TRUE=yes, FALSE=no)

text.cex

expansion factor for plot text

dp

number of decimal places

cv.rep

The number of random samplings when calculating the CV estimate of prediction error

nvmax

The maximum number of variables to be included in models.

data

A data frame, list or environment containing the variables in the model.

subset

an optional vector specifying a subset of observations to be used in the fitting process.

weights

an optional vector of ‘prior weights’ to be used in the fitting process. Should be NULL or a numeric vector.

na.action

a function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options, and is na.fail if that is unset. The ‘factory-fresh’ default is na.omit. Another possible value is NULL, no action. Value na.exclude can be useful.

method

the method to be used in fitting the model. The default method "glm.fit" uses iteratively reweighted least squares (IWLS): the alternative "model.frame" returns the model frame and does no fitting.

x, y, qr, model

For glm: logical values indicating whether the response vector and model matrix used in the fitting process should be returned as components of the returned value.

For glm.fit: x is a design matrix of dimension n * p, and y is a vector of observations of length n.

singular.ok

logical. If FALSE (the default in S but not in R) a singular fit is an error.

contrasts

an optional list. See the contrasts.arg of model.matrix.default.

offset

this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to the number of cases. One or more offset terms can be included in the formula instead or as well, and if more than one is specified their sum is used. See model.offset.

...

additional arguments to be passed to the low level regression fitting functions see lm and glm help files

Value

A matrix with columns labeled:

rssp

Residual Sum of Squares

sigma2

low values indicate better model

adjRsq

adjusted R squared for the model. Big values indicate good model

Cp

Mallow's Cp measure of how well model predicts. Want small values

AIC

Akaike Information Criterion, estimate of the difference between the fitted model and actualy model. Want small values

BIC

Bayesian Information Criterion, estimate of the posterior probability that fitted model is correct one. Want small values

CV

Cross-validation. Small values indicate good model.

Variables

states which variables were included for the regression (val=1 means included)

Rows represent the number of variables in the model

Note

This function redirects to other functions based on the type of object. eg all.poss.regs.lm , all.poss.regs.formula

Author(s)

Alan Lee, Blair Robertson

Examples

1
2
data(fatty.df)
allpossregs(ffa ~ age + skinfold + weight, data = fatty.df, Cp.plot=TRUE)

Example output

Loading required package: s20x
Loading required package: leaps
Loading required package: rgl
Loading required package: lattice
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
   rssp sigma2 adjRsq    Cp    AIC    BIC    CV age skinfold weight
1 0.910  0.051  0.380 2.406 22.406 24.397 0.114   0        0      1
2 0.794  0.047  0.427 2.062 22.062 25.049 0.105   1        0      1
3 0.791  0.049  0.394 4.000 24.000 27.983 0.114   1        1      1

R330 documentation built on May 2, 2019, 2:12 p.m.