Simulate survival data for MaxSPRT computation

simulateMaxSprtData(
  n = 10000,
  pExposure = 0.5,
  backgroundHazard = 0.001,
  tar = 10,
  nullMu = 0.2,
  nullSigma = 0.2,
  maxT = 100,
  looks = 10,
  numberOfNegativeControls = 50,
  numberOfPositiveControls = 1,
  positiveControlEffectSize = 4
)

Arguments

n

Number of subjects.

pExposure

Probability of being in target cohort.

backgroundHazard

Background hazard (risk of the outcome per day).

tar

Time at risk for each exposure

nullMu

Null distribution mean (at log HR scale)

nullSigma

Null distribution SD (at log HR scale)

maxT

Maximum time to simulate.

looks

Number of (evenly spaced) looks at the data.

numberOfNegativeControls

Number of negative controls to simulate.

numberOfPositiveControls

Number of positive controls to simulate.

positiveControlEffectSize

The true effect size of the positive controls.

Value

A data frame with 5 variables:

time

Time from index date to either the event or end of observation, whichever came first

outcome

Whether the outcome occurred (1) or not (0)

exposure

Whether the subject was exposed (TRUE) or not (FALSE)

lookTime

The time point when the look occurred.

outcomeId

A unique identifier for data corresponding to a single outcome. Lower IDs indicate negative controls, higher IDs indicate the positive control

Details

Simulate survival data for negative and positive controls. The data provides multiple looks at data accruing over time, with each look having more data than the one before. Systematic error for each outcome is drawn from the prespecified null distribution.

The outcome IDs are assigned sequentially starting at 1, with the first IDs used for the negative controls, and the latter IDs used for the positive controls.

Examples

data <- simulateMaxSprtData(n = 1000)
head(data)
#>        time outcome exposure lookTime outcomeId
#> 5  8.661996       0     TRUE       10         1
#> 11 9.386998       0     TRUE       10         1
#> 20 0.498716       0    FALSE       10         1
#> 22 7.061753       0     TRUE       10         1
#> 85 3.030036       0     TRUE       10         1
#> 98 2.959496       0     TRUE       10         1