select_model: Backwards stepwise model selection using AIC, accounting for...

View source: R/select_model.R

select_modelR Documentation

Backwards stepwise model selection using AIC, accounting for missing data

Description

Selects best-fitting model, minimizing AIC accounting for missing values. Accounts for missing variables in two stages. Excludes missing observations from variables in base model, selects model. Excludes missing observations from variables retained in selected model. Refits model and selects model again. Then refits model to full data set. Calls -stepAIC- from MASS library

Usage

select_model(model, include = NULL, detail = 1)

Arguments

model

object of class "glm"

include

character vector of variables excluded from selection

detail

1 or 0 (default 1). Shows selection detail (1=Yes, 0=No, see trace from -stepAIC)

Value

"glm" object

Examples

utils::data(survey, package = "MASS")
survey2<-survey
#add some missing data
survey2$Wr.Hnd[1:5]<-NA
otemp<-glm(Sex~Wr.Hnd+NW.Hnd+Fold+Pulse+Smoke+Height, data=survey2, family=binomial)
summary(otemp)
mod1<-select_model(otemp)
summary(mod1)
mod2<-select_model(otemp, include=c("Smoke", "Pulse"))
summary(mod2)

wadetj/timsRstuff documentation built on April 12, 2025, 5:54 p.m.