--- title: "Vignette for R package PBIR" author: "Bo Huang, Xiaodong Luo, and Lu Tian" date: "May 6, 2020" output: pdf_document: default vignette: > %\VignetteIndexEntry{PBIRV} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- # Introduction The PBIR package contains several key functions for estimating and comparing the probability of being in response (PBIR), and for estimating and comparing the mean duration of response (DOR) in ITT population (Tsai et al. 2017 and Huang et al. 2020). Let $T_1$ and $T_2$ denote the time to response and time to disease progression or death, respectively. We assume that $T_1=\infty,$ if disease progression or death occurs first. The PBIR at time $t$ is defined as the probability that a patient of being in response (as a responder and has not progressed or died) at time point $t,$ i.e., $T_1\le t$ and $t< T_2.$ Let $T_3=\min(T_1, T_2)$, then $$PBIR(t)=P(T_2> t)-P(T_3> t),$$ which can be estimated as the difference between two Kaplan Meier estimates for the survival function of $T_2$ and $T_3,$ respectively, in the presence of censoring. Since the survival functions of $T_2$ or $T_3$ may not be estimable over their respective entire support due to right censoring, PBIR is in general only identifiable within a time window $[0, \tau],$ where $\tau$ is a time point no more than the longest followup time in the data (time to response, progression, or death, whichever is earlier). Furthermore, since these two Kaplan Meier estimates are correlated, the variance estimates of the estimated PBIRs need to account for this correlation appropriately. The PBIR package allows researchers to calculate the PBIR curve over a time window $[0, \tau]$ and compare PBIR curves between two groups. This document provides illustrative examples of how to use R functions from "PBIR" package to make statistical inferences on PBIR in different settings. First, we load the "PBIR" and "survival" packages ```{r,message=FALSE} library(PBIR) library(survival) ``` # Estimating PBIR over a given time window In this section, we will show how to use the R function "PBIR1" to estimate PBIR over a time window. To this end, we first need to generate data using following R code: ```{r} set.seed(100) n=100 error=rnorm(n) tr=exp(rnorm(n)+error+0.5) tp=exp(rnorm(n)+error) tr[tpT_2.$ A common censoring time $C$ is generated from a uniform distribution $U(3, 8.5).$ The generated data consist of $n$ copies of $(X_1, \delta_1, X_2, \delta_2),$ where $(X_j, \delta_j)=\{min(T_j, C), I(T_j. Huang, B., Tian, L., McCaw, Z.R., Luo, X., Talukder, E., Rothenberg, M., Xie, W., Choueiri, T.K., Kim, D. H., & Wei, L. J. (2020). Analysis of respose data for assessing treatment effects in comparative clinical studies. Annals of Internal Medicine . Huang, B., Tian, L., Talukder, E., Rothenberg, M., Kim, D. H., & Wei, L. J. (2018). Evaluating treatment effect based on duration of response for a comparative oncology study. JAMA oncology, 4(6), 874-876. Gray, R.J. (1988) A class of K-sample tests for comparing the cumulative incidence of a competing risk, Annals Of Statistics, 16:1141-1154.