Skip to contents

Subsets the data to all subjects randomized by the specified date, and prepares the data for analysis. This is a wrapper for cut_data_by_date() typically used with a date determined by cut_date_for_completers().

Usage

cut_completers(data, cut_date, event_gap = 0)

Arguments

data

Data generated by nb_sim().

cut_date

Calendar time (relative to trial start) at which to cut the data.

event_gap

Gap duration after each event during which no new events are counted. Can be a numeric value (default 0) or a function returning a numeric value. The time at risk is reduced by the sum of these gaps (truncated by the cut date).

Value

A data frame with one row per subject randomized prior to cut_date. Contains the truncated follow-up time (tte) and total number of observed events (events).

Examples

enroll_rate <- data.frame(rate = 20 / (5 / 12), duration = 5 / 12)
fail_rate <- data.frame(treatment = c("Control", "Experimental"), rate = c(0.5, 0.3))
dropout_rate <- data.frame(
  treatment = c("Control", "Experimental"),
  rate = c(0.1, 0.05), duration = c(100, 100)
)
sim <- nb_sim(enroll_rate, fail_rate, dropout_rate, max_followup = 2, n = 20)
# Find date when 5 subjects have completed
date_5 <- cut_date_for_completers(sim, 5)
# Get analysis dataset for this cut date (includes partial follow-up)
cut_completers(sim, date_5)
#>    id    treatment enroll_time      tte tte_total events
#> 1   1 Experimental  0.04940508 2.000000  2.000000      0
#> 2   2 Experimental  0.06333562 1.262942  1.262942      0
#> 3   3      Control  0.06753399 2.000000  2.000000      0
#> 4   4      Control  0.10178320 2.000000  2.000000      2
#> 5   5      Control  0.20960215 1.925256  1.925256      0
#> 6   6 Experimental  0.22735665 2.000000  2.000000      0
#> 7   7      Control  0.23706007 2.000000  2.000000      1
#> 8   8 Experimental  0.24841513 1.988645  1.988645      2
#> 9   9 Experimental  0.24890959 1.988150  1.988150      0
#> 10 10 Experimental  0.26921564 1.967844  1.967844      1
#> 11 11      Control  0.29635022 1.940710  1.940710      1
#> 12 12      Control  0.33700966 1.900050  1.900050      3
#> 13 13      Control  0.36424507 1.872815  1.872815      5
#> 14 14      Control  0.40795392 1.829106  1.829106      0
#> 15 15 Experimental  0.43395293 1.803107  1.803107      2
#> 16 16 Experimental  0.43813914 1.798921  1.798921      2
#> 17 17      Control  0.47884640 1.758214  1.758214      0
#> 18 18      Control  0.47958931 1.757471  1.757471      1
#> 19 19 Experimental  0.48774864 1.749311  1.749311      1
#> 20 20 Experimental  0.49560514 1.741455  1.741455      0