Learn R Programming

gsDesignNB (version 0.2.6)

cut_data_by_date: Cut simulated trial data at a calendar date

Description

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

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

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

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

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.

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.

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

Run this code
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)

Run the code above in your browser using DataLab