step.spind: Stepwise model selection for GEEs and WRMs

step.spindR Documentation

Stepwise model selection for GEEs and WRMs

Description

Stepwise model selection by AIC or AICc for WRMS and QIC for GEEs

Usage

step.spind(object, data, steps = NULL, trace = TRUE, AICc = FALSE)

Arguments

object

A model of class WRM or GEE.

data

The data used to fit that model.

steps

Number of iterations the procedure should go through before concluding. The default is to use the number of variables as the number of iterations.

trace

Should R print progress updates and the final, best model found to the console? Default is TRUE.

AICc

Logical. In the case of model selection with WRMs, should AICc be used to determine which model is best rather than AIC? This argument is ignored for GEEs. Default is FALSE.

Details

This function performs stepwise variable elimination for model comparison. Each iteration will try to find the best combination of predictors for a given number of variables based on AIC, AICc, or QIC, and then use that as the base model for the next iteration until there are no more variables to eliminate. Alternatively, it will terminate when reducing the number of variables while respecting the model hierarchy no longer produces lower information criterion values.

Value

A list with components model and table. model is always formula for the best model found by the procedure. table is always a data frame, but the content varies for each type of model. For WRM's, the columns returned are

  • Deleted.Vars Variables retained from the previous iteration which were tested in the current iteration.

  • LogLik Log-likelihood of the model.

  • AIC AIC score for the model.

  • AICc AICc score for the model.

For GEEs:

  • Deleted.Vars Variables retained from the previous iteration which were tested in the current iteration.

  • QIC Quasi-information criterion of the model.

  • Quasi.Lik Quasi-likelihood of the model.

Note

Currently, the function only supports backwards model selection (i.e. one must start with a full model and subtract variables). Forward and both directions options may be added later.

Author(s)

Sam Levin

References

Hardin, J.W. & Hilbe, J.M. (2003) Generalized Estimating Equations. Chapman and Hall, New York.

See Also

qic.calc, aic.calc, add1, step, stepAIC

Examples

# For demonstration only. We are artificially imposing a grid structure
# on data that is not actually spatial data

library(MASS)
data(birthwt)

x <- rep(1:14, 14)
y <- as.integer(gl(14, 14))
coords <- cbind(x[-(190:196)], y[-(190:196)])

## Not run: 
formula <- formula(low ~ age + lwt + race + smoke + ftv + bwt)

mgee <- GEE(formula,
            family = "gaussian",
            data = birthwt,
            coord = coords,
            corstr = "fixed",
            scale.fix = TRUE)

ss <- step.spind(mgee, birthwt)

best.mgee <- GEE(ss$model,
                 family = "gaussian",
                 data = birthwt,
                 coord = coords,
                 corstr = "fixed",
                 scale.fix = TRUE)

summary(best.mgee, printAutoCorPars = FALSE)

## End(Not run)


levisc8/spind documentation built on April 3, 2024, 4:52 a.m.