Skip to contents

Censors follow-up at a specified calendar time and aggregates events per subject. Returns one row per subject randomized before the cut date, with the total number of observed events and follow-up times.

Usage

cut_data_by_date(data, cut_date, event_gap = 0, ...)

# Default S3 method
cut_data_by_date(data, cut_date, event_gap = 0, ...)

# S3 method for class 'nb_sim_data'
cut_data_by_date(data, cut_date, event_gap = 0, ...)

# S3 method for class 'nb_sim_seasonal'
cut_data_by_date(data, cut_date, event_gap = 0, ...)

Arguments

data

Data generated by nb_sim().

cut_date

Calendar time (relative to trial start) at which to censor follow-up.

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).

...

Additional arguments passed to methods.

Value

A data frame with one row per subject randomized prior to cut_date containing:

id

Subject identifier

treatment

Treatment group

enroll_time

Time of enrollment relative to trial start

tte

Time at risk (total follow-up minus event gap periods)

tte_total

Total follow-up time (calendar time, not adjusted for gaps)

events

Number of observed events

A data frame with one row per subject randomized prior to cut_date. This method stops with an error for unsupported classes.

A data frame with one row per subject randomized prior to cut_date. Includes total events and follow-up time within the cut window.

A data frame with one row per subject randomized prior to cut_date. Includes season and follow-up time within the cut window.

Methods (by class)

  • cut_data_by_date(default): Default method.

  • cut_data_by_date(nb_sim_data): Method for nb_sim data.

  • cut_data_by_date(nb_sim_seasonal): Method for nb_sim_seasonal data.

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)
cut_data_by_date(sim, cut_date = 1)
#>    id    treatment enroll_time       tte tte_total events
#> 1   1 Experimental  0.02373508 0.9762649 0.9762649      1
#> 2   2 Experimental  0.02518861 0.9748114 0.9748114      1
#> 3   3      Control  0.03072470 0.3479680 0.3479680      1
#> 4   4      Control  0.03118814 0.9688119 0.9688119      0
#> 5   5 Experimental  0.03422514 0.9657749 0.9657749      0
#> 6   6 Experimental  0.09750120 0.9024988 0.9024988      0
#> 7   7      Control  0.10103810 0.8989619 0.8989619      0
#> 8   8      Control  0.11866510 0.5366065 0.5366065      0
#> 9   9 Experimental  0.12293590 0.8770641 0.8770641      0
#> 10 10      Control  0.12667913 0.8733209 0.8733209      1
#> 11 11 Experimental  0.13747740 0.8625226 0.8625226      0
#> 12 12      Control  0.15148053 0.8485195 0.8485195      0
#> 13 13 Experimental  0.16243134 0.8375687 0.8375687      0
#> 14 14 Experimental  0.19081107 0.8091889 0.8091889      0
#> 15 15      Control  0.22187134 0.7781287 0.7781287      0
#> 16 16      Control  0.27130803 0.7286920 0.7286920      0
#> 17 17 Experimental  0.27780731 0.7221927 0.7221927      0
#> 18 18 Experimental  0.28205747 0.7179425 0.7179425      1
#> 19 19      Control  0.28859896 0.7114010 0.7114010      0
#> 20 20      Control  0.30964929 0.6903507 0.6903507      1