The purpose of this vignette is to introduce the bdpsurvival
function. bdpsurvival
is used for estimating posterior samples in the context of right-censored data for clinical trials where an informative prior is used. The underlying model is a piecewise exponential model that assumes a constant hazard rate for each of several sub-intervals of the time to follow-up. In the parlance of clinical trials, the informative prior is derived from historical data. The weight given to the historical data is determined using what we refer to as a discount function. There are three steps in carrying out estimation:
Estimation of the historical data weight, denoted \(\hat{\alpha}\), via the discount function
Estimation of the posterior distribution of the current data, conditional on the historical data weighted by \(\hat{\alpha}\)
If a two-arm clinical trial, estimation of the posterior treatment effect, i.e., treatment versus control
Throughout this vignette, we use the terms current
, historical
, treatment
, and control
. These terms are used because the model was envisioned in the context of clinical trials where historical data may be present. Because of this terminology, there are 4 potential sources of data:
Current treatment data: treatment data from a current study
Current control data: control (or other treatment) data from a current study
Historical control data: treatment data from a previous study
Historical control data: control (or other treatment) data from a previous study
If only treatment data is input, the function considers the analysis a one-arm trial. If treatment data + control data is input, then it is considered a two-arm trial.
Before we get into our estimation scheme, we will briefly describe the piecewise exponential model. First, we partition the time duration into \(J\) intervals with cutpoints (or breaks) \(0=\tau_0<\tau_1<\dots<\tau_J=\infty\). The \(j\)th interval is defined as \([\tau_{j-1},\,\tau_j)\). Then, we let \(\lambda_j\) denote the hazard rate of the \(j\)th interval. That is, we assume that the hazard rate is piecewise constant.
Now, let \(d_{ij}\) be an event indicator for the \(i\)th subject in the \(j\)th interval. That is, \(d_{ij}=1\) if the endpoint occurred in the \(j\)th interval, otherwise \(d_{ij}=0\). Let \(t_{ij}\) denote the exposure time of the \(i\)th subject in the \(j\)th interval.
Let \(D_j=\sum_id_{ij}\) be the number of episodes that occurred in interval \(j\), and let \(T_j=\sum_it_{ij}\) be the total exposure time within interval \(j\). Then, the \(j\)th hazard rate is estimated as \[\lambda_j\mid D_j, \sim \mathcal{G}amma\left(a_0+D_j,\,b_0+T_j\right),\] where \(a_0\) and \(b_0\) are the prior shape and rate parameters of a gamma distribution. The survival probability can be estimated as \[p_S = 1-F_p\left(q,\,\lambda_1,\dots,\,\lambda_J,\,\tau_0,\,\dots\,\,\tau_J\right),\] where \(F_p\) is the piecewise exponential cumulative distribution function.
In the case where a covariate effect is present, a slightly different approach is used. In the bdpsurvival
function, a covariate effect arises in the context of a two-arm trial where the covariate of interest is the treatment indicator, i.e., treatment vs. control. In that case, we assume a Poisson glm model of the form \[\log\mathbb{E}\left(d_{ij}\mid\lambda_j,\,\beta\right)=\log t_{ij} + \log\lambda_j + x_i\beta,\,\,\,i=1,\dots,\,N,\,\,j=1,\dots,\,J.\] In this context, \(\beta\) is the \(\log\) hazard rate between the treatment and control arms. With the Poisson glm, we use an approximation to estimate \(\beta\) conditional on each \(\lambda_j\). Suppose we estimate hazard rates for the treatment and controls arms independently, denoted \(\lambda_{jT}\) and \(\lambda_{jC}\), respectively. That is \[\lambda_{jT} \sim \mathcal{G}amma\left(a_0+D_{jT},\,b_0+T_{jT}\right)\] and \[\lambda_{jC} \sim \mathcal{G}amma\left(a_0+D_{jC},\,b_0+T_{jC}\right),\] where \(D_{jT}\) and \(D_{jC}\) denote the number of events occurring in interval \(j\) for the treatment and control arms, respectively, and \(T_{jT}\) and \(T_{jC}\) denote the total exposures times in interval \(j\) for the treatment and control arms, respectively. Then, the approximation of the log-hazard rate \(\beta\) is carried out as follows: \[\begin{array}{rcl}
R_j & = & \log\lambda_{jT}-\log\lambda_{jC},\,\,\,j=1,\dots,\,J,\\
\\
V_j & = & \mathbb{V}ar(R_j),\,\,\,j=1,\dots,\,J,\\
\\
\beta & = & \displaystyle{\frac{\sum_jR_j/V_j}{\sum_j1/V_j}}.\\
\end{array}\] This estimate of \(\beta\) is essentially a normal approximation to the estimate under a Poisson glm. Currently, the variance term \(V_j\) is estimated empirically by calculating the variance of the posterior draws. The empirical variance approximates the theoretical variance under a normal approximation of \[\begin{array}{rcl}
\tilde{V}_j & = & V_{jT} + V_{jC},\\
\\
V_{jT} & = & 1/D_{jT},\\
\\
V_{jC} & = & 1/D_{jC}.\\
\end{array}\] In a future release of the package, we will demonstrate via simulation how well this normal approximation works in practice.
In the first estimation step, the historical data weight \(\hat{\alpha}\) is estimated. In the case of a two-arm trial, where both treatment and control data are available, an \(\hat{\alpha}\) value is estimated separately for each of the treatment and control arms. Of course, historical treatment or historical control data must be present, otherwise \(\hat{\alpha}\) is not estimated for the corresponding arm.
When historical data are available, estimation of \(\hat{\alpha}\) is carried out as follows. Let \(d_{ij}\) and \(t_{ij}\) denote the the event indicator and event time or censoring time for the \(i\)th subject in the \(j\)th interval of the current data, respectively. Similarly, let \(d_{0ij}\) and \(t_{0ij}\) denote the the event indicator and event time or censoring time for the \(i\)th subject in the \(j\)th interval of the historical data, respectively. Let \(a_0\) and \(b_0\) denote the shape and rate parameters of a gamma distribution, respectively. Then, the posterior distributions of the \(j\) piecewise hazard rates for current and historical data, under vague (flat) priors are
\[\lambda_{j} \sim \mathcal{G}amma\left(a_0+D_j,\,b_0+T_j\right)\]
\[\lambda_{j0} \sim \mathcal{G}amma\left(a_0+D_{0j},\,b_0+T_{j0}\right)\] respectively, where \(D_j=\sum_id_{ij}\), \(T_j=\sum_it_{ij}\), \(D_{0j}=\sum_id_{0ij}\), and \(T_{j0}=\sum_it_{0ij}\). The next steps are dependent on whether a one-arm or two-arm analysis is requested.
Under a one-arm analysis, the comparison of interest is the survival probability at user-specified time \(t^\ast\). Let \[\tilde{\theta} = 1-F_p\left(t^\ast,\,\lambda_1,\dots,\,\lambda_J,\,\tau_0,\,\dots\,\,\tau_J\right),\] and \[\theta_0 = 1-F_p\left(t^\ast,\,\lambda_{10},\dots,\,\lambda_{J0},\,\tau_0,\,\dots\,\,\tau_J\right),\] be the posterior survival probabilities for the current and historical data, respectively. Then, we compute the posterior probability that the current survival is greater than the historical survival \(p = Pr\left(\tilde{\theta} > \theta_0 \mid D, T, D_0,T_0 \right)\), where \(D\) and \(T\) collect \(D_1,\dots,D_J\) and \(T_1,\dots,T_J\), respectively.
Under a two-arm analysis, the comparison of interest is the hazard ratio of current vs. historical data. We estimate the log hazard ratio \(\beta\) as described previously and compute the posterior probability that \(\beta>0\) as \(p = Pr\left(\beta > 0\mid D, T, D_0, T_0\right)\).
Finally, with the posterior probability \(p\) in hand, we can compute the weight \(\hat{\alpha}\). For a Weibull distribution function (i.e., the Weibull cumulative distribution function), denoted \(W\), \(\hat{\alpha}\) is computed as
\[ \begin{array}{ccc} \mbox{One-sided analysis} & & \mbox{Two-sided analysis} \\ \hat{\alpha}=\alpha_{max}\cdot W\left(p, \,w_{shape}, \,w_{scale}\right), & & \hat{\alpha}=\begin{cases} \alpha_{max}\cdot W\left(p, \,w_{shape}, \,w_{scale}\right),\,0\le p\le0.5\\ \alpha_{max}\cdot W\left(1-p, \,w_{shape}, \,w_{scale}\right),\,0.5 \lt p \le 1, \end{cases} \end{array} \]
where \(w_{shape}\) and \(w_{scale}\) are the shape and scale of the Weibull distribution function, respectively and \(\alpha_{max}\) scales the weight \(\hat{\alpha}\) by a user-input maximum value. Using the default values of \(w_{shape}=3\) and \(w_{scale}=0.135\), \(\hat{\alpha}\) increases to 1 as \(p\) increases to 1 (one-sided) and \(\hat{\alpha}\) increases to 1 as \(p\) goes to 0.5 (two-sided).
There are several model inputs at this first stage. First, the user can select fix_alpha=TRUE
and force a fixed value of \(\hat{\alpha}\) (at the alpha_max
input), as opposed to estimation via the discount function. Next, a Monte Carlo estimation approach is used, requiring several samples from the posterior distributions. Thus, the user can input a sample size greater than or less than the default value of number_mcmc=10000
. Next, the Beta rate parameters can be changed from the defaults of \(a_0=b_0=1\) (a0
and b0
inputs). Finally, the shape of the Weibull discount function can be altered by changing the Weibull shape and scale parameters from the default values of \(w_{shape}=3\) and \(w_{scale}=0.135\) (weibull_shape
and weibull_scale
inputs).
With the historical data weight \(\hat{\alpha}\) in hand, we can move on to estimation of the posterior distribution of the current data.
Throughout this vignette, we refer to a discount function. The discount function is a Weibull distribution function and has the form \[W(x) = 1 - \exp\left\{- (x/w_{scale})^{w_{shape}}\right\}.\] During estimation, a user may be interested in selecting values of \(w_{shape}\) and \(w_{scale}\) that result in optimal statistical properties of the analysis. Thus, the discount function can be used to control the false positive rate (type I error) and/or the false negative rate (type II error). Examples in a following section illustrate the shape of the discount function using the default shape and scale parameters.
Another important aspect related to the discount function is the analysis type: one-sided or two-sided. The sidedness of the analysis is analogous to a one- or two-sided hypothesis test. Using the default shape and scale inputs, a two-sided analysis type results in a discount function with the following curve:
The discount function of a one-sided analysis, again with the default shape and scale inputs, has the following curve: In both of the above plots, the x-axis is the stochastic comparison between current and historical data, which we’ve denoted \(p\). The y-axis is the discount value \(\hat{\alpha}\) that corresponds to a given value of \(p\).
The posterior distribution is dependent on the analysis type: one-arm or two-arm analysis.
With \(\hat{\alpha}\) in hand, we can now estimate the posterior distributions of the hazards so that we can estimate the survival probability as described previously. Using the notation of the previous sections, the posterior distribution is \[
\begin{array}{rcl}
p_S & = & 1-F_p\left(t^\ast,\,\lambda_1,\dots,\,\lambda_J,\,\tau_0,\,\dots\,\,\tau_J\right),\\
\\
\lambda_j & \sim & \mathcal{G}amma\left(a_0+\sum_id_{ij} + \hat{\alpha}\sum_id_{0ij},\,b_0+\sum_it_{ij} + \hat{\alpha}\sum_it_{0ij}\right),\,j=1,\dots,J\\
\end{array}
\] At this model stage, we have in hand number_mcmc
simulations from the augmented posterior distribution and we then generate posterior summaries.
Again, under a two-arm analysis, and with \(\hat{\alpha}\) in hand, we can now estimate the posterior distribution of the log hazard rate comparing treatment and control. Let \(\lambda_{jT}\) and \(\lambda_{jC}\) denote the hazard associated with the treatment and control data for the \(j\)th interval, respectively. Then we augment each of the treatment and control data by the weighted historical data as \[
\begin{array}{rcl}
\lambda_{jT} & \sim & \mathcal{G}amma\left(a_0+\sum_id_{ijT} + \hat{\alpha}_T\sum_id_{0ijT},\,b_0+\sum_it_{ijT} + \hat{\alpha}_T\sum_it_{0ijT}\right),\,j=1,\dots,J\\
\end{array}
\] and \[
\begin{array}{rcl}
\lambda_{jC} & \sim & \mathcal{G}amma\left(a_0+\sum_id_{ijC} + \hat{\alpha}_C\sum_id_{0ijC},\,b_0+\sum_it_{ijC} + \hat{\alpha}_C\sum_it_{0ijC}\right),\,j=1,\dots,J\\
\end{array}
\] respectively. We then construct the log hazard ratio \(\beta\) using the estimates of \(\lambda_{jT}\) and \(\lambda_{jC}\), \(j=1,\dots,\,J\) as described previously. At this model stage, we have in hand number_mcmc
simulations from the augmented posterior distribution and we then generate posterior summaries.
The data inputs for bdpsurvival
is via a data frame that must have very specific column names. The required columns are status
, time
, historical
, and treatment
. Descriptions of each column are as follows:
status
- an indicator (0 or 1) of whether an event was observed (1) or if the observation is right-censored (0)time
- the event or censor timehistorical
- an indicator (0 or 1) of whether the observation source is historical data (1) or current data (0)treatment
- an indicator (0 or 1) of whether the observation source is treatment group (1) or control group (0)Historical data are not necessary, but using this function would not be necessary either. At the minimum, at least one historical=0
and one treatment=1
observation must be present. Each of the following input combinations for observations are allowed:
historical=0
, treatment=1
) - one-arm trialhistorical=0
, treatment=1
) + (historical=1
, treatment=1
) - one-arm trialhistorical=0
, treatment=1
) + (historical=0
, treatment=0
) - two-arm trialhistorical=0
, treatment=1
) + (historical=0
, treatment=0
) - two-arm trialhistorical=0
, treatment=1
) + (historical=1
, treatment=1
) + (historical=0
, treatment=0
) - two-arm trialhistorical=0
, treatment=1
) + (historical=1
, treatment=1
) + (historical=1
, treatment=0
) - two-arm trialhistorical=0
, treatment=1
) + (historical=1
, treatment=1
) + (historical=0
, treatment=0
)+ (historical=1
, treatment=0
) - two-arm trialTo demonstrate a one-arm trial, we will simulate survival data from an exponential distribution. For ease of exposition, we will assume that there are no censored observations.
set.seed(42)
# Simulate survival times
time_current <- rexp(50, rate=1/10)
time_historical <- rexp(50, rate=1/15)
# Combine simulated data into a data frame
data1 <- data.frame(status = 1,
time = c(time_current, time_historical),
historical = c(rep(0,50),rep(1,50)),
treatment = 1)
In this example, we’ve simulated current survival times from an exponential distribution with rate 1/10
and historical survival times from an exponential distribution with rate 1/15
. With our data frame constructed, we can now fit the bdpsurvival
model. Since this is a one-arm trial, we will request the survival probability at surv_time=5
. Thus, estimation using the default model inputs is carried out:
set.seed(42)
fit1 <- bdpsurvival(Surv(time, status) ~ historical + treatment,
data = data1,
surv_time = 5)
print(fit1)
##
## One-armed bdp survival
##
##
## n events surv_time median lower 95% CI upper 95% CI
## 50 50 5 0.6261 0.5066 0.7365
The print
method displays the median survival probability of 0.6261
and the 95% lower and upper interval limits of 0.5066
and 0.7365
, respectively. The summary
method is implemented as well. For a one-arm trial, the summary outputs a survival table as follows:
summary(fit1)
##
## One-armed bdp survival
##
## Stochastic comparison (p_hat) - treatment (current vs. historical data): 0.0554
## Discount function value (alpha) - treatment: 0.0668
##
## Current treatment - augmented posterior summary:
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 0.2882 50 1 0.9773 0.0064 0.9626 0.9875
## 0.2883 49 1 0.9773 0.0064 0.9626 0.9875
## 0.3819 48 1 0.9700 0.0084 0.9507 0.9835
## 0.5714 47 1 0.9554 0.0124 0.9272 0.9754
## 0.9615 46 1 0.9262 0.0201 0.8806 0.9589
## 1.9834 45 1 0.8537 0.0379 0.7693 0.9170
## 2.2356 44 1 0.8367 0.0418 0.7440 0.9070
## 2.3111 43 1 0.8317 0.0430 0.7366 0.9040
## 2.7996 42 1 0.7999 0.0499 0.6905 0.8849
## 2.8349 41 1 0.7976 0.0504 0.6873 0.8836
## 3.0982 40 1 0.7811 0.0538 0.6638 0.8735
## 3.1398 39 1 0.7785 0.0543 0.6601 0.8719
## 3.5121 38 1 0.7477 0.0542 0.6309 0.8422
## 3.5455 37 1 0.7447 0.0541 0.6283 0.8390
## 3.7034 36 1 0.7306 0.0537 0.6157 0.8247
## 3.8641 35 1 0.7166 0.0536 0.6030 0.8116
## 3.9266 34 1 0.7113 0.0536 0.5978 0.8075
## 4.1013 33 1 0.6969 0.0539 0.5843 0.7947
## 4.3871 32 1 0.6734 0.0547 0.5603 0.7749
## 4.7318 31 1 0.6464 0.0563 0.5301 0.7530
## 4.7519 30 1 0.6448 0.0564 0.5281 0.7518
## 4.9759 29 1 0.6279 0.0577 0.5085 0.7379
## 5.6939 28 1 0.5779 0.0623 0.4519 0.6985
## 6.2211 27 1 0.5433 0.0658 0.4120 0.6716
## 6.5632 26 1 0.5226 0.0665 0.3910 0.6525
## 6.6090 25 1 0.5201 0.0662 0.3895 0.6499
## 6.6583 24 1 0.5174 0.0660 0.3876 0.6467
## 7.1486 23 1 0.4919 0.0639 0.3645 0.6179
## 7.1909 22 1 0.4898 0.0638 0.3624 0.6154
## 7.3750 21 1 0.4804 0.0634 0.3539 0.6048
## 7.7829 20 1 0.4607 0.0629 0.3362 0.5858
## 11.9160 19 1 0.2915 0.0560 0.1887 0.4067
## 11.9511 18 1 0.2904 0.0559 0.1877 0.4053
## 12.1138 17 1 0.2847 0.0554 0.1837 0.3989
## 12.4558 16 1 0.2733 0.0545 0.1752 0.3874
## 12.5396 15 1 0.2706 0.0543 0.1731 0.3845
## 12.8709 14 1 0.2603 0.0535 0.1650 0.3735
## 13.0849 13 1 0.2538 0.0531 0.1594 0.3663
## 13.4472 12 1 0.2431 0.0524 0.1507 0.3551
## 14.1609 11 1 0.2231 0.0513 0.1341 0.3338
## 14.6363 10 1 0.2106 0.0507 0.1242 0.3208
## 15.2313 9 1 0.1962 0.0499 0.1126 0.3056
## 17.5641 8 1 0.1490 0.0469 0.0740 0.2563
## 19.0209 7 1 0.1390 0.0441 0.0686 0.2396
## 24.0868 6 1 0.1112 0.0371 0.0537 0.1967
## 30.1856 5 1 0.0852 0.0322 0.0376 0.1615
## 41.6813 4 1 0.0517 0.0263 0.0172 0.1181
## 48.6280 3 1 0.0384 0.0234 0.0102 0.0997
## 49.9597 2 1 0.0363 0.0229 0.0092 0.0966
## 68.4657 1 1 0.0166 0.0165 0.0023 0.0637
In the above output, in addition to a survival table, we can see the stochastic comparison between the current and historical data of 0.0554
as well as the weight, alpha, of 0.0668
applied to the historical data. Here, the weight applied to the historical data is very small since the stochastic comparison suggests that the current and historical data are not similar.
Suppose that we would like to apply full weight to the historical data. This can be accomplished by setting alpha_max=1
and fix_alpha=TRUE
as follows:
set.seed(42)
fit1a <- bdpsurvival(Surv(time, status) ~ historical + treatment,
data = data1,
surv_time = 5,
alpha_max = 1,
fix_alpha = TRUE)
print(fit1a)
##
## One-armed bdp survival
##
##
## n events surv_time median lower 95% CI upper 95% CI
## 50 50 5 0.6831 0.5958 0.7592
Now, the median survival probability shifts upwards towards the historical data.
Many of the the values presented in the summary
and print
methods are accessible from the fit object. For instance, alpha
is found in fit1a$posterior_treatment$alpha_discount
and p_hat
is located at fit1a$posterior_treatment$p_hat
. The augmented survival probability and confidence interval are computed at run-time. The results can be replicated as:
survival_time_posterior_flat <- ppexp(5,
fit1a$posterior_treatment$posterior_hazard,
cuts=c(0,fit1a$args1$breaks))
surv_augmented <- 1-median(survival_time_posterior_flat)
CI95_augmented <- 1-quantile(survival_time_posterior_flat, prob=c(0.975, 0.025))
Here, we first compute the piecewise exponential cumulative distribution function using the ppexp
function. The ppexp
function requires the survival time, 5
here, the posterior draws of the piecewise hazards, and the cuts points of the corresponding intervals.
Finally, we’ll explore the plot
method.
plot(fit1a)
The top plot displays three survival curves. The green curve is the survival of the historical data, the red curve is the survival of the current event rate, and the blue curve is the survival of the current data augmented by historical data. Since we gave full weight to the historical data, the augmented curve is “in-between” the current and historical curves.
The bottom plot displays the discount function (solid curve) as well as alpha
(horizontal dashed line) and p_hat
(vertical dashed line). In the present example, the discount function is the Weibull probability distribution with shape=3
and scale=0.135
.
On to two-arm trials. In this package, we define a two-arm trial as an analysis where a current and/or historical control arm is present. Suppose we have the same treatment data as in the one-arm example, but now we introduce control data. Again, we will assume that there is no censoring present in the control data.:
set.seed(42)
# Simulate survival times for treatment data
time_current_trt <- rexp(50, rate=1/10)
time_historical_trt <- rexp(50, rate=1/15)
# Simulate survival times for control data
time_current_cntrl <- rexp(50, rate=1/20)
time_historical_cntrl <- rexp(50, rate=1/20)
# Combine simulated data into a data frame
data2 <- data.frame(status = 1,
time = c(time_current_trt, time_historical_trt,
time_current_cntrl, time_historical_cntrl),
historical = c(rep(0,50),rep(1,50), rep(0,50),rep(1,50)),
treatment = c(rep(1,100), rep(0,100)))
In this example, we’ve simulated current and historical control survival times from exponential distributions with rate 1/20
. Note how the data2
data frame has been constructed; we’ve taken care to ensure that the current/historical and treatment/control indicators line up properly. With our data frame constructed, we can now fit the bdpsurvival
model. Before proceeding, it is worth pointing out that the discount function is applied separately to the treatment and control data. Now, let’s carry out the two-arm analysis using default inputs:
set.seed(42)
fit2 <- bdpsurvival(Surv(time, status) ~ historical + treatment,
data = data2)
print(fit2)
##
## Two-armed bdp survival
##
## data:
## Current treatment: n = 50, number of events = 50
## Current control: n = 50, number of events = 50
## Stochastic comparison (p_hat) - treatment (current vs. historical data): 0.0483
## Stochastic comparison (p_hat) - control (current vs. historical data): 0.1544
## Discount function value (alpha) - treatment: 0.0448
## Discount function value (alpha) - control: 0.776
##
## coef exp(coef) se(coef) lower 95% CI upper 95% CI
## treatment 0.7066 2.027 0.1929 0.3267 1.0794
The print
method of a two-arm analysis is largely different than a one-arm analysis (with a two-arm analysis, the summary
method is identical to print
). First, we see the stochastic comparisons reported for both the treatment and control arms. As seen previously, the stochastic comparison between the current and historical data for the treatment data is relatively small at 0.0483
, giving a low historical data weight of 0.0448
. On the other hand, the stochastic comparison between the current and historical data for the control data is relatively large at 0.1544
, giving a high historical data weight of 0.776
. Finally, the presented coef
value (and associated interval limits) is the log hazard ratio between the augmented treatment data and the augmented control data computed as log(treatment) - log(control)
.