vignettes/jstable_competing_risk_analysis.Rmd
jstable_competing_risk_analysis.Rmd
data <- mgus2
data$etime <- with(data, ifelse(pstat == 0, futime, ptime))
data$event <- with(data, ifelse(pstat == 0, 2 * death, 1))
data$event <- factor(data$event, 0:2, labels = c("censor", "pcm", "death"))
data$age65 <- with(data, ifelse(age > 65, 1, 0))
data$age65 <- factor(data$age65)
pdata <- survival::finegray(survival::Surv(etime, event) ~ ., data = data)
TableSubgroupMultiCox(formula = Surv(fgstart, fgstop, fgstatus) ~ sex, data = pdata, var_cov = "age", weights = "fgwt", var_subgroups = c("age65"))
#> Variable Count Percent Point Estimate Lower Upper sex=F sex=M P value
#> sex Overall 41775 100 0.77 0.54 1.1 10.4 8.1 0.153
#> 1 age65 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
#> 2 0 7572 18.1 0.71 0.4 1.27 17.2 10.5 0.252
#> 3 1 34203 81.9 0.8 0.51 1.25 8.7 7.3 0.33
#> P for interaction
#> sex <NA>
#> 1 0.673
#> 2 <NA>
#> 3 <NA>
fgfit <- coxph(Surv(fgstart, fgstop, fgstatus) ~ age + sex,
weight = fgwt, data = pdata, model = T
)
cox2.display(fgfit)
#> $table
#> crude HR(95%CI) crude P value adj. HR(95%CI) adj. P value
#> age "0.98 (0.97,0.99)" "0.003" "0.98 (0.97,0.99)" "0.002"
#> sex: M vs F "0.8 (0.56,1.13)" "0.207" "0.77 (0.54,1.1)" "0.153"
#>
#> $metric
#> [,1] [,2] [,3] [,4]
#> <NA> NA NA NA NA
#> No. of observations 41775.000 NA NA NA
#> No. of events 115.000 NA NA NA
#> AIC 1583.872 NA NA NA
#>
#> $caption
#> [1] "Cox model on time ('fgstart, fgstop') to event ('fgstatus')"