if (FALSE) {
#
# Generate synthetic survival data with regression coefficients
# beta = c(log(2),log(3)) and theta = 2, where the shared frailty
# values from a gamma distribution with expectation 1 and variance theta.
#
dat <- genfrail(N=300, K=2, beta=c(log(2),log(3)),
frailty="gamma", theta=2,
censor.rate=0.35,
Lambda_0=function(t, tau=4.6, C=0.01) (C*t)^tau)
# Fit a shared frailty model
fit <- fitfrail(Surv(time, status) ~ Z1 + Z2 + cluster(family),
dat, frailty="gamma")
fit
# The Lambda.fun function can give the estimated cumulative baseline hazard at
# any time
fit$Lambda.fun(seq(0, 100, by=10))
# Fit the DRS data, clustered on patient
data(drs)
fit.drs <- fitfrail(Surv(time, status) ~ treated + cluster(subject_id),
drs, frailty="gamma")
fit.drs
}
#
# A small example with c(log(2),log(3)) coefficients, Gamma(2) frailty, and
# 0.10 censorship.
#
dat <- genfrail(N=30, K=2, beta=c(log(2),log(3)),
frailty="gamma", theta=2,
censor.rate=0.10,
Lambda_0=function(t, tau=4.6, C=0.01) (C*t)^tau)
# Fit a shared frailty model
fit <- fitfrail(Surv(time, status) ~ Z1 + Z2 + cluster(family),
dat, frailty="gamma", se=TRUE)
fit
# Summarize the survival curve
head(summary(fit))
Run the code above in your browser using DataLab