Onesample.generate.sequential: Function to simulate one-sample composite endpoint data under...

View source: R/Onesample.generate.sequential.R

Onesample.generate.sequentialR Documentation

Function to simulate one-sample composite endpoint data under staggered entry.

Description

Simulate one-sample composite endpoints data with recurrent events and a terminal event under two time scales: event time t and calendar time s. A uniform recruitment period is assumed, and the function returns all observed data available at a specified calendar time. Recurrent event occurrences are generated from an underlying Poisson process with subject-specific Gamma frailty.

Usage

Onesample.generate.sequential(
  beta = c(0, 0),
  lambda_0 = 1.15,
  size,
  recruitment = 3,
  calendar = 5,
  random.censor.rate,
  seed
)

Arguments

beta

Regression coefficient vector for the proportional mean functions, the default is c(0,0), corresponds to no covariates effects.

lambda_0

Rate parameter for the underlying Poisson process, default is 1.15 for a mean frequeny of 2 at t=2.

size

Total sample size.

recruitment

Length of the recruitment period (in years), default is 3.

calendar

Calendar time of the end of the trial (in years), default is 5.

random.censor.rate

Rate parameter for independent random right censoring.

seed

Seed for reproducibility.

Value

A data frame in long format containing simulated composite endpoint data. Each subject may contributing multiple rows corresponding to recurrent events, a terminal event (death), or censoring. The data include:

  • id: Subject identifier.

  • e: Enrollment time on the calendar scale.

  • event_time_cal: Cumulative event time on the calendar scale.

  • status: Event indicator with values 2=recurrent event, 1=death, and 0=censoring.

  • Z1, Z2: Simulated covariates used in the proportional mean model.

  • tau_star: Subject-specific stopping time, the last event observed in [0, tau_star] is classified as death.

  • death: Binary indicator for death.

  • recurrent: Binary indicator for recurrent events.

  • event: Binary event indicator, event = death + recurrent.

  • calendar: Calendar time cutoff used to generate the returned data.

  • lambda_0: Baseline Poisson process rate parameter.

  • lambda_star: Rate parameter of an exponential distribution in generating tau_star.

  • gamma_scale, gamma_shape: Parameters of the Gamma distribution used to generate subject-specific frailty terms.

References

Mao L, Lin DY. Semiparametric regression for the weighted composite endpoint of recurrent and terminal events. Biostatistics. 2016 Apr; 17(2) :390-403.

Examples

# Generate one-sample composite endpoint data
df <- Onesample.generate.sequential(size = 200,
recruitment = 3, calendar = 5,
random.censor.rate = 0.05, seed = 1123)

gsMeanFreq documentation built on Feb. 17, 2026, 1:07 a.m.