| Type: | Package |
| Title: | Implementation of the Bayesian Discount Prior Approach forClinical Trials |
| Version: | 1.3.7 |
| Depends: | R (≥ 3.6.0), ggplot2, methods, survival |
| Description: | Functions for data augmentation using the Bayesian discount prior method for single arm and two-arm clinical trials, as described in Haddad et al. (2017) <doi:10.1080/10543406.2017.1300907>. The discount power prior methodology was developed in collaboration with the The Medical Device Innovation Consortium (MDIC) Computer Modeling & Simulation Working Group. |
| LazyLoad: | yes |
| License: | GPL-3 | file LICENSE |
| URL: | https://github.com/graemeleehickey/bayesDP |
| BugReports: | https://github.com/graemeleehickey/bayesDP/issues |
| NeedsCompilation: | yes |
| Repository: | CRAN |
| Imports: | MCMCpack, Rcpp |
| LinkingTo: | Rcpp, RcppArmadillo |
| RoxygenNote: | 7.3.2 |
| Encoding: | UTF-8 |
| Suggests: | covr, knitr, rmarkdown, testthat |
| VignetteBuilder: | knitr |
| Packaged: | 2025-01-11 23:56:44 UTC; hickeg3 |
| Author: | Shawn Balcome [aut], Donnie Musgrove [aut], Tarek Haddad [aut], Graeme L. Hickey |
| Maintainer: | Graeme L. Hickey <graemeleehickey@gmail.com> |
| Date/Publication: | 2025-01-12 11:40:10 UTC |
Bayesian Discount Prior: Historical Data Weight (alpha)
Description
alpha_discount can be used to estimate the weightapplied to historical data in the context of a one- or two-armclinical trial.alpha_discount is not used internally but isgiven for educational purposes.
Usage
alpha_discount( p_hat = NULL, discount_function = "weibull", alpha_max = 1, weibull_scale = 0.135, weibull_shape = 3)Arguments
p_hat | scalar. The posterior probability of a stochastic comparison.This value can be the output of |
discount_function | character. Specify the discount function to use.Currently supports |
alpha_max | scalar. Maximum weight the discount function can apply.Default is 1. |
weibull_scale | scalar. Scale parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 0.135. |
weibull_shape | scalar. Shape parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 3. |
Details
This function is not used internally but is given for educational purposes.Given inputsp_hat,discount_function,alpha_max,weibull_shape, andweibull_scale the output is the weightthat would be applied to historical data in the context of a one- ortwo-arm clinical trial.
Value
alpha_discount returns an object of class "alpha_discount".
An object of classalpha_discount contains the following:
alpha_hatscalar. The historical data weight.
References
Haddad, T., Himes, A., Thompson, L., Irony, T., Nair, R. MDIC ComputerModeling and Simulation working group.(2017) Incorporation of stochasticengineering models as prior information in Bayesian medical device trials.Journal of Biopharmaceutical Statistics, 1-15.
Examples
alpha_discount(0.5)alpha_discount(0.5, discount_function = "identity")Bayesian Discount Prior: Binomial counts
Description
bdpbinomial is used for estimating posterior samples froma binomial outcome where an informative prior is used. The prior weight isdetermined using a discount function. This code is modeled after themethodologies developed in Haddad et al. (2017).
Usage
bdpbinomial( y_t = NULL, N_t = NULL, y0_t = NULL, N0_t = NULL, y_c = NULL, N_c = NULL, y0_c = NULL, N0_c = NULL, discount_function = "identity", alpha_max = 1, fix_alpha = FALSE, a0 = 1, b0 = 1, number_mcmc = 10000, weibull_scale = 0.135, weibull_shape = 3, method = "mc", compare = TRUE)Arguments
y_t | scalar. Number of events for the current treatment group. |
N_t | scalar. Sample size of the current treatment group. |
y0_t | scalar. Number of events for the historical treatment group. |
N0_t | scalar. Sample size of the historical treatment group. |
y_c | scalar. Number of events for the current control group. |
N_c | scalar. Sample size of the current control group. |
y0_c | scalar. Number of events for the historical control group. |
N0_c | scalar. Sample size of the historical control group. |
discount_function | character. Specify the discount function to use.Currently supports |
alpha_max | scalar. Maximum weight the discount function can apply.Default is 1. For a two-arm trial, users may specify a vector of two valueswhere the first value is used to weight the historical treatment group andthe second value is used to weight the historical control group. |
fix_alpha | logical. Fix alpha at alpha_max? Default value is FALSE. |
a0 | scalar. Prior value for the beta rate. Default is 1. |
b0 | scalar. Prior value for the beta rate. Default is 1. |
number_mcmc | scalar. Number of Monte Carlo simulations. Default is10000. |
weibull_scale | scalar. Scale parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 0.135. For a two-arm trial, users may specify a vector of twovalues where the first value is used to estimate the weight of thehistorical treatment group and the second value is used to estimate theweight of the historical control group. Not used when |
weibull_shape | scalar. Shape parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 3. For a two-arm trial, users may specify a vector of two valueswhere the first value is used to estimate the weight of the historicaltreatment group and the second value is used to estimate the weight of thehistorical control group. Not used when |
method | character. Analysis method with respect to estimation of theweight parameter alpha. Default method " |
compare | logical. Should a comparison object be included in the fit?For a one-arm analysis, the comparison object is simply the posterior chainof the treatment group parameter. For a two-arm analysis, the comparisonobject is the posterior chain of the treatment effect that comparestreatment and control. If |
Details
bdpbinomial uses a two-stage approach for determining thestrength of historical data in estimation of a binomial count mean outcome.In the first stage, adiscount function is used that that definesthe maximum strength of the historical data and discounts based ondisagreement with the current data. Disagreement between current andhistorical data is determined by stochastically comparing the respectiveposterior distributions under noninformative priors. With binomial data,the comparison is the probability (p) that the current count is lessthan the historical count. The comparison metricp is then inputinto the Weibull discount function and the final strength of the historicaldata is returned (alpha).
In the second stage, posterior estimation is performed where the discountfunction parameter,alpha, is used incorporated in all posteriorestimation procedures.
To carry out a single arm (OPC) analysis, data for the current treatment(y_t andN_t) and historical treatment (y0_t andN0_t) must be input. The results are then based on the posteriordistribution of the current data augmented by the historical data.
To carry our a two-arm (RCT) analysis, data for the current treatment andat least one of current or historical control data must be input. Theresults are then based on the posterior distribution of the differencebetween current treatment and control, augmented by available historicaldata.
For more details, see thebdpbinomial vignette:vignette("bdpbinomial-vignette", package="bayesDP")
Value
bdpbinomial returns an object of class "bdpbinomial". Thefunctionssummary andprint are used to obtain and printa summary of the results, including user inputs. Theplot function displays visualoutputs as well.
An object of classbdpbinomial is a list containing at least thefollowing components:
posterior_treatmentlist. Entries contain values related to the treatment group:
alpha_discountnumeric. Alpha value, the weighting parameter of the historical data.p_hatnumeric. The posterior probability of the stochastic comparisonbetween the current and historical data.posteriorvector. A vector of lengthnumber_mcmccontainingposterior Monte Carlo samples of the event rate of the treatmentgroup. If historical treatment data is present, the posteriorincorporates the weighted historical data.posterior_flatvector. A vector of lengthnumber_mcmccontainingMonte Carlo samples of the event rate of the current treatment groupunder a flat/non-informative prior, i.e., no incorporation of thehistorical data.priorvector. If historical treatment data is present, a vector of lengthnumber_mcmccontaining Monte Carlo samples of the event rateof the historical treatment group under a flat/non-informative prior.
posterior_controllist. Similar entries as
posterior_treament. Only present if acontrol group is specified.finallist. Contains the final comparison object, dependent on the analysis type:
One-arm analysis:vector. Posterior chain of binomial proportion.
Two-arm analysis:vector. Posterior chain of binomial proportion difference comparingtreatment and control groups.
args1list. Entries contain user inputs. In addition, the following elementsare output:
arm2binary indicator. Used internally to indicate one-arm or two-armanalysis.intentcharacter. Denotes current/historical status of treatment andcontrol groups.
References
Haddad, T., Himes, A., Thompson, L., Irony, T., Nair, R. MDIC ComputerModeling and Simulation working group.(2017) Incorporation of stochasticengineering models as prior information in Bayesian medical device trials.Journal of Biopharmaceutical Statistics, 1-15.
See Also
summary,print,andplot for details of each of thesupported methods.
Examples
# One-arm trial (OPC) examplefit <- bdpbinomial( y_t = 10, N_t = 500, y0_t = 25, N0_t = 250, method = "fixed")summary(fit)print(fit)## Not run: plot(fit)## End(Not run)# Two-arm (RCT) examplefit2 <- bdpbinomial( y_t = 10, N_t = 500, y0_t = 25, N0_t = 250, y_c = 8, N_c = 500, y0_c = 20, N0_c = 250, method = "fixed")summary(fit2)print(fit2)## Not run: plot(fit2)## End(Not run)Bayesian Discount Prior: Two-Arm Linear Regression
Description
bdplm is used to estimate the treatment effect in thepresence of covariates using the regression analysis implementation of theBayesian discount prior.summary andprint methods aresupported. Currently, the function only supports a two-arm clinical trialwhere all of current treatment, current control, historical treatment, andhistorical control data are present
Usage
bdplm( formula = formula, data = data, data0 = NULL, prior_treatment_effect = NULL, prior_control_effect = NULL, prior_treatment_sd = NULL, prior_control_sd = NULL, prior_covariate_effect = 0, prior_covariate_sd = 10000, number_mcmc_alpha = 5000, number_mcmc_sigmagrid = 5000, number_mcmc_sigma = 100, number_mcmc_beta = 10000, discount_function = "identity", alpha_max = 1, fix_alpha = FALSE, weibull_scale = 0.135, weibull_shape = 3, method = "mc")Arguments
formula | an object of class "formula." See "Details" for moreinformation, including specification of treatment data indicators. |
data | a data frame containing the current data variables in the model.A column named |
data0 | a data frame containing the historical data variables in themodel. The column labels of data and data0 must match. |
prior_treatment_effect | scalar. The historical adjusted treatmenteffect. If left |
prior_control_effect | scalar. The historical adjusted control effect.If left |
prior_treatment_sd | scalar. The standard deviation of the historicaladjusted treatment effect. If left |
prior_control_sd | scalar. The standard deviation of the historicaladjusted control effect. If left |
prior_covariate_effect | vector. The prior mean(s) of the covariateeffect(s). Default value is zero. If a single value is input, the thescalar is repeated to the length of the input covariates. Otherwise, caremust be taken to ensure the length of the input matches the number ofcovariates. |
prior_covariate_sd | vector. The prior standard deviation(s) of thecovariate effect(s). Default value is 1e4. If a single value is input, thethe scalar is repeated to the length of the input covariates. Otherwise,care must be taken to ensure the length of the input matches the number ofcovariates. |
number_mcmc_alpha | scalar. Number of Monte Carlo simulations forestimating the historical data weight. Default is 5000. |
number_mcmc_sigmagrid | scalar. Grid size for computing sigma. Defaultis 5000. See "Details" for more information. |
number_mcmc_sigma | scalar. Number of Monte Carlo simulations forestimating sigma. Default is 1000. See "Details" for more information. |
number_mcmc_beta | scalar. Number of Monte Carlo simulations forestimating beta, the vector of regression coefficients. Default is 10000. |
discount_function | character. Specify the discount function to use.Currently supports |
alpha_max | scalar. Maximum weight the discount function can apply.Default is 1. Users may specify a vector of two values where the firstvalue is used to weight the historical treatment group and the second valueis used to weight the historical control group. |
fix_alpha | logical. Fix alpha at alpha_max? Default value is FALSE. |
weibull_scale | scalar. Scale parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 0.135. Users may specify a vector of two values where the firstvalue is used to estimate the weight of the historical treatment group andthe second value is used to estimate the weight of the historical controlgroup. Not used when |
weibull_shape | scalar. Shape parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 3. Users may specify a vector of two values where the first valueis used to estimate the weight of the historical treatment group and thesecond value is used to estimate the weight of the historical controlgroup. Not used when |
method | character. Analysis method with respect to estimation of theweight paramter alpha. Default method " |
Details
bdplm uses a two-stage approach for determining the strengthof historical data in estimation of an adjusted mean or covariate effect.In the first stage, adiscount function is used that that definesthe maximum strength of the historical data and discounts based ondisagreement with the current data. Disagreement between current andhistorical data is determined by stochastically comparing the respectiveposterior distributions under noninformative priors. Here with a two-armregression analysis, the comparison is the proability (p) that thecovariate effect of an historical data indicator is significantly differentfrom zero. The comparison metricp is then input into the discountfunction and the final strength of the historical data is returned(alpha).
In the second stage, posterior estimation is performed where the discountfunction parameter,alpha, is used to weight the historical dataeffects.
The formula must include an intercept (i.e., do not use-1 in theformula) and both data and data0 must be present. The column names of dataand data0 must match. Seeexamples below for example usage.
The underlying model results in a marginal posterior distribution for theerror variancesigma2 that does not have a known distribution. Thus,we use a grid search to draw samples ofsigma2. First, the marginalposterior is evaluated at a grid ofnumber_mcmc_sigmagridsigma2 values. The bounds of the grid are taken as approximately sixstandard deviations from an estimate ofsigma2 using thelmfunction. Next,number_mcmc_sigma posterior draws ofsigma2are made by sampling with replacement from the grid with each value havingthe corresponding marginal posterior probability of being selected. Withposterior draws ofsigma2 in hand, we can make posterior draws ofthe regression coefficients.
Value
bdplm returns an object of class "bdplm".
An object of class "bdplm" is a list containing at least thefollowing components:
posteriordata frame. Theposterior draws of the covariates, the intercept, and the treatment effect.The grid of sigma values are included.
alpha_discountvector. The posterior probability of the stochastic comparison between thecurrent and historical data for each of the treatment and control arms. If
method="mc", the result is a matrix of estimates, otherwise formethod="fixed", the result is a vector of estimates.estimateslist. The posterior means and standard errors ofthe intercept, treatment effect, covariate effect(s) and error variance.
Examples
# Set sample sizesn_t <- 30 # Current treatment sample sizen_c <- 30 # Current control sample sizen_t0 <- 80 # Historical treatment sample sizen_c0 <- 80 # Historical control sample size# Treatment group vectors for current and historical datatreatment <- c(rep(1, n_t), rep(0, n_c))treatment0 <- c(rep(1, n_t0), rep(0, n_c0))# Simulate a covariate effect for current and historical datax <- rnorm(n_t + n_c, 1, 5)x0 <- rnorm(n_t0 + n_c0, 1, 5)# Simulate outcome:# - Intercept of 10 for current and historical data# - Treatment effect of 31 for current data# - Treatment effect of 30 for historical data# - Covariate effect of 3 for current and historical dataY <- 10 + 31 * treatment + x * 3 + rnorm(n_t + n_c, 0, 5)Y0 <- 10 + 30 * treatment0 + x0 * 3 + rnorm(n_t0 + n_c0, 0, 5)# Place data into separate treatment and control data frames and# assign historical = 0 (current) or historical = 1 (historical)df_ <- data.frame(Y = Y, treatment = treatment, x = x)df0 <- data.frame(Y = Y0, treatment = treatment0, x = x0)# Fit model using default settingsfit <- bdplm( formula = Y ~ treatment + x, data = df_, data0 = df0, method = "fixed")# Look at estimates and discount weightsummary(fit)print(fit)Bayesian Discount Prior: Two-Arm Logistic Regression
Description
bdplogit is used to estimate the treatment effectin the presence of covariates using the logistic regression analysisimplementation of the Bayesian discount prior.summary andprint methods are supported. Currently, the function only supportsa two-arm clinical trial where all of current treatment, current control,historical treatment, and historical control data are present
Usage
bdplogit( formula = formula, data = data, data0 = NULL, prior_treatment_effect = NULL, prior_control_effect = NULL, prior_treatment_sd = NULL, prior_control_sd = NULL, prior_covariate_effect = 0, prior_covariate_sd = 10000, number_mcmc_alpha = 5000, number_mcmc_beta = 10000, discount_function = "identity", alpha_max = 1, fix_alpha = FALSE, weibull_scale = 0.135, weibull_shape = 3, method = "mc")Arguments
formula | an object of class "formula." See "Details" formore information, including specification of treatmentdata indicators. |
data | a data frame containing the current data variables in the model.A column named |
data0 | a data frame containing the historical data variables in the model.The column labels of data and data0 must match. |
prior_treatment_effect | scalar. The historical adjusted treatment effect.If left |
prior_control_effect | scalar. The historical adjusted control effect.If left |
prior_treatment_sd | scalar. The standard deviation of the historicaladjusted treatment effect. If left |
prior_control_sd | scalar. The standard deviation of the historicaladjusted control effect. If left |
prior_covariate_effect | vector. The prior mean(s) of the covariateeffect(s). Default value is zero. If a single value is input, thethe scalar is repeated to the length of the input covariates. Otherwise,care must be taken to ensure the length of the input matches the number ofcovariates. |
prior_covariate_sd | vector. The prior standard deviation(s) of thecovariate effect(s). Default value is 1e4. If a single value is input, thethe scalar is repeated to the length of the input covariates. Otherwise,care must be taken to ensure the length of the input matches the number ofcovariates. |
number_mcmc_alpha | scalar. Number of Monte Carlosimulations for estimating the historical data weight. Default is 5000. |
number_mcmc_beta | scalar. Number of Monte Carlo simulations forestimating beta, the vector of regression coefficients. Default is 10000. |
discount_function | character. Specify the discount function to use.Currently supports |
alpha_max | scalar. Maximum weight the discount function can apply.Default is 1. Users may specify a vector of two values where the firstvalue is used to weight the historical treatment group andthe second value is used to weight the historical control group. |
fix_alpha | logical. Fix alpha at alpha_max? Default value is FALSE. |
weibull_scale | scalar. Scale parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 0.135. Users may specify a vector of twovalues where the first value is used to estimate the weight of thehistorical treatment group and the second value is used to estimate theweight of the historical control group.Not used when |
weibull_shape | scalar. Shape parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 3. Users may specify a vector of two valueswhere the first value is used to estimate the weight of the historicaltreatment group and the second value is used to estimate the weight of thehistorical control group. Not used when |
method | character. Analysis method with respect to estimation of the weightparamter alpha. Default method " |
Details
bdplogit uses a two-stage approach for determining thestrength of historical data in estimation of an adjusted mean or covariateeffect. In the first stage, adiscount function is used thatthat defines the maximum strength of thehistorical data and discounts based on disagreement with the current data.Disagreement between current and historical data is determined by stochasticallycomparing the respective posterior distributions under noninformative priors.Here with a two-arm regression analysis, the comparison is theproability (p) that the covariate effect of an historical data indicator issignificantly different from zero. The comparison metricp is theninput into the discount function and the final strength of thehistorical data is returned (alpha).
In the second stage, posterior estimation is performed where the discountfunction parameter,alpha, is used to weight the historical dataeffects.
The formula must include an intercept (i.e., do not use-1 inthe formula) and both data and data0 must be present.The column names of data and data0 must match. Seeexamples below forexample usage.
The underlying model uses theMCMClogit function of the MCMCpackpackage to carryout posterior estimation. Add more.
Value
bdplogit returns an object of class "bdplogit".
An object of class "bdplogit" is a list containing at leastthe following components:
posteriordata frame. The posterior draws of the covariates, the intercept, andthe treatment effect. The grid of sigma values are included.
alpha_discountvector. The posterior probability of the stochastic comparisonbetween the current and historical data for each of the treatmentand control arms. If
method="mc", the result is a matrix ofestimates, otherwise formethod="fixed", the result is a vectorof estimates.estimateslist. The posterior means and standard errors of the intercept,treatment effect, covariate effect(s) and error variance.
Examples
# Set sample sizesn_t <- 30 # Current treatment sample sizen_c <- 30 # Current control sample sizen_t0 <- 80 # Historical treatment sample sizen_c0 <- 80 # Historical control sample size# Treatment group vectors for current and historical datatreatment <- c(rep(1, n_t), rep(0, n_c))treatment0 <- c(rep(1, n_t0), rep(0, n_c0))# Simulate a covariate effect for current and historical datax <- rnorm(n_t + n_c, 1, 5)x0 <- rnorm(n_t0 + n_c0, 1, 5)# Simulate outcome:# - Intercept of 10 for current and historical data# - Treatment effect of 31 for current data# - Treatment effect of 30 for historical data# - Covariate effect of 3 for current and historical dataY <- 10 + 31 * treatment + x * 3 + rnorm(n_t + n_c, 0, 5)Y0 <- 10 + 30 * treatment0 + x0 * 3 + rnorm(n_t0 + n_c0, 0, 5)# Place data into separate treatment and control data frames and# assign historical = 0 (current) or historical = 1 (historical)df_ <- data.frame(Y = Y, treatment = treatment, x = x)df0 <- data.frame(Y = Y0, treatment = treatment0, x = x0)# Fit model using default settingsfit <- bdplm( formula = Y ~ treatment + x, data = df_, data0 = df0, method = "fixed")# Look at estimates and discount weightsummary(fit)print(fit)Bayesian Discount Prior: Gaussian mean values
Description
bdpnormal is used for estimating posterior samples from aGaussian outcome where an informative prior is used. The prior weight isdetermined using a discount function. This code is modeled after themethodologies developed in Haddad et al. (2017).
Usage
bdpnormal( mu_t = NULL, sigma_t = NULL, N_t = NULL, mu0_t = NULL, sigma0_t = NULL, N0_t = NULL, mu_c = NULL, sigma_c = NULL, N_c = NULL, mu0_c = NULL, sigma0_c = NULL, N0_c = NULL, discount_function = "identity", alpha_max = 1, fix_alpha = FALSE, weibull_scale = 0.135, weibull_shape = 3, number_mcmc = 10000, method = "mc", compare = TRUE)Arguments
mu_t | scalar. Mean of the current treatment group. |
sigma_t | scalar. Standard deviation of the current treatment group. |
N_t | scalar. Number of observations of the current treatment group. |
mu0_t | scalar. Mean of the historical treatment group. |
sigma0_t | scalar. Standard deviation of the historical treatment group. |
N0_t | scalar. Number of observations of the historical treatment group. |
mu_c | scalar. Mean of the current control group. |
sigma_c | scalar. Standard deviation of the current control group. |
N_c | scalar. Number of observations of the current control group. |
mu0_c | scalar. Mean of the historical control group. |
sigma0_c | scalar. Standard deviation of the historical control group. |
N0_c | scalar. Number of observations of the historical control group. |
discount_function | character. Specify the discount function to use.Currently supports |
alpha_max | scalar. Maximum weight the discount function can apply.Default is 1. For a two-arm trial, users may specify a vector of two valueswhere the first value is used to weight the historical treatment group andthe second value is used to weight the historical control group. |
fix_alpha | logical. Fix alpha at alpha_max? Default value is FALSE. |
weibull_scale | scalar. Scale parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 0.135. For a two-arm trial, users may specify a vector of twovalues where the first value is used to estimate the weight of thehistorical treatment group and the second value is used to estimate theweight of the historical control group. Not used when |
weibull_shape | scalar. Shape parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 3. For a two-arm trial, users may specify a vector of two valueswhere the first value is used to estimate the weight of the historicaltreatment group and the second value is used to estimate the weight of thehistorical control group. Not used when |
number_mcmc | scalar. Number of Monte Carlo simulations. Default is10000. |
method | character. Analysis method with respect to estimation of theweight parameter alpha. Default method " |
compare | logical. Should a comparison object be included in the fit?For a one-arm analysis, the comparison object is simply the posterior chainof the treatment group parameter. For a two-arm analysis, the comparisonobject is the posterior chain of the treatment effect that comparestreatment and control. If |
Details
bdpnormal uses a two-stage approach for determining thestrength of historical data in estimation of a mean outcome. In the firststage, adiscount function is used that that defines the maximumstrength of the historical data and discounts based on disagreement withthe current data. Disagreement between current and historical data isdetermined by stochastically comparing the respective posteriordistributions under noninformative priors. With Gaussian data, thecomparison is the proability (p) that the current mean is less thanthe historical mean. The comparison metricp is then input into thediscount function and the final strength of the historical data is returned(alpha).
In the second stage, posterior estimation is performed where the discountfunction parameter,alpha, is used incorporated in all posteriorestimation procedures.
To carry out a single arm (OPC) analysis, data for the current treatment(mu_t,sigma_t, andN_t) and historical treatment(mu0_t,sigma0_t, andN0_t) must be input. The resultsare then based on the posterior distribution of the current data augmentedby the historical data.
To carry our a two-arm (RCT) analysis, data for the current treatment andat least one of current or historical control data must be input. Theresults are then based on the posterior distribution of the differencebetween current treatment and control, augmented by available historicaldata.
For more details, see thebdpnormal vignette:vignette("bdpnormal-vignette", package="bayesDP")
Value
bdpnormal returns an object of class "bdpnormal". Thefunctionssummary andprint are used to obtain and print asummary of the results, including user inputs. Theplot function displays visual outputsas well.
An object of classbdpnormal is a list containing at leastthe following components:
posterior_treatmentlist. Entries contain values related to the treatment group:
alpha_discountnumeric. Alpha value, the weighting parameter of the historical data.p_hatnumeric. The posterior probability of the stochastic comparisonbetween the current and historical data.posterior_muvector. A vector of lengthnumber_mcmccontaining the posteriormean of the treatment group. If historical treatment data is present,the posterior incorporates the weighted historical data.posterior_sigma2vector. A vector of lengthnumber_mcmccontaining the posteriorvariance of the treatment group. If historical treatment data is present,the posterior incorporates the weighted historical data.posterior_flat_muvector. A vector of lengthnumber_mcmccontainingMonte Carlo samples of the mean of the current treatment groupunder a flat/non-informative prior, i.e., no incorporation of thehistorical data.posterior_flat_sigma2vector. A vector of lengthnumber_mcmccontainingMonte Carlo samples of the standard deviation of the current treatment groupunder a flat/non-informative prior, i.e., no incorporation of thehistorical data.prior_muvector. If historical treatment data is present, a vector of lengthnumber_mcmccontaining Monte Carlo samples of the meanof the historical treatment group under a flat/non-informative prior.prior_sigma2vector. If historical treatment data is present, a vector of lengthnumber_mcmccontaining Monte Carlo samples of the standard deviationof the historical treatment group under a flat/non-informative prior.
posterior_controllist. Similar entries as
posterior_treament. Only present if acontrol group is specified.finallist. Contains the final comparison object, dependent on the analysis type:
One-arm analysis:vector. Posterior chain of the mean.
Two-arm analysis:vector. Posterior chain of the mean difference comparing treatment andcontrol groups.
args1list. Entries contain user inputs. In addition, the following elementsare output:
arm2binary indicator. Used internally to indicate one-arm or two-armanalysis.intentcharacter. Denotes current/historical status of treatment andcontrol groups.
References
Haddad, T., Himes, A., Thompson, L., Irony, T., Nair, R. MDIC ComputerModeling and Simulation working group.(2017) Incorporation of stochasticengineering models as prior information in Bayesian medical device trials.Journal of Biopharmaceutical Statistics, 1-15.
See Also
summary,print,andplot for details of each of thesupported methods.
Examples
# One-arm trial (OPC) examplefit <- bdpnormal( mu_t = 30, sigma_t = 10, N_t = 50, mu0_t = 32, sigma0_t = 10, N0_t = 50, method = "fixed")summary(fit)## Not run: plot(fit)## End(Not run)# Two-arm (RCT) examplefit2 <- bdpnormal( mu_t = 30, sigma_t = 10, N_t = 50, mu0_t = 32, sigma0_t = 10, N0_t = 50, mu_c = 25, sigma_c = 10, N_c = 50, mu0_c = 25, sigma0_c = 10, N0_c = 50, method = "fixed")summary(fit2)## Not run: plot(fit2)## End(Not run)Bayesian Discount Prior: Survival Analysis
Description
bdpsurvival is used to estimate the survival probability(single arm trial; OPC) or hazard ratio (two-arm trial; RCT) forright-censored data using the survival analysis implementation of theBayesian discount prior. In the current implementation, a two-arm analysisrequires all of current treatment, current control, historical treatment,and historical control data. This code is modeled after the methodologiesdeveloped in Haddad et al. (2017).
Usage
bdpsurvival( formula = formula, data = data, data0 = NULL, breaks = NULL, a0 = 0.1, b0 = 0.1, surv_time = NULL, discount_function = "identity", alpha_max = 1, fix_alpha = FALSE, number_mcmc = 10000, weibull_scale = 0.135, weibull_shape = 3, method = "mc", compare = TRUE)Arguments
formula | an object of class "formula." Must have a survival object onthe left side and at most one input on the right side, treatment. See"Details" for more information. |
data | a data frame containing the current data variables in the model.Columns denoting 'time' and 'status' must be present. See "Details" forrequired structure. |
data0 | optional. A data frame containing the historical data variablesin the model. If present, the column labels of data and data0 must match. |
breaks | vector. Breaks (interval starts) used to compose the breaks ofthe piecewise exponential model. Do not include zero. Default breaks arethe quantiles of the input times. |
a0 | scalar. Prior value for the gamma shape of the piecewiseexponential hazards. Default is 0.1. |
b0 | scalar. Prior value for the gamma rate of the piecewise exponentialhazards. Default is 0.1. |
surv_time | scalar. Survival time of interest for computing theprobability of survival for a single arm (OPC) trial. Default is overall,i.e., current+historical, median survival time. |
discount_function | character. Specify the discount function to use.Currently supports |
alpha_max | scalar. Maximum weight the discount function can apply.Default is 1. For a two-arm trial, users may specify a vector of two valueswhere the first value is used to weight the historical treatment group andthe second value is used to weight the historical control group. |
fix_alpha | logical. Fix alpha at alpha_max? Default value is FALSE. |
number_mcmc | scalar. Number of Monte Carlo simulations. Default is10000. |
weibull_scale | scalar. Scale parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 0.135. For a two-arm trial, users may specify a vector of twovalues where the first value is used to estimate the weight of thehistorical treatment group and the second value is used to estimate theweight of the historical control group. |
weibull_shape | scalar. Shape parameter of the Weibull discount functionused to compute alpha, the weight parameter of the historical data. Defaultvalue is 3. For a two-arm trial, users may specify a vector of two valueswhere the first value is used to estimate the weight of the historicaltreatment group and the second value is used to estimate the weight of thehistorical control group. |
method | character. Analysis method with respect to estimation of theweight parameter alpha. Default method " |
compare | logical. Should a comparison object be included in the fit?For a one-arm analysis, the comparison object is simply the posterior chainof the treatment group parameter. For a two-arm analysis, the comparisonobject is the posterior chain of the treatment effect that comparestreatment and control. If |
Details
bdpsurvival uses a two-stage approach for determining thestrength of historical data in estimation of a survival probabilityoutcome. In the first stage, adiscount function is used that thatdefines the maximum strength of the historical data and discounts based ondisagreement with the current data. Disagreement between current andhistorical data is determined by stochastically comparing the respectiveposterior distributions under noninformative priors. With a single armsurvival data analysis, the comparison is the probability (p) thatthe current survival is less than the historical survival. For a two-armsurvival data, analysis the comparison is the probability that the hazardratio comparing treatment and control is different from zero. Thecomparison metricp is then input into the discount function and thefinal strength of the historical data is returned (alpha).
In the second stage, posterior estimation is performed where the discountfunction parameter,alpha, is used incorporated in all posteriorestimation procedures.
To carry out a single arm (OPC) analysis, data for the current andhistorical treatments are specified in separate data frames, data anddata0, respectively. The data frames must have matching columns denotingtime and status. The 'time' column is the survival (censor) time of theevent and the 'status' column is the event indicator. The results are thenbased on the posterior probability of survival atsurv_time for thecurrent data augmented by the historical data.
Two-arm (RCT) analyses are specified similarly to a single arm trial. Againthe input data frames must have columns denoting time and status, but nowan additional column named 'treatment' is required to denote treatment andcontrol data. The 'treatment' column must use 0 to indicate the controlgroup. The current data are augmented by historical data (if present) andthe results are then based on the posterior distribution of the hazardratio between the treatment and control groups.
For more details, see thebdpsurvival vignette:vignette("bdpsurvival-vignette", package="bayesDP")
Value
bdpsurvival returns an object of class "bdpsurvival". Thefunctionssummary andprint are used to obtain and printa summary of the results, including user inputs. Theplot function displays visualoutputs as well.
An object of class "bdpsurvival" is a list containing at leastthe following components:
posterior_treatmentlist. Entries contain values related to the treatment group:
alpha_discountnumeric. Alpha value, the weighting parameter of the historical data.p_hatnumeric. The posterior probability of the stochastic comparisonbetween the current and historical data.posterior_survivalvector. If one-arm trial, a vector of lengthnumber_mcmccontaining the posterior probability draws of survival atsurv_time.posterior_flat_survivalvector. If one-arm trial, a vector of lengthnumber_mcmccontaining the probability draws of survival atsurv_timefor the current treatment not augmented by historical treatment.prior_survivalvector. If one-arm trial, a vector of lengthnumber_mcmccontaining the probability draws of survival atsurv_timefor the historical treatment.posterior_hazardmatrix. A matrix withnumber_mcmcrows andlength(breaks)columns containing the posterior draws of the piecewise hazardsfor each interval break point.posterior_flat_hazardmatrix. A matrix withnumber_mcmcrows andlength(breaks)columns containing the draws of piecewise hazards for each intervalbreak point for current treatment not augmented by historical treatment.prior_hazardmatrix. A matrix withnumber_mcmcrows andlength(breaks)columns containing the draws of piecewise hazards for each interval break pointfor historical treatment.
posterior_controllist. If two-arm trial, contains values related to the control groupanalogous to the
posterior_treatmentoutput.finallist. Contains the final comparison object, dependent on the analysis type:
One-arm analysis:vector. Posterior chain of survival probability at requested time.
Two-arm analysis:vector. Posterior chain of log-hazard rate comparing treatment and control groups.
args1list. Entries contain user inputs. In addition, the following elementsare output:
S_t,S_c,S0_t,S0_csurvival objects. Used internally to pass survival data betweenfunctions.arm2logical. Used internally to indicate one-arm or two-arm analysis.
References
Haddad, T., Himes, A., Thompson, L., Irony, T., Nair, R. MDIC ComputerModeling and Simulation working group.(2017) Incorporation of stochasticengineering models as prior information in Bayesian medical device trials.Journal of Biopharmaceutical Statistics, 1-15.
See Also
summary,print,andplot for details of each of thesupported methods.
Examples
# One-arm trial (OPC) example - survival probability at 5 years# Collect data into data framesdf_ <- data.frame( status = rexp(50, rate = 1 / 30), time = rexp(50, rate = 1 / 20))df_$status <- ifelse(df_$time < df_$status, 1, 0)df0 <- data.frame( status = rexp(50, rate = 1 / 30), time = rexp(50, rate = 1 / 10))df0$status <- ifelse(df0$time < df0$status, 1, 0)fit1 <- bdpsurvival(Surv(time, status) ~ 1, data = df_, data0 = df0, surv_time = 5, method = "fixed")print(fit1)## Not run: plot(fit1)## End(Not run)# Two-arm trial example# Collect data into data framesdf_ <- data.frame( time = c( rexp(50, rate = 1 / 20), # Current treatment rexp(50, rate = 1 / 10) ), # Current control status = rexp(100, rate = 1 / 40), treatment = c(rep(1, 50), rep(0, 50)))df_$status <- ifelse(df_$time < df_$status, 1, 0)df0 <- data.frame( time = c( rexp(50, rate = 1 / 30), # Historical treatment rexp(50, rate = 1 / 5) ), # Historical control status = rexp(100, rate = 1 / 40), treatment = c(rep(1, 50), rep(0, 50)))df0$status <- ifelse(df0$time < df0$status, 1, 0)fit2 <- bdpsurvival(Surv(time, status) ~ treatment, data = df_, data0 = df0, method = "fixed")summary(fit2)### Fix alpha at 1fit2_1 <- bdpsurvival(Surv(time, status) ~ treatment, data = df_, data0 = df0, fix_alpha = TRUE, method = "fixed")summary(fit2_1)bdpbinomial Object Plot
Description
plot method for classbdpbinomial.
Usage
## S4 method for signature 'bdpbinomial'plot(x, type = NULL, print = TRUE)Arguments
x | object of class |
type | character. Optional. Select plot type to print. Supports thefollowing: "discount" gives the discount function; "posteriors" gives theposterior plots of the event rates; and "density" gives the augmentedposterior density plot(s). Leave NULL to display all plots in sequence. |
print | logical. Optional. Produce a plot ( |
Details
Theplot method forbdpbinomial returns up to threeplots: (1) posterior density curves; (2) posterior density of the effect ofinterest; and (3) the discount function. A call toplot that omitsthetype input returns one plot at a time and prompts the user toclick the plot or press return to proceed to the next plot. Otherwise, theuser can specify a plottype to display the requested plot.
bdpnormal Object Plot
Description
plot method for classbdpnormal.
Usage
## S4 method for signature 'bdpnormal'plot(x, type = NULL, print = TRUE)Arguments
x | object of class |
type | character. Optional. Select plot type to print. Supports thefollowing: "discount" gives the discount function; "posteriors" gives theposterior plots of the event rates; and "density" gives the augmentedposterior density plot(s). Leave NULL to display all plots in sequence. |
print | logical. Optional. Produce a plot ( |
Details
Theplot method forbdpnormal returns up to threeplots: (1) posterior density curves; (2) posterior density of the effect ofinterest; and (3) the discount function. A call toplot that omitsthetype input returns one plot at a time and prompts the user toclick the plot or press return to proceed to the next plot. Otherwise, theuser can specify a plottype to display the requested plot.
bdpsurvival Object Plot
Description
plot method for classbdpsurvival.
Usage
## S4 method for signature 'bdpsurvival'plot(x, type = NULL, print = TRUE)Arguments
x | object of class |
type | character. Optional. Select plot type to print. Supports thefollowing: "discount" gives the discount function and "survival" gives thesurvival curves. Leave NULL to display all plots in sequence. |
print | logical. Optional. Produce a plot ( |
Details
Theplot method forbdpsurvival returns up to twoplots: (1) posterior survival curves and (2) the discount function. A calltoplot that omits thetype input returns one plot at a timeand prompts the user to click the plot or press return to proceed to thenext plot. Otherwise, the user can specify a plottype to displaythe requested plot.
Compute cdf of the piecewise exponential distribution
Description
ppexp is used to compute the cumulative distributionfunction of the piecewise exponential distribution. The function is portedfrom R to C++ via code adapted from themsm package.
Usage
ppexp(q, x, cuts)Arguments
q | scalar. The time point at which the cdf is to be computed. |
x | vector or matrix. The hazard rate(s). |
cuts | vector. Times at which the rate changes, i.e., the interval cutpoints. The first element of cuts should be 0, and cuts should be inincreasing order. Must be the same length as |
Details
The code underlyingppexp is written in C++ and adapted fromR code used in themsm package.
Value
The cumulative distribution function computed at timeq,hazard(s)x, and cut pointscuts.
Examples
# Single vector of hazard rates. Returns a single cdf value.q <- 12x <- c(0.25, 0.3, 0.35, 0.4)cuts <- c(0, 6, 12, 18)pp <- ppexp(q, x, cuts)# Matrix of multiple vectors of hazard rates. Returns 10 cdf values.x <- matrix(rgamma(4 * 10, 0.1, 0.1), nrow = 10)pp <- ppexp(q, x, cuts)bdpbinomial Object Print
Description
print method for classbdpbinomial.
Usage
## S4 method for signature 'bdpbinomial'print(x)Arguments
x | object of class |
Details
Returns same output as a call tosummary.
bdplm Object Print
Description
print method for classbdplm.
Usage
## S4 method for signature 'bdplm'print(x)Arguments
x | object of class |
Details
Displays a print of thebdplm fit and the initial function call.The fit includes the estimate of the intercept, treatment effect, andcovariate effects. The discount function weight estimates are displayed as well.Ifmethod="mc", the median estimate of alpha is displayed.
bdpnormal Object Print
Description
print method for classbdpnormal.
Usage
## S4 method for signature 'bdpnormal'print(x)Arguments
x | object of class |
Details
Returns same output as a call tosummary.
bdpsurvival Object Print
Description
print method for classbdpsurvival.
Usage
## S4 method for signature 'bdpsurvival'print(x)Arguments
x | object of class |
Details
Displays a print of thebdpsurvival fit. The outputis different, conditional on a one- or two-arm survival analysis.
In the case of a one-arm analysis, a brief summary is displayed,including the current data sample size, number of events,user input survival time, the augmented median survival probability,and corresponding lower and upper 95 percent interval limits.
When a control arm is present, the output is the same as a call tosummary.
Bayesian Discount Prior: Comparison Between Current and Historical Data
Description
probability_discount can be used to estimate the posteriorprobability of the comparison between historical and current data in thecontext of a clinical trial with normal (mean) data.probability_discount is not used internally but is given foreducational purposes.
Usage
probability_discount( mu = NULL, sigma = NULL, N = NULL, mu0 = NULL, sigma0 = NULL, N0 = NULL, number_mcmc = 10000, method = "fixed")Arguments
mu | scalar. Mean of the current data. |
sigma | scalar. Standard deviation of the current data. |
N | scalar. Number of observations of the current data. |
mu0 | scalar. Mean of the historical data. |
sigma0 | scalar. Standard deviation of the historical data. |
N0 | scalar. Number of observations of the historical data. |
number_mcmc | scalar. Number of Monte Carlo simulations. Default is10000. |
method | character. Analysis method. Default value " |
Details
This function is not used internally but is given for educational purposes.Given the inputs, the output is the posterior probability of the comparisonbetween current and historical data in the context of a clinicaltrial with normal (mean) data.
Value
probability_discount returns an object of class"probability_discount".
An object of classprobability_discount contains the following:
p_hatscalar. The posterior probability of the comparison historical data weight. If
method="mc", a vector of posterior probabilities of lengthnumber_mcmcis returned.
References
Haddad, T., Himes, A., Thompson, L., Irony, T., Nair, R. MDIC ComputerModeling and Simulation working group.(2017) Incorporation of stochasticengineering models as prior information in Bayesian medical device trials.Journal of Biopharmaceutical Statistics, 1-15.
Examples
probability_discount( mu = 0, sigma = 1, N = 100, mu0 = 0.1, sigma0 = 1, N0 = 100)bdpbinomial Object Summary
Description
summary method for classbdpbinomial.
Usage
## S4 method for signature 'bdpbinomial'summary(object)Arguments
object | object of class |
Details
Displays a summary of thebdpbinomial fit including the inputdata, the stochastic comparison between current and historical data, andthe resulting historical data weight (alpha). If historical data is missingthen no stochastic comparison nor weight are displayed.
In the case of a one-arm analysis, the displayed 95 percent CI contains thelower and upper limits of the augmented event rate of the current data. Thedisplayedsample estimate is the event rate of the current dataaugmented by the historical data.
When a control arm is present, a two-arm analysis is carried out. Now, thedisplayed 95 percent CI contains the lower and upper limits of thedifference between the treatment and control arms with the historical dataaugmented to current data, if present. The displayedsample estimates are the event rates of the treatment and control arms, each ofwhich are augmented when historical data are present.
bdplm Object Summary
Description
summary method for classbdplm.
Usage
## S4 method for signature 'bdplm'summary(object)Arguments
object | an object of class |
Details
Displays a summary of thebdplm fit. Displayed output issimilar tosummary.lm. The function call, residuals, andcoefficient table are displayed. The discount function weight estimates aredisplayed as well. Ifmethod="mc", the median estimate of alpha isdisplayed.
bdpnormal Object Summary
Description
summary method for classbdpnormal.
Usage
## S4 method for signature 'bdpnormal'summary(object)Arguments
object | object of class |
Details
Displays a summary of thebdpnormal fit including the inputdata, the stochastic comparison between current and historical data, andthe resulting historical data weight (alpha). If historical data is missingthen no stochastic comparison nor weight are displayed.
In the case of a one-arm analysis, the displayed 95 percent CI contains thelower and upper limits of the augmented mean value of the current data. Thedisplayedmean of treatment group is the mean of the current dataaugmented by the historical data.
When a control arm is present, a two-arm analysis is carried out. Now, thedisplayed 95 percent CI contains the lower and upper limits of thedifference between the treatment and control arms with the historical dataaugmented to current data, if present. The displayed posterior sampleestimates are the mean of the treatment and control arms, each of which areaugmented when historical data are present.
bdpsurvival Object Summary
Description
summary method for classbdpsurvival.
Usage
## S4 method for signature 'bdpsurvival'summary(object)Arguments
object | an object of class |
Details
Displays a summary of thebdpsurvival fit. The output isdifferent, conditional on a one- or two-arm survival analysis.
In the case of a one-arm analysis, the stochastic comparison betweencurrent and historical data and the resulting historical data weight(alpha) are displayed, followed by a survival table containing augmentedposterior estimates of the survival probability at each time point for thecurrent data.
When a control arm is present, a two-arm analysis is carried out. A two-armsurvival analysis is similar to a cox proportional hazards analysis, andthe displayed summary reflects this. First, the stochastic comparisonbetween current and historical data and the resulting historical dataweight (alpha) are displayed, when historical data is present for therespective arm. The displayedcoef value is the log-hazard betweenthe augmented treatment and control arms (log(treatment) - log(control)).The lower and upper 95 percent interval limits correspond to thecoef value.