Skip to contents

Generate hazard ratio with prediction intervals from parametric bootstrap simulation

Usage

calc_ave_hr_pi(
  sim,
  trt,
  group = NULL,
  pi.range = 0.95,
  calc.obs = TRUE,
  trt.assign = c("default", "reverse"),
  simtimelast = NULL,
  boot.subj = TRUE
)

calc_hr_pi(
  sim,
  trt,
  group = NULL,
  pi.range = 0.95,
  calc.obs = TRUE,
  trt.assign = c("default", "reverse")
)

Arguments

sim

A survparamsim class object generated by surv_param_sim() function.

trt

A string to specify which column define treatment status to calculate HR.

group

Optional string(s) to specify grouping variable(s). You will have faceted histograms for these variables in plot_hr_pi() function.

pi.range

Prediction interval for simulated HR.

calc.obs

A logical to specify whether to calculate HR for the observed data. Need be set as FALSE if survival information in the newdata is dummy.

trt.assign

Specify which of the categories of trt need to be considered as control group. See details below if you have more than two categories.

simtimelast

An optional numeric to specify duration for average HR calculation. If NULL (default), the last observation time in the newdata will be used.

boot.subj

Boolean to specify whether bootstrapping of subjects are performed before calculating HR. Default TRUE.

Details

calc_hr_pi() calculate hazard ratio using the simulated survival times with Cox proportional hazard model, while calc_ave_hr_pi() calculate "average" hazard ratio using the mean survival & probability density function per treatment groups.

If your trt has more than two categories/levels and want to specify which one to use as a reference group, you can convert the column into a factor in the newdata input for surv_param_sim(). The first level will be used as a reference group.