# \donttest{
# Example 1 (SFM): a total of 400 patients (1:1 randomization scheme),
# with a fixed number of 3 recurrent events per patient. Gamma-frailty
# variance of 0.5. Expected hazard ratio of 0.7, time-to-death are uniformly
# distributed, with a mean time to death of (3+10)/2=6.5 years. Each subject is
# followed-up for a maximum of 6 years, with a median time-to-event of 1.5 years.
# Patients are recruited over a 0.5-year period.
SFM.power(
Groups = 400, ni = 3, ni.type = "max",
FUP = 6, Acc.Dur = 0.5, median.H0 = 1.5,
beta.HA = log(0.7), theta = 0.5,
cens.par = c(3, 10), cens.type = "Unif",
data.type = "rec_event"
) # power ~ 90%
# Example 2 (NFM): same parameters as above, but we now assume that we have
# 40 hospitals, 10 subjects per hospital (10 × 40 = 400 subjects in total)
# and 3 recurrent events per subject.
NFM.power(
Groups = 40, ni = 10, ni.type = "max", kij = 3, kij.type = "max",
FUP = 6, Acc.Dur = 0.5, median.H0 = 1.5,
beta.HA = log(0.7), theta = 0.5,
cens.par = c(3, 10), cens.type = "Unif",
data.type = "rec_event1"
) # power ~ 83%
# Example 3 (NFM): we aim to compute the required sample size to achieve
# 80% power for detecting a hazard ratio of 0.75 in a neurological study,
# where migraine episodes experienced by subjects are classified into three
# severity subtypes (mild, moderate, severe). For each subject, we anticipate
# a mean number of 2 migraine episodes per severity subtype, with a median
# time-to-event of 6 months. The study duration includes a 1-year accrual period
# followed by a 5-year total follow-up. All subjects will be followed until
# the end of the study.
NFM.ssize(
power = 0.80, ni = 3, ni.type = "max", kij = 2, kij.type = "pois",
FUP = 5, Acc.Dur = 1, FUP.type = "uptoend", median.H0 = 0.5,
beta.HA = log(0.75), data.type = "rec_event2"
) # sample size ~ 363 patients
# Example 4 (JFM): power estimation, testing a treatment effect on recurrent
# events only. We assume a uniformly distributed number of recurrent events,
# ranging from 1 to 6 recurrent events per subject. The allocation ratio
# experimental:control is 2:1, and the follow-up is 10 weeks.
# The expected hazard ratio is 0.70 for recurrent event and 0.90 for the
# terminal event. We have chosen 0.5 as the variance of the frailties.
JFM.power(
Npts = 400, ni = c(1, 6), ni.type = "unif",
FUP = 10, FUP.type = "fixed", ratio = 2,
betaTest.type = "betaRtest", betaR.HA = log(.70), betaD.HA = log(.90),
theta = .5
) # power ~ 76%
# Example 5 (JFM): sample size calculation, to assess the treatment effect on
# both recurrent and terminal events. We want to achieve an 80% power.
# We anticipate a maximum of 5 recurrent events, over a 6-year period and a
# 0.5-year accrual period. We assume that the gamma-frailty variance is 0.5.
# For the control group, we expect a 2-year and a 5-year median time-to-event
# for recurrent events and terminal events, respectively. We consider a 30%
# and 20% risk reduction for recurrent events and terminal event, respectively.
JFM.ssize(
power = 0.80, ni = 9,
FUP = 6, Acc.Dur = 1.5, medianR.H0 = 2, medianD.H0 = 5,
betaTest.type = "joint", betaR.HA = log(.70), betaD.HA = log(.80), theta = .5
) # sample size ~ 445 patients / ~ approx
# Example 6: Sample size calculation for GJFM
# Same as above, but with two random effects (with two Gamma-frailty variances
# theta and eta). To ensure sample size estimation stability, we use 10000
# Monte-Carlo samples.
GJFM.ssize(
power = 0.80, ni = 5,
FUP = 6, Acc.Dur = 0.5, medianR.H0 = 2, medianD.H0 = 5,
betaR.HA = log(0.70), betaD.HA = log(0.80), theta = 0.5, eta = 0.75,
samples.mc = 1e5
) # sample size ~ 705 patients / ~ approx 4 min.
# Example 7:
# --------------------------------------------------
# Post-hoc power analysis for a Joint Frailty Model
# --------------------------------------------------
# See original article by Gonzalez et al. (2005)
data(readmission)
modJFM <- frailtyPenal(
Surv(time, event) ~ cluster(id) + as.factor(chemo) + terminal(death),
formula.terminalEvent = ~ as.factor(chemo), data = readmission,
hazard = "Weibull"
)
# Test both recurrent and death events
# # - Let us assume an underlying Poisson distribution for ni.type. The
# # empirical mean of the number of recurrent events per patients is: ni = 1.136476.
# # - For the null hypothesis, let us consider betaR.H0 = betaD.H0 = 0. For the
# # alternative hypothesis, we use the estimated parameters for betaD.HA and
# # betaR.HA.
# # - "Patients were actively followed up until June 2002" -> the follow-up
# # type is "UpToEnd".
# # - "The study took place in the Hospital de Bellvitge, [...] between
# # January 1996 and December 1998" -> the accrual time is approximately 3 years
# # - We can assume that the study duration is approximately 6 years
ni <- 1.136476
ni.type <- "Pois"
Acc.Dur <- 3 * 365.25 # time unit = days
FUP <- 6 * 365.25 # same as above
betaR.HA <- as.numeric(modJFM$coef[1]) # else "Named numeric"
betaD.HA <- as.numeric(modJFM$coef[2]) # same as above
med <- modJFM$scale.weib * log(2)^(1 / modJFM$shape.weib)
medianR.H0 <- med[1]
medianD.H0 <- med[2]
shapeR.W <- modJFM$shape[1]
shapeD.W <- modJFM$shape[2]
theta <- modJFM$theta
alpha <- modJFM$alpha
Npts <- length(unique(readmission[, "id"])) # 403 patients
nTreated <- length(unique(readmission[readmission$chemo == "Treated", "id"])) #217 treated patients
ratio <- nTreated / (Npts - nTreated)
JFM.power(
Npts = Npts, ni = ni, ni.type = ni.type,
Acc.Dur = Acc.Dur, FUP = FUP, medianR.H0 = medianR.H0, medianD.H0 = medianD.H0,
betaTest.type = "joint", betaR.HA = betaR.HA, betaD.HA = betaD.HA,
shapeR.W = shapeR.W, shapeD.W = shapeD.W, theta = theta, alpha = alpha,
ratio = ratio
) # power ~ 92%
# --------------------------------------------------
# Required sample size under the same setting
# --------------------------------------------------
# Here, let us consider that readmission is a “pilot study” with 403 patients,
# from which we estimate parameters. Under this scenario, let us compute the
# needed sample size, but to achieve an 80% power.
JFM.ssize(
power = 0.80, ni = ni, ni.type = ni.type,
Acc.Dur = Acc.Dur, FUP = FUP, medianR.H0 = medianR.H0, medianD.H0 = medianD.H0,
betaTest.type = "joint", betaR.HA = betaR.HA, betaD.HA = betaD.HA,
shapeR.W = shapeR.W, shapeD.W = shapeD.W, theta = theta, alpha = alpha,
ratio = ratio
) # 289 patients needed under the same settings vs. 403
# }
Run the code above in your browser using DataLab