forward function

F-test based model effect selection for linear models.

F-test based model effect selection for linear models.

Adaptation of existing methods based on AIC/BIC.

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)

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.

Details

F-based versions of built in stepwise methods.

Returns

The final linear model after selection is returned.

Author(s)

Kristian Hovde Liland

Examples

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)
  • Maintainer: Kristian Hovde Liland
  • License: GPL (>= 2)
  • Last published: 2025-01-14