--- title: "Getting started with oceCens" author: "Michael P. Fay" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Using oceCens} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ## Composite Endpoints with Right censoring The oceCens R package is for creating a rank based outcome which is a composite of several time-to-event endpoints, ordered by priority. Follmann, et al (2020) describe this methodology. The example in that paper has three endpoints, with the following priority order: (1) death, (2) stroke/MI, and (3) bleed. Thus, with no censoring outcomes are first ordered by time to death, and in those participants that did not die during the study, they are ordered by time to first stroke or MI (myocardial infaction), and in those participants that did not die OR have a stroke/MI during the study, they are ordered by time to first bleed. The software allows for right censoring. A simulated data set is included in the package. ```{r, eval=TRUE} library(oceCens) data(simScenario5) head(simScenario5) ``` For this simulated data set the time to the three priority ordered endpoints are T1, T2, and T3, and the indicators if each of those times is an event or a right censored observation are I1, I2, and I3, where for example if I1=1 then T1 is the time to event, and if I1=0 then T1 is the time to censoring. The main function of the package is oceTest. It estimates either the Mann-Whitney parameter or the Win Ratio parameter using one of several estimation methods.Let $O_1$ and $O_0$ be the ordering scores for a random participant from the treatment arm ($O_1$) or control arm ($O_0$). Then the Mann-Whitney parameter is $MW = Pr[ O_1 > O_0] + (1/2)*Pr[ O_1=O_0]$ and the Win Ratio is $WR = Pr[O_1>O_0 | O_1 \neq O_0]/Pr[O_1 s]$ for different values of $s$). The survival curves for the two arms can be estimated in one of two ways: (1) as two different nonparametric maximum likelihood estimates (NPMLEs) or (2) using the Cox regression model, which imposes the proportional hazards semiparametric assumption onto the estimates for the two arms. We can plot both sets of survival curves onto the same plot: ```{r fig1, fig.width=7, fig.height=7} dataFormt<-oceFormat(data=simScenario5, oceTime=c("T1","T2","T3"), oceStatus=c("I1","I2","I3"), group=c("Z"), oceNames = c("Death","Stroke/MI","Bleed")) npmleOutput<- oceNPMLE(dataFormt) plot(npmleOutput, xlab="Custom x label", mark.time=FALSE, lwd=2) # add lines from coxph output coxOutput<- oceCoxph(dataFormt) plot(coxOutput,linesonly=TRUE, col=c("orange","purple"),lwd=2) legend("bottomleft", legend=c("grp=0, NPMLE","grp=1, NPMLE", "grp=0, coxph","grp=1, coxph"), col=c("red","blue","orange","purple"),lty=c(1,1,1,1),lwd=2) ``` ## References Follmann, D., Fay, M. P., Hamasaki, T., and Evans, S. (2020). Analysis of ordered composite endpoints. Statistics in Medicine, 39(5), 602-616. Wei, L. J., Lin, D. Y., & Weissfeld, L. (1989). Regression analysis of multivariate incomplete failure time data by modeling marginal distributions. Journal of the American statistical association, 84(408), 1065-1073.