stepVIF: Stepwise model selection using AIC/QIC for lm, glm/geeglm...

Description Usage Arguments Author(s) Examples

View source: R/stepVIF.R

Description

Stepwise model selection using AIC/QIC for lm, glm/geeglm objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
stepVIF(
  object,
  scope,
  direction = "forward",
  VIFThreshold = 5,
  parallel = FALSE,
  cl.type = NULL,
  n.cores = NULL,
  verbose = TRUE,
  AUC = FALSE,
  ...
)

Arguments

object

A lm, glm, or geeglm object. If the object is defined, the scope argument should be a formula.

scope

Defines the range of models explored in the stepwise search. See details for how to calibrate the scope.

direction

The direction (mode) of the stepwise model. Only "forward"" direction is supported.

VIFThreshold

maximum VIF threshold. Default value is 5.

parallel

If TRUE, run the function in parallel mode.

cl.type

Cluster type ("FORK" or "PSOCK") in parallel mode. Default value is "PSOCK." See parallel package's documentation for more information.

n.cores

Number of cores in parallel mode. Default value is the total number of cores (including logical cores) minus 1.

verbose

If true, prints the steps of the model selection. Default value is FLASE.

AUC

If true, computes the model's AUC along with AIC/QIC (binary reponse only).

...

See lm/glm/gee packages' documentations for additional parameters.

Author(s)

Masoud Barah, Sanjay Mehrotra

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
data("donor.kidney")

#select distinct donors
donor.kidney.distinct<-donor.kidney[!duplicated(donor.kidney[c("id")]),]
fitLM<-lm(log(creatinine) ~ 1,data=donor.kidney.distinct)
summary(fitLM)

frm<-as.formula(log(creatinine) ~ log(KDRI) + glomerulosclerosis +race+
                  anti_HCV + on_pump + DCD + laterality +
                  init_pump_resistance + terminal_pump_resistance +
                  init_pump_flow+ diabetes + smoking +
                  blood_type + HBsAg + MI + clinical_infection +
                  anti_HBs + Tattoos + cancer +
                  CMV + anti_HBc + HTLV)

fitLM<-stepVIF(object=fitLM,scope=frm)

fitGLM<-with(donor.kidney.distinct, glm(discard ~ 1, family =  binomial(link="logit")))
frm<-as.formula(discard ~ log(KDRI) + log(creatinine)+ glomerulosclerosis +race+
                  anti_HCV + on_pump + DCD + laterality +
                  init_pump_resistance + terminal_pump_resistance +
                  init_pump_flow+ diabetes + smoking +
                  blood_type + HBsAg + MI + clinical_infection +
                  anti_HBs + Tattoos + cancer +
                  CMV + anti_HBc + HTLV)

fitGLM<-stepVIF(object=fitGLM,scope=frm, AUC= FALSE)
summary(fitGLM)

library(geepack)
fit.gee<-geepack::geeglm(discard ~ 1, family =  binomial(link="logit"), data=donor.kidney,
corstr="independence", id=id)
fitGEE<-stepVIF(object=fit.gee,scope=frm, AUC = TRUE, verbose = FALSE)
summary(fitGEE)

mbarah/stepVIF documentation built on Feb. 19, 2021, 8:06 p.m.