Learn R Programming

surveillance (version 1.20.3)

twinstim_step: Stepwise Model Selection by AIC

Description

stepComponent is a wrapper around step to select a "twinstim" component's model based on an information criterion in a stepwise algorithm.

There are also stand-alone single-step methods of add1 and drop1.

Usage

stepComponent(object, component = c("endemic", "epidemic"),
              scope = list(upper = object$formula[[component]]),
              direction = "both", trace = 2, verbose = FALSE, ...)

# S3 method for twinstim add1(object, scope, component = c("endemic", "epidemic"), trace = 2, ...) # S3 method for twinstim drop1(object, scope, component = c("endemic", "epidemic"), trace = 2, ...)

Value

See step and add1, respectively.

Arguments

object

an object of class "twinstim".

component

one of "endemic" or "epidemic" (partially matched), determining the model component where the algorithm should proceed.

scope,direction,trace

see step and add1, respectively.

verbose

see twinstim.

...

further arguments passed to step, add1.default, or drop1.default, respectively.

Author

(of this wrapper around step) Sebastian Meyer

See Also

Examples

Run this code
data("imdepi", "imdepifit")

## simple baseline model
m0 <- update(imdepifit, epidemic=~1, siaf=NULL)

## AIC-based step-wise backward selection of the endemic component
m0_step <- stepComponent(m0, "endemic", scope=list(lower=~I(start/365-3.5)))
## nothing is dropped from the model

# \dontshow{
m0_step$anova <- NULL
stopifnot(identical(m0, m0_step))
# }

Run the code above in your browser using DataLab