Learn R Programming

logistf (version 1.24)

backward: Backward Elimination/Forward Selection of Model Terms in logistf Models

Description

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

Usage

backward(object, ...)

# S3 method for logistf backward( object, scope, steps = 1000, slstay = 0.05, trace = TRUE, printwork = FALSE, full.penalty = FALSE, ... )

# S3 method for flic backward( object, scope, steps = 1000, slstay = 0.05, trace = TRUE, printwork = FALSE, full.penalty = FALSE, ... )

forward(object, ...)

# S3 method for logistf forward( object, scope, steps = 1000, slentry = 0.05, trace = TRUE, printwork = FALSE, pl = TRUE, ... )

# S3 method for flac backward( object, steps = 1000, slstay = 0.05, trace = TRUE, printwork = FALSE, full.penalty = FALSE, ... )

Arguments

object

A fitted logistf model object. To start with an empty model, create a model fit with a formula=<y>~1, pl=FALSE. (Replace <y> by your response variable.)

...

Further arguments to be passed to methods.

scope

The scope of variables to add/drop from the model. Can be missing for backward, backward will use the terms of the object fit. Alternatively, an arbitrary vector of variable names can be given, to allow that only some of the variables will be competitively selected or dropped. Has to be provided for forward.

steps

The number of forward selection/backward elimination steps.

slstay

For backward, the significance level to stay in the model.

trace

If TRUE, protocols selection steps.

printwork

If TRUE, prints each working model that is visited by the selection procedure.

full.penalty

If TRUE penalty is not taken from current model but from start model.

slentry

For forward, the significance level to enter the model.

pl

For forward, computes profile likelihood confidence intervals for the final model if TRUE.

Value

An updated logistf, flic or flac fit with the finally selected model.

Functions

  • forward: Forward Selection

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
# NOT RUN {
data(sex2) 
fit<-logistf(data=sex2, case~1, pl=FALSE) 
fitf<-forward(fit, scope = c("dia", "age")) 

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

# }

Run the code above in your browser using DataLab