calculate_trt_effect.Rd
This function is used to calculate the logHR using cox model after obtaining the counterfactural simulations for potential outcomes from simulate_counterfactuals.
calculate_trt_effect(sim_out_1d, sim_out_0d, sim_out_1c, sim_out_0c)
List. A list from simulate_counterfactuals for cox_event in treatment group, e.g. the cox model using OS.
List. A list from simulate_counterfactuals for cox_event in control group, e.g. the cox model using OS.
List. A list from simulate_counterfactuals for cox_event in treatment group, e.g. the cox model using 1-OS.
List. A list from simulate_counterfactuals for cox_event in control group, e.g. the cox model using 1-OS.
The marginal beta (logHR)
The event indicator from this function uses the equation 10', I(Y0<Y0_cens) or I(Y1<Y1_cens).
Daniel R, Zhang J, Farewell D. Making apples from oranges: Comparing noncollapsible effect estimators and their standard errors after adjustment for different covariate sets. Biom J. 2021;63(3):528-557. doi:10.1002/bimj.201900297
library(survival)
data("oak")
cox_event <- coxph(Surv(OS, os.status) ~ trt + btmb + pdl1, data = oak)
#
cox_censor <- coxph(Surv(OS, 1 - os.status) ~ trt + btmb + pdl1, data = oak)
bh <- basehaz(cox_event, centered = FALSE)
bh_c <- basehaz(cox_censor, centered = FALSE)
s_condi <- calculate_statistics(model = cox_event, trt = "trt")
s_condi_c <- calculate_statistics(model = cox_censor, trt = "trt")
sim_out_1d <- simulate_counterfactuals(
bh = bh, surv_cond = s_condi$surv_cond1, cpp = FALSE, M = 1000)
sim_out_0d <- simulate_counterfactuals(
bh = bh, surv_cond = s_condi$surv_cond0, cpp = FALSE, M = 1000)
sim_out_1c <- simulate_counterfactuals(
bh = bh_c, surv_cond = s_condi_c$surv_cond1, cpp = FALSE, M = 1000)
sim_out_0c <- simulate_counterfactuals(
bh = bh_c, surv_cond = s_condi_c$surv_cond0, cpp = FALSE, M = 1000)
output <- calculate_trt_effect(sim_out_1d, sim_out_0d, sim_out_1c, sim_out_0c)