--- 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[tp