This function censors a study after a pre-specified number of events occurred.

censoringByNumberEvents(data, eventNum, typeEvent)

Arguments

data

(data.frame)
illness-death data set in 1rowPatient format.

eventNum

(int)
number of events.

typeEvent

(string)
type of event. Possible values are PFS and OS.

Value

This function returns a data set that is censored after eventNum of typeEvent-events occurred.

Examples

transition1 <- weibull_transition(h01 = 1.2, h02 = 1.5, h12 = 1.6, p01 = 0.8, p02 = 0.9, p12 = 1)
transition2 <- weibull_transition(h01 = 1, h02 = 1.3, h12 = 1.7, p01 = 1.1, p02 = 0.9, p12 = 1.1)

simStudy <- getOneClinicalTrial(
  nPat = c(20, 20), transitionByArm = list(transition1, transition2),
  dropout = list(rate = 0.3, time = 10),
  accrual = list(param = "time", value = 7)
)
simStudyWide <- getDatasetWideFormat(simStudy)
censoringByNumberEvents(data = simStudyWide, eventNum = 20, typeEvent = "PFS")
#>    id trt     PFStime PFSevent      OStime CensoredOS OSevent recruitTime
#> 1   3   1 1.127056946        1 1.127056946          0       1   0.7429309
#> 2   5   1 1.593579126        0 1.593579126          1       0   2.9646064
#> 3   7   1 0.223508147        1 0.223508147          0       1   3.0262608
#> 4   8   1 2.483116191        1 2.486866495          0       1   1.8683394
#> 5  13   1 0.234099907        0 0.234099907          1       0   4.3240856
#> 6  14   1 0.411073411        1 1.697192985          0       1   2.2610827
#> 7  15   1 0.266230586        1 0.394330944          1       0   3.1541936
#> 8  16   1 0.018928459        1 0.244591839          1       0   4.3135937
#> 9  18   1 0.112501726        1 0.112501726          0       1   3.3479215
#> 10 20   1 0.359260647        1 0.628131688          1       0   3.9300538
#> 11 21   2 0.316858768        0 0.316858768          1       0   4.2413267
#> 12 22   2 1.357593783        1 1.357593783          1       0   3.2005917
#> 13 23   2 0.252229688        1 0.252229688          0       1   1.4496798
#> 14 24   2 0.054816005        0 0.054816005          1       0   4.5033695
#> 15 25   2 0.576754674        1 0.576754674          0       1   1.4123259
#> 16 26   2 0.115295696        1 0.115295696          0       1   0.8734048
#> 17 29   2 0.123387578        1 0.123387578          0       1   2.5367745
#> 18 30   2 0.277939909        1 0.277939909          0       1   2.4394640
#> 19 33   2 0.355767883        1 0.744432078          0       1   2.2880676
#> 20 35   2 0.107493309        1 0.107493309          0       1   2.4871808
#> 21 36   2 0.970763256        1 1.429349337          0       1   2.7119912
#> 22 37   2 0.005442567        1 0.005442567          0       1   4.4032067
#> 23 39   2 0.441030235        1 0.473158518          0       1   3.9459606
#> 24 40   2 0.374976614        1 0.374976614          0       1   3.9569277
#>    OStimeCal PFStimeCal
#> 1  1.8699879  1.8699879
#> 2  4.5581855  4.5581855
#> 3  3.2497689  3.2497689
#> 4  4.3552059  4.3514556
#> 5  4.5581855  4.5581855
#> 6  3.9582757  2.6721561
#> 7  3.5485245  3.4204242
#> 8  4.5581855  4.3325221
#> 9  3.4604233  3.4604233
#> 10 4.5581855  4.2893145
#> 11 4.5581855  4.5581855
#> 12 4.5581855  4.5581855
#> 13 1.7019095  1.7019095
#> 14 4.5581855  4.5581855
#> 15 1.9890806  1.9890806
#> 16 0.9887005  0.9887005
#> 17 2.6601621  2.6601621
#> 18 2.7174039  2.7174039
#> 19 3.0324997  2.6438355
#> 20 2.5946741  2.5946741
#> 21 4.1413405  3.6827544
#> 22 4.4086493  4.4086493
#> 23 4.4191191  4.3869908
#> 24 4.3319043  4.3319043