Simulate attained-age survival data under a Cox PH model
Source:R/sim_cox_age_data.R
sim_cox_age_data.RdSimulate attained-age survival data under a Cox PH model
Usage
sim_cox_age_data(
n,
entry_age,
censor_age,
beta,
covariates,
baseline_hazard = 0.004,
baseline_hazard_by_age = NULL,
target_avg_baseline_hazard = NULL
)Arguments
- n
Integer, number of subjects.
- entry_age
Numeric scalar or length-n vector of entry ages.
- censor_age
Numeric scalar or length-n vector of administrative censoring ages.
- beta
Numeric vector of regression coefficients with length p.
- covariates
Numeric matrix or data.frame with n rows and p columns.
- baseline_hazard
Optional positive scalar specifying a constant baseline hazard over attained age. Must be NULL if
baseline_hazard_by_ageis provided.- baseline_hazard_by_age
Optional data.frame with columns age_lo, age_hi, hazard defining piecewise-constant baseline hazard over attained age intervals [age_lo, age_hi). Must be NULL if
baseline_hazardis provided.- target_avg_baseline_hazard
Optional positive scalar. If provided, rescales the baseline hazard so the cohort-weighted average equals this value.