knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
survival19 is a package dealing with the stratified Cox proportional hazard model. It contains two main functions:
The stratified_cox function would estimate beta for a stratified survival dataset with arbitrary facility. However, missingness or ties are not allowed.
library(survival19) set.seed(2019) testdata = generate_data(F_pre = c("a", "b", "c", "d"), gamma = rep(1, 4), order = F) stratified_cox(testdata$delta, testdata$z, testdata$facility, testdata$time, testdata$num_facility, tol= 1.0e-6)
beta1 = stratified_cox(testdata$delta, testdata$z, testdata$facility, testdata$time, testdata$num_facility, tol= 1.0e-6) require(survival) beta2 = coxph(Surv(testdata$time, testdata$delta) ~ testdata$z + strata(testdata$facility))$coef all.equal(as.numeric(beta1), as.vector(beta2))
require(bench) effi <- bench::mark(survival19_time = as.numeric(stratified_cox(testdata$delta, testdata$z, testdata$facility, testdata$time, testdata$num_facility, tol= 1.0e-6)), coxph_time = coxph(Surv(testdata$time, testdata$delta) ~ testdata$z + strata(testdata$facility)), check = F) effi # plot(effi)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.