Variable Selection in Normal Linear Models
Performs variable selection in normal linear models.
## S3 method for class 'lm' stepCriterion( model, criterion = c("bic", "aic", "adjr2", "predr2", "cp", "p-value"), direction = c("backward", "forward"), level = 0.05, verbose = TRUE, ... )
model |
an object of the class lm which is obtained from the fit of a normal linear model. The linear predictor of the model whose fit is stored in this lm object is the more complex candidate which should be considered by the variable selection procedure. |
criterion |
an (optional) character string indicating the criterion which should be used to compare the candidate models. The available options are: AIC ("aic"), BIC ("bic"), adjusted R-squared ("adjr2"), predicted R-squared ("predr2"), Mallows' CP ("cp") and p-value of the F test ("p-value"). By default, |
direction |
an (optional) character string indicating the mode of variable selection which should be used. The available options are: deleting variables ("backward") and adding variables ("forward"). By default, |
level |
an (optional) numeric value in the interval (0,1) indicating the significance level chosen to perform the F tests. This is only appropiate if |
verbose |
an (optional) logical switch indicating if should the report of results be printed. By default, |
... |
further arguments passed to or from other methods. For example, |
A list which contains the following objects:
initial
: an expression describing the linear predictor of the "initial" model.
final
: an expression describing the linear predictor of the "final" model.
criterion
: a character string describing the criterion chosen to compare the candidate models.
## Example 1 fit1 <- lm(log(Ozone) ~ Solar.R*Temp*Wind, data=airquality) stepCriterion(fit1, direction="forward", criterion="adjr2") stepCriterion(fit1, direction="forward", criterion="bic") stepCriterion(fit1, direction="forward", criterion="p-value", level=0.01) ## Example 2 fit2 <- lm(mpg ~ log(hp)*log(wt)*qsec, data=mtcars) stepCriterion(fit2, direction="backward", criterion="bic") stepCriterion(fit2, direction="forward", criterion="cp") stepCriterion(fit2, direction="backward", criterion="p-value", level=0.05)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.