Learn R Programming

gsDesignNB (version 0.2.6)

sample_size_nbinom: Sample size calculation for negative binomial distribution

Description

Computes the sample size for comparing two treatment groups assuming a negative binomial distribution for the outcome.

Usage

sample_size_nbinom(
  lambda1,
  lambda2,
  dispersion,
  power = NULL,
  alpha = 0.025,
  sided = 1,
  ratio = 1,
  rr0 = 1,
  accrual_rate,
  accrual_duration,
  trial_duration,
  dropout_rate = 0,
  max_followup = NULL,
  event_gap = NULL
)

Value

An object of class sample_size_nbinom_result, which is a list containing:

inputs

Named list of the original function arguments.

n1

Sample size for group 1

n2

Sample size for group 2

n_total

Total sample size

alpha

Significance level

sided

One-sided or two-sided test

power

Power of the test

exposure

Average exposure time used in calculation (calendar time). Vector of length 2.

exposure_at_risk_n1

Average at-risk exposure time for group 1 (accounts for event gap)

exposure_at_risk_n2

Average at-risk exposure time for group 2 (accounts for event gap)

events_n1

Expected number of events in group 1

events_n2

Expected number of events in group 2

total_events

Total expected number of events

variance

Variance of the log rate ratio

accrual_rate

Accrual rate used in calculation

accrual_duration

Accrual duration used in calculation

Arguments

lambda1

Rate in group 1 (control).

lambda2

Rate in group 2 (treatment).

dispersion

Dispersion parameter k such that \(\mathrm{Var}(Y) = \mu + k \mu^2\). Note that this is equivalent to 1/size in R's stats::rnbinom() parameterization.

power

Power of the test (1 - beta). Default is 0.9.

alpha

Significance level. Default is 0.025.

sided

One-sided or two-sided test. 1 for one-sided, 2 for two-sided. Default is 1.

ratio

Allocation ratio n2/n1. Default is 1.

rr0

Rate ratio under the null hypothesis (lambda2/lambda1). Default is 1 (superiority). For non-inferiority, use a value > 1 (e.g., 1.1). For super-superiority, use a value < 1 (e.g., 0.8).

accrual_rate

Vector of accrual rates (patients per unit time).

accrual_duration

Vector of durations for each accrual rate. Must be same length as accrual_rate.

trial_duration

Total planned duration of the trial. If trial_duration is less than the sum of accrual_duration, accrual is truncated at trial_duration.

dropout_rate

Dropout rate (hazard rate). Default is 0. Can be a vector of length 2.

max_followup

Maximum follow-up time for any patient. Default is NULL (infinite).

event_gap

Gap duration after each event during which no new events are counted. Default is NULL (no gap). If provided, the effective event rate is reduced.

References

Zhu, H., & Lakkis, H. (2014). Sample size calculation for comparing two negative binomial rates. Statistics in Medicine, 33(3), 376--387. tools:::Rd_expr_doi("10.1002/sim.5947")

Friede, T., & Schmidli, H. (2010). Blinded sample size reestimation with negative binomial counts in superiority and non-inferiority trials. Methods of Information in Medicine, 49(06), 618--624. tools:::Rd_expr_doi("10.3414/ME09-02-0060")

Mütze, T., Glimm, E., Schmidli, H., & Friede, T. (2019). Group sequential designs for negative binomial outcomes. Statistical Methods in Medical Research, 28(8), 2326--2347. tools:::Rd_expr_doi("10.1177/0962280218773115")

See Also

vignette("sample-size-nbinom", package = "gsDesignNB") for a detailed explanation of the methodology.

Examples

Run this code
# Calculate sample size for lambda1 = 0.5, lambda2 = 0.3, dispersion = 0.1
# with fixed recruitment of 10/month for 20 months, 24 month trial duration
x <- sample_size_nbinom(
  lambda1 = 0.5, lambda2 = 0.3, dispersion = 0.1, power = 0.8,
  accrual_rate = 10, accrual_duration = 20, trial_duration = 24
)
class(x)
summary(x)

# With piecewise accrual
# 5 patients/month for 3 months, then 10 patients/month for 3 months
# Trial ends at month 12.
x2 <- sample_size_nbinom(
  lambda1 = 0.5, lambda2 = 0.3, dispersion = 0.1, power = 0.8,
  accrual_rate = c(5, 10), accrual_duration = c(3, 3),
  trial_duration = 12
)
summary(x2)

Run the code above in your browser using DataLab