This will calculate the power for the negative binomial distribution for the 2-sample case under different follow-up scenarios: 1: fixed follow-up, 2: fixed follow-up with drop-out, 3: variable follow-up with a minimum fu and a maximum fu, 4: variable follow-up with a minimum fu and a maximum fu and drop-out.
ynegbinompowersim(nsize=200,r0=1.0,r1=0.5,shape0=1,shape1=shape0,pi1=0.5,
alpha=0.05,twosided=1,fixedfu=1,type=1,u=c(0.5,0.5,1),ut=c(0.5,1.0,1.5),
tfix=ut[length(ut)]+0.5,maxfu=10.0,tchange=c(0,0.5,1),
ratec1=c(0.15,0.15,0.15),ratec0=ratec1,rn=10000)total number of subjects in two groups
event rate for the control
event rate for the treatment
dispersion parameter for the control
dispersion parameter for the treatment
allocation prob for the treatment
type-1 error
1: two-side, others: one-sided
fixed follow-up time for each patient
follow-up time type, type=1: fixed fu with fu time fixedfu; type=2: same as 1 but subject to censoring; type=3: depending on entry time, minimum fu is fixedfu and maximum fu is maxfu; type=4: same as 3 but subject to censoring
recruitment rate
recruitment interval, must have the same length as u
fixed study duration, often equals to recruitment time plus minimum follow-up
maximum follow-up time, should not be greater than tfix
a strictly increasing sequence of time points starting from zero at which the drop-out rate changes. The first element of tchange must be zero. The above rates and tchange must have the same length.
piecewise constant drop-out rate for the treatment
piecewise constant drop-out rate for the control
Number of repetitions
simulation power (in percentage)
Let \(\tau_{min}\) and \(\tau_{max}\) correspond to the minimum follow-up time fixedfu and the maximum follow-up time maxfu. Let \(T_f\), \(C\), \(E\) and \(R\) be the follow-up time, the drop-out time, the study entry time and the total recruitment period(\(R\) is the last element of ut). For type 1 follow-up, \(T_f=\tau_{min}\). For type 2 follow-up \(T_f=min(C,\tau_{min})\). For type 3 follow-up, \(T_f=min(R+\tau_{min}-E,\tau_{max})\). For type 4 follow-up, \(T_f=min(R+\tau_{min}-E,\tau_{max},C)\). Let \(f\) be the density of \(T_f\).
Suppose that \(Y_i\) is the number of event obsevred in follow-up time \(t_i\) for patient \(i\) with treatment assignment \(Z_i\), \(i=1,\ldots,n\). Suppose that \(Y_i\) follows a negative binomial distribution such that
$$P(Y_i=y\mid Z_i=j)=\frac{\Gamma(y+1/k_j)}{\Gamma(y+1)\Gamma(1/k_j)}\Bigg(\frac{k_ju_i}{1+k_ju_i}\Bigg)^y\Bigg(\frac{1}{1+k_ju_i}\Bigg)^{1/k_j},$$
where \(k_j, j=0,1\) are the dispersion parameters for control \(j=0\) and treatment \(j=1\) and
$$\log(u_i)=\log(t_i)+\beta_0+\beta_1 Z_i.$$
The data will be gnerated according to the above model. Note that the piecewise exponential distribution and the piecewise uniform distribution are genrated using R package PWEALL functions "rpwe" and "rpwu", respectively.
The parameters in the model are estimated by MLE using the R package MASS function "glm.nb".
# NOT RUN {
##calculating the sample sizes
abc=ynegbinompowersim(nsize=200,r0=1.0,r1=0.5,shape0=1,
pi1=0.5,alpha=0.05,twosided=1,fixedfu=1,
type=4,u=c(0.5,0.5,1),ut=c(0.5,1.0,1.5),
tchange=c(0,0.5,1),
ratec1=c(0.15,0.15,0.15),rn=10)
###Power
abc$power
# }
Run the code above in your browser using DataLab