Pregunta

I would like to assess multicollinearity in a cox proportional hazards model by calculating Variance Inflation Factor (VIF). The vif-functions in packages like {car} does not accept coxph objects.

Is there a way to calculate VIF for cox models in R?

¿Fue útil?

Solución

You are quite correct in your comment above that the VIF depends only in the X values. The vif-function in 'package:car' will accept any model that responds to vcov, coef, and model.matrix which should happen with coxph in 'package:survival', so assuming you have a fit-object, this should give you results:

library(survival)
library(rms)  # one possible source for a `vif`-function .... there are many
cvif <- vif(  testfit1  ) #assumes testfit from :  lrm, ols, psm, cph, Rq, Glm, glm

(Not yet tested since you offered no working example.)

This is a test case construction after copying the example in another question and modifying to construct a 'coxph'-object:

treatment <- factor(rep(c(1, 2), c(43, 41)), levels = c(1, 2), labels = c("placebo", "treated"))
improved <- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7, 7, 13, 7, 21)), levels = c(1, 2, 3), labels = c("none", "some", "marked"))
numberofdrugs <- rpois(84, 5)+1
healthvalue <- rpois(84,5)
y <- data.frame(healthvalue,numberofdrugs, treatment, improved)

testfit1 <- coxph(Surv(healthvalue, rep(1,nrow(y) ) ) ~numberofdrugs+treatment+improved, data= y)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top