[R] Simulation of the Frailty of the Cox PH model

Mohammad Ehsanul Karim wildscop at yahoo.com
Sun Apr 8 09:47:07 CEST 2007

Dear R-list users,

I am trying to do simulation of survival data to
enable it to run under frailty option. Below is the
function a that I am using. My questions are:

1. How do I modify it to get bigger (hopefully
significant) value of Variance of random effect?

2. What changes do I have to make in the function to
run it under correlated frailty model? (may be in
kinship package)

3. Is there any program to run frailty by Inverse
gaussian or stable family in R?

Thank you for your time.
Thanks in advance.

Mohammad Ehsanul Karim
wildscop at yahoo dot com
Institute of Statistical Research and Training
University of Dhaka

# ***************************************
"sim.data"<- function(g,m){
group <- rep(1:m,rep(g,m))
Frailty <- rep(rgamma(m,100,1),rep(g,m))
covariate <- rbinom(g*m,1,.05)
stimes <-
cens <- 5 + 5*runif(25)
times <- pmin(stimes, cens)
censored <- as.numeric(cens > times)
data.mat <-
data.mat <-
data.fr <- data.frame(data.mat)
# ***************************************

# Example of 50 group each with 100 members

fit.c <- coxph(Surv(times,censored) ~ covariate,data=
# fit.c gives the Usual cox proportional hazards model
fit.gm.em <- coxph(Surv(times,censored) ~ covariate +
frailty(group, dist='gamma', method='em'), data=
# fit.gm.em gives the gamma frailty model by EM

fit.c # result of Cox PH model
fit.gm.em # result of gamma frailty model

More information about the R-help mailing list