Learn R Programming

mixlm (version 1.0.8.1)

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)

Arguments

model
object class lm to select effects from.
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.

Value

  • The final linear model after selection is returned.

Details

F-based versions of built in stepwise methods.

Examples

Run this code
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)

Run the code above in your browser using DataLab