Title: | Self-Adapting Mixture (SAM) Priors |
---|---|
Description: | Implementation of the SAM prior and generation of its operating characteristics for dynamically borrowing information from historical data. For details, please refer to Yang et al. (2023) <doi:10.1111/biom.13927>. |
Authors: | Peng Yang [aut, cre] , Ying Yuan [aut] |
Maintainer: | Peng Yang <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.1.1 |
Built: | 2024-10-25 04:34:44 UTC |
Source: | https://github.com/pengyang0411/samprior |
The get_OC
function is designed to generate the operating
characteristics of SAM priors (Yang, et al., 2023), including the
relative bias, relative mean squared error, and type I error and power
under a two-arm comparative trial design. As an option, the operating
characteristic of robust MAP priors (Schmidli, et al., 2014)
can also be generated for comparison.
get_OC( if.prior, theta.h, method.w, prior.odds, nf.prior, delta, n, n.t, decision, ntrial, if.MAP, weight, theta, theta.t, ... ) ## S3 method for class 'betaMix' get_OC( if.prior, theta.h, method.w, prior.odds, nf.prior, delta, n, n.t, decision, ntrial, if.MAP, weight, theta, theta.t, ... ) ## S3 method for class 'normMix' get_OC( if.prior, theta.h, method.w, prior.odds, nf.prior, delta, n, n.t, decision, ntrial, if.MAP, weight, theta, theta.t, ..., sigma )
get_OC( if.prior, theta.h, method.w, prior.odds, nf.prior, delta, n, n.t, decision, ntrial, if.MAP, weight, theta, theta.t, ... ) ## S3 method for class 'betaMix' get_OC( if.prior, theta.h, method.w, prior.odds, nf.prior, delta, n, n.t, decision, ntrial, if.MAP, weight, theta, theta.t, ... ) ## S3 method for class 'normMix' get_OC( if.prior, theta.h, method.w, prior.odds, nf.prior, delta, n, n.t, decision, ntrial, if.MAP, weight, theta, theta.t, ..., sigma )
if.prior |
Informative prior constructed from historical data, represented (approximately) as a mixture of conjugate distributions. |
theta.h |
Estimate of the treatment effect based on historical data.
If missing, the default value is set to be the posterior mean estimate from
|
method.w |
Methods used to determine the mixture weight for SAM priors.
The default method is LRT (Likelihood Ratio Test), the alternative option can
be PPR (Posterior Probability Ratio). See |
prior.odds |
The prior probability of |
nf.prior |
Non-informative prior used for constructing the SAM prior and robust MAP prior. |
delta |
Clinically significant difference used for the SAM prior. |
n |
Sample size for the control arm. |
n.t |
Sample size for the treatment arm. |
decision |
Decision rule to compare the treatment with the control;
see |
ntrial |
Number of trials simulated. |
if.MAP |
Whether to simulate the operating characteristics of the
robust MAP prior for comparison, the default value is |
weight |
Weight assigned to the informative prior component
( |
theta |
A vector of the response rate (binary endpoints) or mean (continuous endpoints) for the control arm. |
theta.t |
A vector of the response rate (binary endpoints) or mean (continuous endpoints) for the treatment arm. |
... |
Additional parameters for continuous endpoints. |
sigma |
Variance to simulate the continuous endpoint under normality assumption. |
The get_OC
function is designed to generate the operating
characteristics of SAM priors, including the relative bias, relative
mean squared error, and type I error, and power under a two-arm
comparative trial design. As an option, the operating characteristics of
robust MAP priors (Schmidli, et al., 2014) can also be generated for
comparison.
The relative bias is defined as the difference between the bias of a method and the bias of using a non-informative prior. The relative mean squared error is the difference between the mean squared error (MSE) of a method and the MES of using a non-informative prior.
To evaluate type I error and power, the determination of whether the
treatment is superior to the control is calculated based on function
decision2S
.
Returns dataframe that contains the relative bias, relative MSE, type I error, and power for both SAM priors, as well as robust MAP priors. Additionally, the mixture weight of the SAM prior is also displayed.
get_OC(betaMix)
: The function is designed to generate the operating
characteristics of SAM priors for binary endpoints.
get_OC(normMix)
: The function is designed to generate the operating
characteristics of SAM priors for continuous endpoints.
Yang P, Zhao Y, Nie L, Vallejo J, Yuan Y. SAM: Self-adapting mixture prior to dynamically borrow information from historical data in clinical trials. Biometrics 2023; 00, 1–12. https://doi.org/10.1111/biom.13927
Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan A, Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors in clinical trials with historical control information. Biometrics 2014; 70(4):1023-1032.
set.seed(123) ## Example of a binary endpoint ## Consider a randomized comparative trial designed to borrow information ## from historical data on the control. We assumed a non-informative prior ## beta(1, 1) and an informative prior beta(30, 50) after incorporating ## the historical data. The treatment is regarded as superior to the control ## if Pr(RR.t > RR.c | data) > 0.95, where RR.t and RR.c are response rates ## of the treatment and control, respectively. The operating characteristics ## were assessed under the scenarios of (RR.c, RR.t) = (0.3, 0.36) and (0.3, 0.56). ## OC <- get_OC(## Informative prior constructed based on historical data ## if.prior = mixbeta(c(1, 30, 50)), ## ## Non-informative prior used for constructing the SAM prior ## nf.prior = mixbeta(c(1,1,1)), ## delta = 0.2, ## Clinically significant difference ## n = 35, ## Sample size for the control arm ## n.t = 70, ## Sample size for the treatment arm ## ## Decision rule to compare the whether treatment is superior ## ## than the control ## decision = decision2S(0.95, 0, lower.tail=FALSE), ## ntrial = 1000, ## Number of trials simulated ## ## Weight assigned to the informative component for MAP prior ## weight = 0.5, ## ## A vector of response rate for the control arm ## theta = c(0.3, 0.36), ## ## A vector of response rate for the treatment arm ## theta.t = c(0.3, 0.56)) ## OC ## Example of continuous endpoint ## Consider a randomized comparative trial designed to borrow information ## from historical data on the control. We assumed a non-informative prior ## N(0, 1e4) and an informative prior N(0.5, 2) after incorporating ## the historical data. The treatment is regarded as superior to the control ## if Pr(mean.t > mean.c | data) > 0.95, where mean.t and mean.c are mean ## of the treatment and control, respectively. The operating characteristics ## were assessed under the scenarios of (mean.c, mean.t) = (0.1, 0.1) and ## (0.5, 1.0). sigma <- 2 prior.mean <- 0.5 prior.se <- sigma/sqrt(100) ## OC <- get_OC(## Informative prior constructed based on historical data ## if.prior = mixnorm(c(1, prior.mean, prior.se)), ## ## Non-informative prior used for constructing the SAM prior ## nf.prior = mixnorm(c(1, 0, 1e4)), ## delta = 0.2 * sigma, ## Clinically significant difference ## n = 100, ## Sample size for the control arm ## n.t = 200, ## Sample size for the treatment arm ## ## Decision rule to compare the whether treatment is superior ## ## than the control ## decision = decision2S(0.95, 0, lower.tail=FALSE), ## ntrial = 1000, ## Number of trials simulated ## ## A vector of mean for the control arm ## theta = c(0.1, 0.5), ## ## A vector of mean for the treatment arm ## theta.t = c(0.1, 1.0), ## sigma = sigma) ## OC
set.seed(123) ## Example of a binary endpoint ## Consider a randomized comparative trial designed to borrow information ## from historical data on the control. We assumed a non-informative prior ## beta(1, 1) and an informative prior beta(30, 50) after incorporating ## the historical data. The treatment is regarded as superior to the control ## if Pr(RR.t > RR.c | data) > 0.95, where RR.t and RR.c are response rates ## of the treatment and control, respectively. The operating characteristics ## were assessed under the scenarios of (RR.c, RR.t) = (0.3, 0.36) and (0.3, 0.56). ## OC <- get_OC(## Informative prior constructed based on historical data ## if.prior = mixbeta(c(1, 30, 50)), ## ## Non-informative prior used for constructing the SAM prior ## nf.prior = mixbeta(c(1,1,1)), ## delta = 0.2, ## Clinically significant difference ## n = 35, ## Sample size for the control arm ## n.t = 70, ## Sample size for the treatment arm ## ## Decision rule to compare the whether treatment is superior ## ## than the control ## decision = decision2S(0.95, 0, lower.tail=FALSE), ## ntrial = 1000, ## Number of trials simulated ## ## Weight assigned to the informative component for MAP prior ## weight = 0.5, ## ## A vector of response rate for the control arm ## theta = c(0.3, 0.36), ## ## A vector of response rate for the treatment arm ## theta.t = c(0.3, 0.56)) ## OC ## Example of continuous endpoint ## Consider a randomized comparative trial designed to borrow information ## from historical data on the control. We assumed a non-informative prior ## N(0, 1e4) and an informative prior N(0.5, 2) after incorporating ## the historical data. The treatment is regarded as superior to the control ## if Pr(mean.t > mean.c | data) > 0.95, where mean.t and mean.c are mean ## of the treatment and control, respectively. The operating characteristics ## were assessed under the scenarios of (mean.c, mean.t) = (0.1, 0.1) and ## (0.5, 1.0). sigma <- 2 prior.mean <- 0.5 prior.se <- sigma/sqrt(100) ## OC <- get_OC(## Informative prior constructed based on historical data ## if.prior = mixnorm(c(1, prior.mean, prior.se)), ## ## Non-informative prior used for constructing the SAM prior ## nf.prior = mixnorm(c(1, 0, 1e4)), ## delta = 0.2 * sigma, ## Clinically significant difference ## n = 100, ## Sample size for the control arm ## n.t = 200, ## Sample size for the treatment arm ## ## Decision rule to compare the whether treatment is superior ## ## than the control ## decision = decision2S(0.95, 0, lower.tail=FALSE), ## ntrial = 1000, ## Number of trials simulated ## ## A vector of mean for the control arm ## theta = c(0.1, 0.5), ## ## A vector of mean for the treatment arm ## theta.t = c(0.1, 1.0), ## sigma = sigma) ## OC
The SAM_prior
function is designed to display the SAM prior, given
the informative prior (constructed from historical data), non-informative
prior, and the mixture weight calculated using SAM_weight
function (Yang, et al., 2023).
SAM_prior(if.prior, nf.prior, weight, ...) ## S3 method for class 'betaMix' SAM_prior(if.prior, nf.prior, weight, ...) ## S3 method for class 'gammaMix' SAM_prior(if.prior, nf.prior, weight, ...) ## S3 method for class 'normMix' SAM_prior(if.prior, nf.prior, weight, ..., sigma)
SAM_prior(if.prior, nf.prior, weight, ...) ## S3 method for class 'betaMix' SAM_prior(if.prior, nf.prior, weight, ...) ## S3 method for class 'gammaMix' SAM_prior(if.prior, nf.prior, weight, ...) ## S3 method for class 'normMix' SAM_prior(if.prior, nf.prior, weight, ..., sigma)
if.prior |
Informative prior constructed from historical data, represented (approximately) as a mixture of conjugate distributions. |
nf.prior |
Non-informative prior used for the mixture. |
weight |
Weight assigned to the informative prior component
( |
... |
Additional parameters required for different endpoints. |
sigma |
Variance used for constructing the non-informative prior for continuous endpoints. |
SAM prior is constructed by mixing an informative prior
, constructed based on historical data, with a
non-informative prior
using the mixture weight
determined by
SAM_weight
function to achieve the
degree of prior-data conflict (Schmidli et al., 2015, Yang et al., 2023).
Let and
denote the treatment effects
associated with the current arm data
and historical data
,
respectively. Let
denote the clinically significant difference
such that if
, then
is
regarded as clinically distinct from
, and it is therefore
inappropriate to borrow any information from
. Consider two
hypotheses:
represents that
and
are consistent (i.e.,
no prior-data conflict) and thus information borrowing is desirable,
whereas
represents that the treatment effect of
differs from
to such a degree that no information should be
borrowed.
The SAM prior uses the likelihood ratio test (LRT) statistics to
quantify the degree of prior-data conflict and determine the extent of
information borrowing.
where denotes the likelihood function. An alternative
Bayesian choice is the posterior probability ratio (PPR):
where and
is the prior probabilities of
and
being true.
is the Bayes Factor that in this case
is the same as the LRT.
The SAM prior, denoted as , is then defined
as a mixture of an informative prior
, constructed
based on
and a non-informative prior
:
where the mixture weight is calculated as:
As the level of prior-data conflict increases, the likelihood ratio
decreases, resulting in a decrease in the weight
assigned to the informative prior and thus a decrease in information
borrowing. As a result,
is data-driven and
has the ability to self-adapt the information borrowing based on the
degree of prior-data conflict.
Displays the SAM prior as a mixture of an informative prior (constructed based on the historical data) and a non-informative prior.
SAM_prior(betaMix)
: The function calculates the SAM prior for beta
mixture distribution. The default nf.prior
is set to be
mixbeta(c(1,1,1))
which represents a uniform prior Beta(1,1)
.
SAM_prior(gammaMix)
: The function calculates the SAM prior for gamma
mixture distribution. The default nf.prior
is set to be
mixgamma(c(1,0.001,0.001))
which represents a vague gamma prior
Gamma(0.001,0.001)
.
SAM_prior(normMix)
: The function calculates the SAM prior for normal
mixture distribution. The default nf.prior
is set to be
mixnorm(c(1,summary(if.prior)['mean'], sigma))
which represents a
unit-information prior.
Yang P, Zhao Y, Nie L, Vallejo J, Yuan Y. SAM: Self-adapting mixture prior to dynamically borrow information from historical data in clinical trials. Biometrics 2023; 00, 1–12. https://doi.org/10.1111/biom.13927
Schmidli H, Gsteiger S, Roychoudhury S, O'Hagan A, Spiegelhalter D, Neuenschwander B. Robust meta-analytic-predictive priors in clinical trials with historical control information. Biometrics 2014; 70(4):1023-1032.
set.seed(123) ## Examples for binary endpoints ## Suppose that the informative prior constructed based on historical data is ## beta(40, 60) prior.historical <- mixbeta(c(1, 40, 60)) ## Data of the control arm data.control <- rbinom(60, size = 1, prob = 0.42) ## Calculate the mixture weight of the SAM prior wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.15, ## Clinically significant difference data = data.control ## Control arm data ) ## Assume beta(1,1) as the non-informative prior used for mixture nf.prior <- mixbeta(nf.prior = c(1,1,1)) ## Generate the SAM prior SAM.prior <- SAM_prior(if.prior = prior.historical, ## Informative prior nf.prior = nf.prior, ## Non-informative prior weight = wSAM ## Mixture weight of the SAM prior ) plot(SAM.prior) ## Examples for continuous endpoints ## Suppose that the informative prior constructed based on historical data is ## N(0, 3) sigma <- 3 prior.mean <- 0 prior.se <- sigma/sqrt(100) prior.historical <- mixnorm(c(1, prior.mean, prior.se), sigma = sigma) ## Data of the control arm data.control <- rnorm(80, mean = 0, sd = sigma) ## Calculate the mixture weight of the SAM prior wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.2 * sigma, ## Clinically significant difference data = data.control ## Control arm data ) ## Assume unit-information prior N(0,3) as the non-informative prior used ## for the mixture nf.prior <- mixnorm(nf.prior = c(1,prior.mean, sigma), sigma = sigma) ## Generate the SAM prior SAM.prior <- SAM_prior(if.prior = prior.historical, ## Informative prior nf.prior = nf.prior, ## Non-informative prior weight = wSAM ## Mixture weight of the SAM prior ) plot(SAM.prior)
set.seed(123) ## Examples for binary endpoints ## Suppose that the informative prior constructed based on historical data is ## beta(40, 60) prior.historical <- mixbeta(c(1, 40, 60)) ## Data of the control arm data.control <- rbinom(60, size = 1, prob = 0.42) ## Calculate the mixture weight of the SAM prior wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.15, ## Clinically significant difference data = data.control ## Control arm data ) ## Assume beta(1,1) as the non-informative prior used for mixture nf.prior <- mixbeta(nf.prior = c(1,1,1)) ## Generate the SAM prior SAM.prior <- SAM_prior(if.prior = prior.historical, ## Informative prior nf.prior = nf.prior, ## Non-informative prior weight = wSAM ## Mixture weight of the SAM prior ) plot(SAM.prior) ## Examples for continuous endpoints ## Suppose that the informative prior constructed based on historical data is ## N(0, 3) sigma <- 3 prior.mean <- 0 prior.se <- sigma/sqrt(100) prior.historical <- mixnorm(c(1, prior.mean, prior.se), sigma = sigma) ## Data of the control arm data.control <- rnorm(80, mean = 0, sd = sigma) ## Calculate the mixture weight of the SAM prior wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.2 * sigma, ## Clinically significant difference data = data.control ## Control arm data ) ## Assume unit-information prior N(0,3) as the non-informative prior used ## for the mixture nf.prior <- mixnorm(nf.prior = c(1,prior.mean, sigma), sigma = sigma) ## Generate the SAM prior SAM.prior <- SAM_prior(if.prior = prior.historical, ## Informative prior nf.prior = nf.prior, ## Non-informative prior weight = wSAM ## Mixture weight of the SAM prior ) plot(SAM.prior)
The SAM_weight
function is designed to calculate the mixture
weight of the SAM priors according to the degree of prior-data
conflicts (Yang, et al., 2023).
SAM_weight(if.prior, theta.h, method.w, prior.odds, data, delta, ...) ## S3 method for class 'betaMix' SAM_weight(if.prior, theta.h, method.w, prior.odds, data, delta, n, r, ...) ## S3 method for class 'normMix' SAM_weight( if.prior, theta.h, method.w, prior.odds, data, delta, m, n, sigma, ... ) ## S3 method for class 'gammaMix' SAM_weight(if.prior, theta.h, method.w, prior.odds, data, delta, u, w, ...)
SAM_weight(if.prior, theta.h, method.w, prior.odds, data, delta, ...) ## S3 method for class 'betaMix' SAM_weight(if.prior, theta.h, method.w, prior.odds, data, delta, n, r, ...) ## S3 method for class 'normMix' SAM_weight( if.prior, theta.h, method.w, prior.odds, data, delta, m, n, sigma, ... ) ## S3 method for class 'gammaMix' SAM_weight(if.prior, theta.h, method.w, prior.odds, data, delta, u, w, ...)
if.prior |
Informative prior constructed based on historical data, represented (approximately) as a mixture of conjugate distributions. |
theta.h |
Estimate of the treatment effect based on historical data.
If missing, the default value is set to be the posterior mean estimate from
|
method.w |
Methods used to determine the mixture weight for SAM priors. The default method is "LRT" (Likelihood Ratio Test), the alternative option is "PPR" (Posterior Probability Ratio). See Details section for more information. |
prior.odds |
The prior probability of |
data |
Data of the control arm from the current trial, see Methods section for more details. |
delta |
Clinically significant difference used for the SAM prior. |
... |
Additional parameters required for different endpoints. |
n |
Number of subjects in the control arm for continuous endpoint. |
r |
Number of responses in the control arm for binary endpoint. |
m |
Mean estimate in the control arm for continuous endpoint. |
sigma |
Standard deviation in the control arm for continuous endpoint. |
u |
Number of events in the control arm for time-to-event endpoint. |
w |
Total observed time in the control arm for time-to-event endpoint. |
SAM prior is constructed by mixing an informative prior
, constructed based on historical data, with a
non-informative prior
using the mixture weight
determined by
SAM_weight
function to achieve the
degree of prior-data conflict (Schmidli et al., 2015, Yang et al., 2023).
Let and
denote the treatment effects
associated with the current arm data
and historical data
,
respectively. Let
denote the clinically significant difference
such that if
, then
is
regarded as clinically distinct from
, and it is therefore
inappropriate to borrow any information from
. Consider two
hypotheses:
represents that
and
are consistent (i.e.,
no prior-data conflict) and thus information borrowing is desirable,
whereas
represents that the treatment effect of
differs from
to such a degree that no information should be
borrowed.
The SAM prior uses the likelihood ratio test (LRT) statistics to
quantify the degree of prior-data conflict and determine the extent of
information borrowing.
where denotes the likelihood function. An alternative
Bayesian choice is the posterior probability ratio (PPR):
where and
is the prior probabilities of
and
being true.
is the Bayes Factor that in this case
is the same as the LRT.
The SAM prior, denoted as , is then defined
as a mixture of an informative prior
, constructed
based on
and a non-informative prior
:
where the mixture weight is calculated as:
As the level of prior-data conflict increases, the likelihood ratio
decreases, resulting in a decrease in the weight
assigned to the informative prior and thus a decrease in information
borrowing. As a result,
is data-driven and
has the ability to self-adapt the information borrowing based on the
degree of prior-data conflict.
The mixture weight of the SAM priors.
SAM_weight(betaMix)
: The function calculates the mixture weight of SAM
priors for beta mixture distribution. The input data
can be patient-level
data (i.e., a vector of 0 and 1 representing the response status of each
patient) or summary statistics (i.e., the number of patients and the number
of responses).
SAM_weight(normMix)
: The function calculates the mixture weight of SAM
priors for normal mixture distribution. The input data
should be
a vector of patient-level observations. The input data
can be
patient-level data (i.e., a vector of continuous response of each
patient) or summary statistics (i.e., the mean estimate, number of subjects,
and the standard deviation in the control arm).
SAM_weight(gammaMix)
: The function calculates the mixture weight of SAM
priors for gamma mixture distribution. The input data
can be
patient-level data (i.e., a matrix with the first row as the censoring
indicator and the second row recording the observed time) or summary
statistics (i.e., the number of uncensored observations u
and
total observed time w
).
Yang P, Zhao Y, Nie L, Vallejo J, Yuan Y. SAM: Self-adapting mixture prior to dynamically borrow information from historical data in clinical trials. Biometrics 2023; 00, 1–12. https://doi.org/10.1111/biom.13927
set.seed(123) ## Examples for binary endpoints ## Example 1: no prior-data conflict ## Suppose that the informative prior constructed based on historical data is ## beta(40, 60) prior.historical <- mixbeta(c(1, 40, 60)) ## Data of control arm data.control <- rbinom(60, size = 1, prob = 0.42) ## Calculate the mixture weight of the SAM prior wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.15, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM) ## Example 2: in the presence of prior-data conflict, where the current data ## has 12 responses in 60 patients wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.15, ## Clinically significant difference ## Methods to determine mixture weight for the SAM priors ## by Posterior Probability Ratio method.w = 'PPR', ## Prior odds of favoring no prior-data conflicts to ## the presence of prior-data conflict prior.odd = 1/9, n = 60, ## Number of patients in the control arm r = 12 ## Number of responses in the control arm ) print(wSAM) ## Example 3: in the presence of prior-data conflict, where the current data ## has 12 responses in 60 patients wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.15, ## Clinically significant difference n = 60, ## Number of patients in the control arm r = 12 ## Number of responses in the control arm ) print(wSAM) ## Examples for continuous endpoints ## Example 1: no prior-data conflict ## Suppose that the informative prior constructed from historical data is ## N(0, 3) sigma <- 3 prior.mean <- 0 prior.se <- sigma/sqrt(100) prior.historical <- mixnorm(c(1, prior.mean, prior.se), sigma = sigma) ## Data of the control arm data.control <- rnorm(80, mean = 0, sd = sigma) wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.3 * sigma, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM) ## Example 2: in the presence of prior-data conflict, where the current data ## has mean of 0.5 data.control <- rnorm(80, mean = 1, sd = sigma) wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.3 * sigma, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM) ## Examples for survival endpoints ## Example 1: no prior-data conflict ## Suppose the survival times from historical data follows exp(1) distribution ## with random censoring time follows U(0.5, 5) distribution T_hi <- rexp(100, rate = 1) C_hi <- runif(100, min = 0.5, max = 5) ## Indicators of the uncensored events delta_hi <- as.numeric(T_hi < C_hi) ## Observed survival times from historical data U_hi <- T_hi U_hi[delta_hi == 0] <- C_hi[delta_hi == 0] ## Construct the informative prior based on simulated historical data prior.historical <- mixgamma(c(1, sum(delta_hi), sum(U_hi)), param = 'ab', likelihood = 'exp') ## Suppose the survival times from control data follows exp(0.95) distribution ## with random censoring time follows U(0.5, 5) distribution T_ci <- rexp(100, rate = 0.95) C_ci <- runif(100, min = 0.5, max = 5) ## Indicators of the uncensored events delta_ci <- as.numeric(T_ci < C_ci) ## Observed survival times from control data U_ci <- T_ci U_ci[delta_ci == 0] <- C_ci[delta_ci == 0] ## Data of the control arm data.control <- rbind(sum(delta_ci), sum(U_ci)) wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.2, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM) ## Example 2: in the presence of prior-data conflict, where the current survival ## times follows exp(2) distribution with random censoring time follows U(0.5, 5) ## distribution T_ci <- rexp(100, rate = 2) C_ci <- runif(100, min = 0.5, max = 5) ## Indicators of the uncensored events delta_ci <- as.numeric(T_ci < C_ci) ## Observed survival times from control data U_ci <- T_ci U_ci[delta_ci == 0] <- C_ci[delta_ci == 0] ## Data of the control arm data.control <- rbind(sum(delta_ci), sum(U_ci)) wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.2, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM)
set.seed(123) ## Examples for binary endpoints ## Example 1: no prior-data conflict ## Suppose that the informative prior constructed based on historical data is ## beta(40, 60) prior.historical <- mixbeta(c(1, 40, 60)) ## Data of control arm data.control <- rbinom(60, size = 1, prob = 0.42) ## Calculate the mixture weight of the SAM prior wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.15, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM) ## Example 2: in the presence of prior-data conflict, where the current data ## has 12 responses in 60 patients wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.15, ## Clinically significant difference ## Methods to determine mixture weight for the SAM priors ## by Posterior Probability Ratio method.w = 'PPR', ## Prior odds of favoring no prior-data conflicts to ## the presence of prior-data conflict prior.odd = 1/9, n = 60, ## Number of patients in the control arm r = 12 ## Number of responses in the control arm ) print(wSAM) ## Example 3: in the presence of prior-data conflict, where the current data ## has 12 responses in 60 patients wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.15, ## Clinically significant difference n = 60, ## Number of patients in the control arm r = 12 ## Number of responses in the control arm ) print(wSAM) ## Examples for continuous endpoints ## Example 1: no prior-data conflict ## Suppose that the informative prior constructed from historical data is ## N(0, 3) sigma <- 3 prior.mean <- 0 prior.se <- sigma/sqrt(100) prior.historical <- mixnorm(c(1, prior.mean, prior.se), sigma = sigma) ## Data of the control arm data.control <- rnorm(80, mean = 0, sd = sigma) wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.3 * sigma, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM) ## Example 2: in the presence of prior-data conflict, where the current data ## has mean of 0.5 data.control <- rnorm(80, mean = 1, sd = sigma) wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.3 * sigma, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM) ## Examples for survival endpoints ## Example 1: no prior-data conflict ## Suppose the survival times from historical data follows exp(1) distribution ## with random censoring time follows U(0.5, 5) distribution T_hi <- rexp(100, rate = 1) C_hi <- runif(100, min = 0.5, max = 5) ## Indicators of the uncensored events delta_hi <- as.numeric(T_hi < C_hi) ## Observed survival times from historical data U_hi <- T_hi U_hi[delta_hi == 0] <- C_hi[delta_hi == 0] ## Construct the informative prior based on simulated historical data prior.historical <- mixgamma(c(1, sum(delta_hi), sum(U_hi)), param = 'ab', likelihood = 'exp') ## Suppose the survival times from control data follows exp(0.95) distribution ## with random censoring time follows U(0.5, 5) distribution T_ci <- rexp(100, rate = 0.95) C_ci <- runif(100, min = 0.5, max = 5) ## Indicators of the uncensored events delta_ci <- as.numeric(T_ci < C_ci) ## Observed survival times from control data U_ci <- T_ci U_ci[delta_ci == 0] <- C_ci[delta_ci == 0] ## Data of the control arm data.control <- rbind(sum(delta_ci), sum(U_ci)) wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.2, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM) ## Example 2: in the presence of prior-data conflict, where the current survival ## times follows exp(2) distribution with random censoring time follows U(0.5, 5) ## distribution T_ci <- rexp(100, rate = 2) C_ci <- runif(100, min = 0.5, max = 5) ## Indicators of the uncensored events delta_ci <- as.numeric(T_ci < C_ci) ## Observed survival times from control data U_ci <- T_ci U_ci[delta_ci == 0] <- C_ci[delta_ci == 0] ## Data of the control arm data.control <- rbind(sum(delta_ci), sum(U_ci)) wSAM <- SAM_weight(if.prior = prior.historical, delta = 0.2, ## Clinically significant difference data = data.control ## Control arm data ) print(wSAM)