Learn R Programming

wle (version 0.5)

mle.stepwise: Stepwise, Backward and Forward selection methods

Description

This function performs Stepwise, Forward and Backward model selection.

Usage

mle.stepwise(formula, data=list(), model=TRUE, x=FALSE, 
             y=FALSE, type="Forward", f.in=4.0, f.out=4.0, 
             contransts=NULL)

Arguments

formula
a symbolic description of the model to be fit. The details of model specification are given below.
data
an optional data frame containing the variables in the model. By default the variables are taken from the environment which mle.stepwise is called from.
model, x, y
logicals. If TRUE the corresponding components of the fit (the model frame, the model matrix, the response.)
type
type="Stepwise": the stepwise methods is used,

type="Forward": the forward methods is used,

type="Backward": the backward method is used.

f.in
the in value
f.out
the out value
contrasts
an optional list. See the contrasts.arg of model.matrix.default.

Value

  • mle.stepwise returns an object of class "mle.stepwise".

    The function summary is used to obtain and print a summary of the results.

    The object returned by mle.stepwise are:

  • stepthe selected models
  • typethe type o model selection procedure was used.
  • f.inthe value of f.in used.
  • f.outthe value of f.out used.
  • callthe match.call().
  • contrasts
  • xlevels
  • termsthe model frame.
  • modelif model=TRUE a matrix with first column the dependent variable and the remain column the explanatory variables for the full model.
  • xif x=TRUE a matrix with the explanatory variables for the full model.
  • yif y=TRUE a vector with the dependent variable.
  • infonot well working yet, if 0 no error occurred.

Details

Models for mle.stepwise are specified symbolically. A typical model has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response. A terms specification of the form first+second indicates all the terms in first together with all the terms in second with duplicates removed. A specification of the form first:second indicates the the set of terms obtained by taking the interactions of all terms in first with all terms in second. The specification first*second indicates the cross of first and second. This is the same as first+second+first:second.

Examples

Run this code
library(wle)

data(hald)

cor(hald)

result <- mle.stepwise(y.hald~x.hald)

summary(result)

Run the code above in your browser using DataLab