Learn R Programming

mixlm (version 1.4.0)

forward: F-test based model effect selection for linear models.

Description

Adaptation of existing methods based on AIC/BIC.

Usage

forward(model, alpha = 0.2, full = FALSE, force.in)
backward(model, alpha = 0.2, full = FALSE, hierarchy = TRUE, force.in)
stepWise(model, alpha.enter = 0.15, alpha.remove = 0.15, full = FALSE)
stepWiseBack(model, alpha.remove = 0.15, alpha.enter = 0.15, full = FALSE)
wideForward(formula, data, alpha = 0.2, force.in = NULL)

Value

The final linear model after selection is returned.

Arguments

model

object class lm to select effects from.

formula

formula specifying all possible effects.

data

data.frame corresponding to formula.

alpha

numeric p-value cut-off for inclusion/exclusion.

full

logical indicating extended output of forward/backward selection.

force.in

character vector indicating effects to keep in all models.

alpha.enter

numeric p-value cut-off for inclusion.

alpha.remove

numeric p-value cut-off for exclusion.

hierarchy

logical indicating if hierarchy should be forced in backward selection.

Author

Kristian Hovde Liland

Details

F-based versions of built in stepwise methods.

Examples

Run this code
set.seed(0)
data <- data.frame(y = rnorm(8),
				   x = factor(c('a','a','a','a','b','b','b','b')),
				   z = factor(c('a','a','b','b','a','a','b','b')))
mod <- lm(y ~ x + z, data=data)
forward(mod)
backward(mod)
stepWise(mod)
stepWiseBack(mod)

# Forward selection for wide matrices (large number of predictors)
set.seed(0)
mydata <- data.frame(y = rnorm(6), X = matrix(rnorm(60),6,10))
fs <- wideForward(y ~ ., mydata)
print(fs)

Run the code above in your browser using DataLab