## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 5, fig.height = 3, fig.align = "center" ) ## ----setup-------------------------------------------------------------------- library(survdt) ## ----------------------------------------------------------------------------- aids_fit <- coxph_indtrunc(Survdt(incu, ltrunc, rtrunc) ~ age_gp, data = aids) aids_fit confint(aids_fit) ## ----------------------------------------------------------------------------- coxph_indtrunc(Survdt(incu, ltrunc, rtrunc) ~ age_gp, data = aids, ipw_type = "W-1") ## ----fig.height = 3.5--------------------------------------------------------- plot_coxsurv(aids_fit, newdata = aids[c(1,40), ], target = "survival") plot_coxsurv(aids_fit, newdata = aids[c(1, 40, 200), ], ci = FALSE, target = "cumhaz") ## ----------------------------------------------------------------------------- qind_test <- test_quasiindep_covariates(Survdt(incu, ltrunc, rtrunc) ~ age_gp, data = aids) qind_test ## ----fig.height = 3.5--------------------------------------------------------- plot(qind_test) ## ----error=TRUE, warning=TRUE------------------------------------------------- try({ positivity_sens_indtrunc(Survdt(incu, ltrunc, rtrunc) ~ age_gp, data = aids, ipw_type = "W-1", trunc_mass = seq(0, 0.11, by = 0.01)) }) ## ----------------------------------------------------------------------------- sens <- positivity_sens_indtrunc(Survdt(incu, ltrunc, rtrunc) ~ age_gp, data = aids, trunc_mass = seq(0, 0.11, by = 0.01)) sens ## ----------------------------------------------------------------------------- plot(sens) plot(sens, hazratio = TRUE) ## ----------------------------------------------------------------------------- strat_fit <- coxph_indtrunc(Survdt(event_time, ltrunc, rtrunc) ~ x, data = nonprop_sample, strata_formula = ~group) strat_fit confint(strat_fit) ## ----fig.height=3.5----------------------------------------------------------- plot_coxsurv(strat_fit, newdata = data.frame(group = c(0, 1), x = c(1, 1)), target = "cumhaz") ## ----------------------------------------------------------------------------- split_dat <- time_split(nonprop_sample, cut = 0.6, stop_name = "event_time", start = "start", event = "event", id = "id") ## ----------------------------------------------------------------------------- split_dat$group_tgr06 <- (split_dat$event_time > 0.6) * split_dat$group tvar_fit <- coxph_indtrunc(Survdt2(start, event_time, event, ltrunc, rtrunc, id) ~ group_tgr06 + x, data = split_dat) tvar_fit confint(tvar_fit)