Skip to contents

Get Date at Which an Event Count is Reached

Usage

getCutDateForCount(x, count)

Arguments

x

a time-to-event dataset, e.g., generated by simPWSurv

count

event count at which dataset is to be cut off for analysis

Value

The a numeric value with the cte from the input dataset at which the targeted event count is reached, or if the final event count is never reached, the final cte at which an event occurs.

Examples

library(dplyr)
library(tibble)

# Use default enrollment and calendar cut date for 50 events in Positive stratum
x <- simPWSurv(
  n = 200,
  strata = tibble(Stratum = c("Positive", "Negative"),
                  p = c(.5, .5)),
  failRates = tibble(Stratum = rep(c("Positive","Negative"), 2),
                     period = rep(1, 4),
                     Treatment = c(rep("Control", 2), rep("Experimental", 2)),
                     duration = rep(1, 4),
                     rate = log(2) / c(6, 9, 9, 12)),
  dropoutRates = tibble(Stratum = rep(c("Positive", "Negative"),2),
                        period = rep(1, 4),
                        Treatment = c(rep("Control", 2), rep("Experimental", 2)),
                        duration = rep(1, 4),
                        rate = rep(.001, 4)))

d <- getCutDateForCount(x %>% filter(Stratum == "Positive"), count = 50)

y <- cutData(x, cut_date = d)
table(y$Stratum, y$event)
#>           
#>             0  1
#>   Negative 44 46
#>   Positive 51 50