Simulate survival time given age and a vector of HAQ scores

sim_survtime(n = 1000, age = 55, haq0 = 1, male = 0,
  haq = rep(haq0, 12/cycle_length * (100 - age + 1)),
  ltfemale = iviRA::lifetable.female, ltmale = iviRA::lifetable.male,
  x_mort = haq0, logor = iviRA::mort.or$logor, cycle_length = 6,
  loghr = iviRA::mort.hr.haqdif$loghr)

Arguments

n

Number of observations

age

Age of patients. Length must be 1.

haq0

Baseline HAQ. Length must be 1.

male

Vector indicating patient gender (1 = male, 0 = female)

haq

Vector of HAQ scores (e.g. HAQ trajectory)

ltfemale

Lifetable for women. Must contain column 'age' for single-year of age and 'qx' for the probability of death at a given age.

ltmale

Identical to ltfemale but for men.

x_mort

Design matrix for mortality adjustment with odds ratios. Number of rows equal to n.

logor

Vector of log odds ratio mortality adjusters. Length equal to number of columns in x.

cycle_length

Length of model cycles in months. Default is 6 month cycles.

loghr

Log hazard ratio of impact of change in HAQ from baseline on mortality rate. A vector with each element denoting (in order) hazard ratio for \(month \le 6\), \(6 > month \le 12\), \(12 < month \le 24\), \(24 < month \le 36\), \(month > 36\).

Examples

set.seed(101) t <- seq(0, 45 * 2, .5) # 90 model cycles, or 45 years. haq.seq <- pmin(1.5 + .03 * t, 3) surv <- sim_survtime(n = 1000, age = 55, haq = haq.seq, male = 0) summary(surv)
#> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 55.00 66.50 73.00 72.39 78.50 93.00