| Title: | Design and Monitoring of Clinical Trials with Negative Binomial Endpoint |
|---|---|
| Description: | Calculate various functions needed for design and monitoring clinical trials with negative binomial endpoint with variable follow-up. This version has a few changes compared to the previous version 1.0.0, including (1) correct a typo in Type 1 censoring, mtbnull=bnull and (2) restructure the code to account for shape parameter equal to zero, i.e. Poisson scenario. |
| Authors: | Xiaodong Luo [aut, cre], Sanofi [cph] |
| Maintainer: | Xiaodong Luo <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 2.0.0 |
| Built: | 2026-06-07 09:44:40 UTC |
| Source: | https://github.com/cran/NBDesign |
Calculate various functions needed for design and monitoring clinical trials with negative binomial endpoint with variable follow-up. This version has a few changes compared to the previous version 1.0.0, including (1) correct a typo in Type 1 censoring, mtbnull=bnull and (2) restructure the code to account for shape parameter equal to zero, i.e. Poisson scenario.
The DESCRIPTION file:
| Package: | NBDesign |
| Type: | Package |
| Version: | 2.0.0 |
| Date: | 2020-09-09 |
| Title: | Design and Monitoring of Clinical Trials with Negative Binomial Endpoint |
| Description: | Calculate various functions needed for design and monitoring clinical trials with negative binomial endpoint with variable follow-up. This version has a few changes compared to the previous version 1.0.0, including (1) correct a typo in Type 1 censoring, mtbnull=bnull and (2) restructure the code to account for shape parameter equal to zero, i.e. Poisson scenario. |
| Authors@R: | c( person(given="Xiaodong", family="Luo", email = "[email protected]", role =c("aut", "cre")), person("Sanofi", role = "cph")) |
| Depends: | R (>= 3.1.2) |
| Imports: | stats,PWEALL,MASS |
| License: | GPL (>= 2) |
| RoxygenNote: | 5.0.1 |
| LazyData: | true |
| NeedsCompilation: | no |
| Packaged: | 2020-09-09 12:59:08 UTC; marve |
| Author: | Xiaodong Luo [aut, cre], Sanofi [cph] |
| Maintainer: | Xiaodong Luo <[email protected]> |
| Repository: | https://marvels2031.r-universe.dev |
| Date/Publication: | 2020-09-10 05:30:22 UTC |
| RemoteUrl: | https://github.com/cran/NBDesign |
| RemoteRef: | HEAD |
| RemoteSha: | bdb7d54b1639ee5618df7da65c4f36b60dd363e6 |
Index of help topics:
NBDesign-package Design and Monitoring of Clinical Trials with
Negative Binomial Endpoint
negint2 A utility functon to calculate the mean
exposure under different scenarios
ynegbinompower Two-sample sample size calculation for negative
binomial distribution with variable follow-up
ynegbinompowersim Two-sample sample size calculation for negative
binomial distribution with variable follow-up
ynegbinomsize Two-sample sample size calculation for negative
binomial distribution with variable follow-up
Xiaodong Luo [aut, cre], Sanofi [cph]
Maintainer: Xiaodong Luo <[email protected]>
This will calculate the mean exposure under different scenarios: 2: fixed follow-up with drop-out, 3: variable follow-up with a maximum (maxfu), 4: variable follow-up with a maximum and drop-out
negint2(ux=0.5,fixedfu=1,type=2,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), ratec=c(0.15,0.15,0.15),eps=1.0e-03)negint2(ux=0.5,fixedfu=1,type=2,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), ratec=c(0.15,0.15,0.15),eps=1.0e-03)
ux |
the parameter a in (a*t)/(1+a*t) |
fixedfu |
the minimum follow-up time |
type |
follow-up type, type=2: fixed fu with fu time |
u |
recruitment rate |
ut |
recruitment interval, must have the same length as |
tfix |
fixed study duration, often equals to recruitment time plus minimum follow-up |
maxfu |
maximum follow-up time, should not be greater than |
tchange |
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 |
ratec |
piecewise constant drop-out rate |
eps |
error tolerance for the numerical intergration |
Let and correspond to the minimum follow-up time taumin and the maximum follow-up time taumax. Let , , and be the follow-up time, the drop-out time, the study entry time and the total recruitment period( is the last element of ut). For type 2 follow-up . For type 3 follow-up, . For type 4 follow-up, . Let be the density of . We calculate
and
where is the ux.
mt |
mean of (a*t)/(1+a*t) |
tt |
mean of t |
vt |
variance of t |
Xiaodong Luo
##calculating the exposure for type 4 follow-up exp4=negint2(ux=0.5,fixedfu=1,type=2,u=c(0.5,0.5,1),ut=c(0.5,1.0,1.5), tfix=2.0,maxfu=1.0,tchange=c(0,0.5,1), ratec=c(0.15,0.15,0.15),eps=1.0e-03) #mean exposure meanexp=exp4$tt #var exposure varexp=exp4$vt c(meanexp,sqrt(varexp)) #mean of (ux*t)/(1+ux*t) meanuxt=exp4$mt##calculating the exposure for type 4 follow-up exp4=negint2(ux=0.5,fixedfu=1,type=2,u=c(0.5,0.5,1),ut=c(0.5,1.0,1.5), tfix=2.0,maxfu=1.0,tchange=c(0,0.5,1), ratec=c(0.15,0.15,0.15),eps=1.0e-03) #mean exposure meanexp=exp4$tt #var exposure varexp=exp4$vt c(meanexp,sqrt(varexp)) #mean of (ux*t)/(1+ux*t) meanuxt=exp4$mt
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.
ynegbinompower(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,eps=1.0e-03)ynegbinompower(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,eps=1.0e-03)
nsize |
total number of subjects in two groups |
r0 |
event rate for the control |
r1 |
event rate for the treatment |
shape0 |
dispersion parameter for the control |
shape1 |
dispersion parameter for the treatment |
pi1 |
allocation prob for the treatment |
alpha |
type-1 error |
twosided |
1: two-side, others: one-sided |
fixedfu |
fixed follow-up time for each patient |
type |
follow-up time type, type=1: fixed fu with fu time |
u |
recruitment rate |
ut |
recruitment interval, must have the same length as |
tfix |
fixed study duration, often equals to recruitment time plus minimum follow-up |
maxfu |
maximum follow-up time, should not be greater than |
tchange |
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 |
ratec1 |
piecewise constant drop-out rate for the treatment |
ratec0 |
piecewise constant drop-out rate for the control |
eps |
error tolerance for the numerical intergration |
Let and correspond to the minimum follow-up time fixedfu and the maximum follow-up time maxfu. Let , , and be the follow-up time, the drop-out time, the study entry time and the total recruitment period( is the last element of ut). For type 1 follow-up, . For type 2 follow-up . For type 3 follow-up, . For type 4 follow-up, . Let be the density of .
Suppose that is the number of event obsevred in follow-up time for patient with treatment assignment , . Suppose that follows a negative binomial distribution such that
where
Let and be the MLE of and .
The varaince of is
where
and are the dispersion parameters for control and treatment . Note that Zhu and Lakkis (2014) use
to replace , . Using Jensen's inequality, we can show , which means
Zhu and Lakkis's method will underestimate variance of , which leads to either smaller than required sample size or inflated power. For comparison, I provide sample sizes under both and .
Zhu and Lakkis (2014) discuss three types of the variance under the null. The first way is to set , using event rate from the control group. The second way is to set , using true event rates. The third way is to set , where , using maximum likelihood estimation.
Therefore, for each type of follow-up, there are 3 sample sizes calculated (because there are 3 varainces under the null) for with and without approximation of Zhu and Lakkis (2014).
Note that PASS14.0 provides 3 ways of null varaince with the default being the MLE. PASS does not allow different dispersion parameters between treatmetn and control. EAST only provides the second way of null varaince but allows for different dispersion parameters. Both of these softwares base on the approximatin method of Zhu and Lakkis (2014), which underestimate the required sample sizes.
tildeXPWR |
powers (in percentage) not based on current approach, i.e. not based on the Zhu and Lakkis's approximation |
XPWR |
powers (in percentage) based on on the Zhu and Lakkis's approximation |
tildemineffsize |
minimum detectable effect sizes not based on approximation |
mineffsize |
minimum detectable effect sizes based on approximation |
Exposure |
mean exposure under different follow-up types with element 1 for control, element 2 for treatment and element 3 for overall. |
SDExp |
Sd of the exposure under different follow-up types with element 1 for control, element 2 for treatment and column 3 for overall. |
Xiaodong Luo
Zhu~H and Lakkis~H. Sample size calculation for comparing two negative binomial rates. Statistics in Medicine 2014, 33: 376-387.
##calculating the sample sizes abc=ynegbinompower(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),eps=1.0e-03) ###Zhu and Lakkis's powers (i.e. with approximation) abc$XPWR ###Our powers (i.e. without approximation) abc$tildeXPWR##calculating the sample sizes abc=ynegbinompower(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),eps=1.0e-03) ###Zhu and Lakkis's powers (i.e. with approximation) abc$XPWR ###Our powers (i.e. without approximation) abc$tildeXPWR
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)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)
nsize |
total number of subjects in two groups |
r0 |
event rate for the control |
r1 |
event rate for the treatment |
shape0 |
dispersion parameter for the control |
shape1 |
dispersion parameter for the treatment |
pi1 |
allocation prob for the treatment |
alpha |
type-1 error |
twosided |
1: two-side, others: one-sided |
fixedfu |
fixed follow-up time for each patient |
type |
follow-up time type, type=1: fixed fu with fu time |
u |
recruitment rate |
ut |
recruitment interval, must have the same length as |
tfix |
fixed study duration, often equals to recruitment time plus minimum follow-up |
maxfu |
maximum follow-up time, should not be greater than |
tchange |
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 |
ratec1 |
piecewise constant drop-out rate for the treatment |
ratec0 |
piecewise constant drop-out rate for the control |
rn |
Number of repetitions |
Let and correspond to the minimum follow-up time fixedfu and the maximum follow-up time maxfu. Let , , and be the follow-up time, the drop-out time, the study entry time and the total recruitment period( is the last element of ut). For type 1 follow-up, . For type 2 follow-up . For type 3 follow-up, . For type 4 follow-up, . Let be the density of .
Suppose that is the number of event obsevred in follow-up time for patient with treatment assignment , . Suppose that follows a negative binomial distribution such that
where are the dispersion parameters for control and treatment and
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".
power |
simulation power (in percentage) |
Xiaodong Luo
##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##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
This will calculate the sample size 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.
ynegbinomsize(r0=1.0,r1=0.5,shape0=1,shape1=shape0,pi1=0.5, alpha=0.05,twosided=1,beta=0.2,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,eps=1.0e-03)ynegbinomsize(r0=1.0,r1=0.5,shape0=1,shape1=shape0,pi1=0.5, alpha=0.05,twosided=1,beta=0.2,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,eps=1.0e-03)
r0 |
event rate for the control |
r1 |
event rate for the treatment |
shape0 |
dispersion parameter for the control |
shape1 |
dispersion parameter for the treatment |
pi1 |
allocation prob for the treatment |
alpha |
type-1 error |
twosided |
1: two-side, others: one-sided |
beta |
tyep-2 error |
fixedfu |
fixed follow-up time for each patient |
type |
follow-up time type, type=1: fixed fu with fu time |
u |
recruitment rate |
ut |
recruitment interval, must have the same length as |
tfix |
fixed study duration, often equals to recruitment time plus minimum follow-up |
maxfu |
maximum follow-up time, should not be greater than |
tchange |
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. |
ratec1 |
piecewise constant drop-out rate for the treatment. The rate and |
ratec0 |
piecewise constant drop-out rate for the control. The rate and |
eps |
error tolerance for the numerical intergration |
Let and correspond to the minimum follow-up time fixedfu and the maximum follow-up time maxfu. Let , , and be the follow-up time, the drop-out time, the study entry time and the total recruitment period( is the last element of ut). For type 1 follow-up, . For type 2 follow-up . For type 3 follow-up, . For type 4 follow-up, . Let be the density of .
Suppose that is the number of event obsevred in follow-up time for patient with treatment assignment , . Suppose that follows a negative binomial distribution such that
where
Let and be the MLE of and .
The varaince of is
where
and are the dispersion parameters for control and treatment . Note that Zhu and Lakkis (2014) use
to replace , . Using Jensen's inequality, we can show , which means
Zhu and Lakkis's method will underestimate variance of , which leads to either smaller than required sample size or inflated power. For comparison, I provide sample sizes under both and .
Zhu and Lakkis (2014) discuss three types of the variance under the null. The first way is to set , using event rate from the control group. The second way is to set , using true event rates. The third way is to set , where , using maximum likelihood estimation.
Therefore, for each type of follow-up, there are 3 sample sizes calculated (because there are 3 varainces under the null) for with and without approximation of Zhu and Lakkis (2014).
Note that PASS14.0 provides 3 ways of null varaince with the default being the MLE. PASS does not allow different dispersion parameters between treatmetn and control. EAST only provides the second way of null varaince but allows for different dispersion parameters. Both of these softwares base on the approximatin method of Zhu and Lakkis (2014), which underestimate the required sample sizes.
tildeXN |
sample sizes based on current approach, i.e. not based on the Zhu and Lakkis's approximation |
XN |
sample sizes based on the Zhu and Lakkis's approximation |
Exposure |
mean exposure under different follow-up types with element 1 for control, element 2 for treatment and element 3 for overall. |
SDExp |
Sd of the exposure under different follow-up types with element 1 for control, element 2 for treatment and column 3 for overall. |
Xiaodong Luo
Zhu~H and Lakkis~H. Sample size calculation for comparing two negative binomial rates. Statistics in Medicine 2014, 33: 376-387.
##calculating the sample sizes abc=ynegbinomsize(r0=1.0,r1=0.5,shape0=1,pi1=0.5,alpha=0.05,twosided=1, beta=0.2,fixedfu=1,type=4,u=c(0.5,0.5,1),ut=c(0.5,1.0,1.5), tfix=1.5,maxfu=1,tchange=c(0,0.5,1),ratec1=c(0.15,0.15,0.15), eps=1.0e-03) ###Zhu and Lakkis's sample sizes (i.e. with approximation) abc$XN ###Our sample sizes (i.e. without approximation) abc$tildeXN##calculating the sample sizes abc=ynegbinomsize(r0=1.0,r1=0.5,shape0=1,pi1=0.5,alpha=0.05,twosided=1, beta=0.2,fixedfu=1,type=4,u=c(0.5,0.5,1),ut=c(0.5,1.0,1.5), tfix=1.5,maxfu=1,tchange=c(0,0.5,1),ratec1=c(0.15,0.15,0.15), eps=1.0e-03) ###Zhu and Lakkis's sample sizes (i.e. with approximation) abc$XN ###Our sample sizes (i.e. without approximation) abc$tildeXN