Learn R Programming

logistf (version 1.21)

backward: Backward elimination of model terms in logistf models

Description

These functions provide simple backward elimination/forward selection procedures for logistf models

Usage

backward(object, scope, steps = 1000, slstay = 0.05, trace = TRUE, printwork = FALSE, ...) forward(object, scope, steps = 1000, slentry = 0.05, trace = TRUE, printwork = FALSE, pl = TRUE, ...)

Arguments

object
A fitted logistf model object. To start with an empty model, create a model fit with a formula=~1, pl=FALSE. (Replace by your response variable.)
scope
The scope of variables to add/drop from the model. If left blank, backward will use the terms of the object fit, and forward will use all variables in object$data not identified as the response variable. Alternatively, an arbitrary vector of variable names can be given, to allow that only some of the variables will be competitively selected or dropped.
steps
The number of forward selection/backward elimination steps.
slstay
For backward, the significance level to stay in the model.
slentry
For forward, the significance level to enter the model.
trace
If TRUE, protocols selection steps.
printwork
If TRUE, prints each working model that is visited by the selection procedure.
pl
For forward, computes profile likelihood confidence intervals for the final model if TRUE.
...
Further arguments to be passed to methods.

Value

An updated logistf fit with the finally selected model.

Details

The variable selection is simply performed by repeatedly calling add1 or drop1 methods for logistf, and is based on penalized likelihood ratio test. It can also properly handle variables that were defined as factors in the original data set.

Examples

Run this code
data(sex2)
fit<-logistf(data=sex2, case~1, pl=FALSE)
fitf<-forward(fit)

fit2<-logistf(data=sex2, case~age+oc+vic+vicl+vis+dia)
fitb<-backward(fit2)

Run the code above in your browser using DataLab