Description Usage Arguments Details Value Author(s) References Examples

View source: R/ynegbinomsize.R

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.

1 2 3 4 |

`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 *τ_{min}* and *τ_{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=τ_{min}*. For type 2 follow-up *T_f=min(C,τ_{min})*. For type 3 follow-up, *T_f=min(R+τ_{min}-E,τ_{max})*. For type 4 follow-up, *T_f=min(R+τ_{min}-E,τ_{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,…,n*. Suppose that *Y_i* follows a negative binomial distribution such that

*P(Y_i=y\mid Z_i=j)=\frac{Γ(y+1/k_j)}{Γ(y+1)Γ(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

*\log(u_i)=\log(t_i)+β_0+β_1 Z_i.*

Let *\hat{β}_0* and *\hat{β}_1* be the MLE of *β_0* and *β_1*.
The varaince of *\hat{β}_1* is

*\mbox{var}(\hat{β}_1)=1/\tilde{a}_0(r_0)+1/\tilde{a}_1(r_1)*

where

*\tilde{a}_j(r)=∑_{i=1}^n I(Z_i=j)k_jrt_i/(1+k_jrt_i), \hspace{0.5cm}j=0,1,*

and *k_j, j=0,1* are the dispersion parameters for control *j=0* and treatment *j=1*. Note that Zhu and Lakkis (2014) use

*a_j(r)=∑_{i=1}^n I(Z_i=j)k_jrE(t_i)/\{1+k_jrE(t_i)\}, *

to replace *\tilde{a}_j(r)*, *j=0,1*. Using Jensen's inequality, we can show *a_j(r)≥ \tilde{a}_j(r)*, which means
Zhu and Lakkis's method will underestimate variance of *\hat{β}_1*, which leads to either smaller than required sample size or inflated power. For comparison, I provide sample sizes under both *\tilde{a}_j(r)* and *a_j(r)*.

Zhu and Lakkis (2014) discuss three types of the variance under the null. The first way is to set *\tilde{r}_0=\tilde{r}_1=r_0*, using event rate from the control group. The second way is to set *\tilde{r}_0=r_0, \tilde{r}_1=r_1*, using true event rates. The third way is to set *\tilde{r}_0=\tilde{r}_1=\tilde{r}*, where *\tilde{r}=π_1 r_1+π_0 r_0*, 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.

1 2 3 4 5 6 7 8 9 | ```
##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
``` |

```
[1] 206 250 236
[1] 228 273 258
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.