modComp: Compare covariate influence

View source: R/modComp.r

modCompR Documentation

Compare covariate influence

Description

Compare different subsets of covariates within a model

Usage

modComp(resp, vars, model, covars, data = NULL, uni = TRUE, ci = TRUE, ...)

Arguments

resp

the response variable

vars

character vector containing the names of all variables of interest

model

name of the model

covars

a list containing index vectors on vars. Each entry corresponds to an analysis.

data

location of the variables in vars

uni

logical: should univariate analyses be performed. If integer, this is used as an index on vars to determine which univariate analyses are performed)

ci

if TRUE confidence intervals are included

...

arguments passed to transFormat

Note

This function cannot yet incorporate interactions.

Author(s)

Henrik Renlund

Examples

# Comparing two set of covariates in model 'lm'
DF <- data.frame(x1=c(1,2,3,4),x2=c(3,4,0,1))
DF$y <- 2*DF$x1 + DF$x2 + c(0.1, -0.2, 0.05,0.05)
modComp(
   resp = "y",
   vars = c("x1", "x2"),
   model = lm,
   covars = list(1, 1:2),
   data = DF,
   uni = FALSE,
   ci = TRUE,
   round=2
   )
# Comparing different covariates in model 'coxph'
library(survival)
DF <- data.frame(
   x = c(3,1,2,3,2,4,5,6,4,5,3,2,4,1,1,2,3,4,6,7,8,1,1,2,6,4,2,1,1,3,4),
   y = c(0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0),
   z =  rep(letters[1:2], length.out=31),
   u = rep(c(1:5), length.out=31)
)
cox_endp <- with(DF, Surv(x,y))
modComp(resp = "cox_endp",
   vars = c("z", "u"),
   model=coxph,
   covars=list(1:2),
   data = DF,
   uni=TRUE,
   ci=FALSE,
   round=1,
   fun=exp
)
# Comparing different covariates in model 'glm' NOTE: must incorporate
# the argument "family='binomial'" by defining a function such that this is
# true
Model <- function(formula, data) glm(formula=formula,
family="binomial",data=data)
modComp(resp = "y",
   vars = c("x", "z"),
   model=Model,
   covars=list(1:2, 2),
   data = DF,
   uni=TRUE,
   ci=FALSE,
   signif=3,
   fun=exp
)
rm(Model, cox_endp, DF)

renlund/ucR documentation built on March 25, 2023, 10:10 a.m.