mardi 4 septembre 2018

random effects Cox model

I am trying to plot the dose-response relation between pm2.5 exposure and hypertension incidence. I fitted a random effects cox model, in which a random effect was added for the study centers. Then I used the plotHR function to plot the dose-response relation. But I met an error. Below is the example R code I used.

library(survival)
library(coxme) 
library(splines)
library(Greg)

data("eortc")
eortc$age<-rnorm(2323,40,10)

efit1 <- coxph(Surv(y, uncens) ~ ns(age) + trt , eortc)
plotHR(efit1,term = 1,xlim = c(30,70))

efit2 <- coxme(Surv(y, uncens) ~ ns(age) + trt + (1|center), eortc)
plotHR(efit2,term = 1,xlim = c(30,70))

I can plot efit1 using plotHR, but I met an error when plot efit2 in which I added a random effect in the cox model. Anyone knows how to solve this problem? Thanks!




Aucun commentaire:

Enregistrer un commentaire