Type: Package
Title: Flexible Evaluation of Surrogate Markers with Bayesian Model Averaging
Version: 1.0
Date: 2024-01-21
Description: Provides functions to estimate the proportion of treatment effect explained by the surrogate marker using a Bayesian Model Averaging approach. Duan and Parast (2023) <doi:10.1002/sim.9986>.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Imports: Rcpp (≥ 1.0.9), MCMCpack, mvtnorm, Rsurrogate
LinkingTo: Rcpp, RcppEigen, RcppNumerical
Depends: R (≥ 3.5.0)
LazyData: true
NeedsCompilation: yes
Packaged: 2024-01-29 21:01:37 UTC; yunshanduan
Author: Yunshan Duan [aut, cre], Layla Parast [aut]
Maintainer: Yunshan Duan <yunshan@utexas.edu>
Repository: CRAN
Date/Publication: 2024-02-01 10:20:06 UTC

Flexible Evaluation of Surrogate Markers with Bayesian Model Averaging

Description

Provides functions to estimate the proportion of treatment effect explained by the surrogate marker using Bayesian Model Averaging approach.

Author(s)

Yunshan Duan

Maintainer: Yunshan Duan <yunshan@utexas.edu>

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.


Calculates the proportion of treatment effect explained

Description

Calculates the proportion of treatment effect on the primary outcome explained by the treatment effect on the surrogate marker using Bayesian Model Averaging (BMA). This function is intended to be used for a fully observed continuous outcome and one single continuous surrogate marker. The user can also request to calculate a 95% credible interval, evaluated by Bayesian bootstrapping. A robust option is provided where we choose a more preferrable approach between the BMA and non-parametric methods based on cross-validation.

Usage

R.BMA.est(Y, S, A, method = "BMA", nmc = 500, nBB = 100, conf.int = TRUE, 
alpha = 0.05, prior.para = NULL, kfold.k = 3)

Arguments

Y

numeric vector; primary outcome, assumed to be continuous.

S

numeric vector; surrogate marker, assumed to be continuous.

A

numeric vector; treatment arm, assumed to be binary. The treatment arm = 1 when the patient is enrolled in the treatment group, treatment arm = 0 when in the control group.

method

"BMA" or "robust"; Default is "BMA". If method = "robust", we choose a more preferrable approach between the BMA and non-parametric methods based on cross-validation.

nmc

number of MCMC samples in posterior inference, default is 500.

nBB

number of replicates in Bayesian bootstrap, default is 100. Igored if conf.int = FALSE.

conf.int

TRUE or FALSE; indicates whether a 95% credible interval for the proportion explained is requested, default is TRUE.

alpha

the confidence level for the credible interval, the 100(1 - \alpha)% credible interval is calculated. Default is 0.05, ignored if conf.int = FALSE.

prior.para

a list of hyper-parameters in the inverse-Gamma-Normal prior for the variance and coefficients, including a0_list, b0_list, mu0_list, Gamma0_list, Gamma0_inv_list , each being a list of 5 with 5 parameters under the 5 different candidate models. An Inv-Gamma(a0, b0) - Normal(mu0, \sigma^2 Gamma0) prior is assumed.

kfold.k

the value of k in k-fold cross validation, default is 3. Ignored if method = "BMA".

Value

R.est

the estimate of the proportion explained by the surrogate marker.

p.model

the posterior probability of the candidate models being true.

ci

the credible (confidence) interval for the proportion explained by the surrogate marker.

Author(s)

Yunshan Duan

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.

Examples


data(exampleData)
R.BMA.est(Y = exampleData$Y, S = exampleData$S, A = exampleData$A)


Calculates the proportion of treatment effect explained

Description

Calculates the proportion of treatment effect on the primary outcome explained by the treatment effect on the surrogate marker using Bayesian Model Averaging. This function is intended to be used for a fully observed continuous outcome and one single continuous surrogate marker. The user can also request to calculate a 95% credible interval, evaluated by Bayesian bootstrapping. The MSE of predicting the primary outcome in the treatment can be calculated when test data is given.

Usage

R.BMAonly(Y, S, A, nmc = 500, nBB = 100, conf.int = TRUE, alpha = 0.05, 
prior.para = NULL, testdata = FALSE, Ytest = NULL, Stest = NULL, Atest = NULL)

Arguments

Y

numeric vector; primary outcome, assumed to be continuous.

S

numeric vector; surrogate marker, assumed to be continuous.

A

numeric vector; treatment arm, assumed to be binary. The treatment arm = 1 when the patient is enrolled in the treatment group, treatment arm = 0 when in the control group.

nmc

number of MCMC samples in posterior inference, default is 500.

nBB

number of replicates in Bayesian bootstrap, default is 100. Igored if conf.int = FALSE.

conf.int

TRUE or FALSE; indicates whether a 95% credible interval for the proportion explained is requested, default is TRUE.

alpha

the confidence level for the credible interval, the 100(1 - \alpha)% credible interval is calculated. Default is 0.05, ignored if conf.int = FALSE.

prior.para

a list of hyper-parameters in the inverse-Gamma-Normal prior for the variance and coefficients, including a0_list, b0_list, mu0_list, Gamma0_list, Gamma0_inv_list , each being a list of 5 with 5 parameters under the 5 different candidate models. An Inv-Gamma(a0, b0) - Normal(mu0, \sigma^2 Gamma0) prior is assumed.

testdata

TRUE or FALSE; indicates whether test data is available, default is FALSE. The MSE of predicting the primary outcome is evaluated if TRUE.

Ytest

numeric vector; primary outcome in test data, assumed to be continuous. Default is NULL, ignored if testdata = FALSE.

Stest

numeric vector; surrogate marker in test data, assumed to be continuous. Default is NULL, ignored if testdata = FALSE.

Atest

numeric vector; treatment arm in test data, assumed to be binary. The treatment arm = 1 when the patient is enrolled in the treatment group, treatment arm = 0 when in the control group. Default is NULL, ignored if testdata = FALSE.

Value

R.BMA

the estimate of the proportion explained by the surrogate marker.

p.model

the posterior probability of the candidate models being true.

ci

the credible interval for the proportion explained by the surrogate marker.

MSE

the MSE of predicting the primary outcome for test data.

Author(s)

Yunshan Duan

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.

Examples


data(exampleData)
R.BMAonly(Y = exampleData$Y, S = exampleData$S, A = exampleData$A)


Calculates the R value given model and parameters

Description

Provides a function to calculate F_m(theta_m).

Usage

R.m.theta(S, m, theta, A, weight = FALSE, nBB = 100)

Arguments

S
m
theta
A
weight
nBB

Value

a numeric value or a numeric verctor when weight = TRUE. the value of R or the values of R using Bayesian bootstap replicates of the surrogate marker.

Author(s)

Yunshan Duan


Calculate prodiction MSE for nonparametric method

Description

Function to calculate prodiction MSE for nonparametric method.

Usage

cv.np(Y, S, A, Ytest, Stest, Atest)

Arguments

Y
S
A
Ytest
Stest
Atest

Value

a numeric value; MSE in cross-validation.

Author(s)

Yunshan Duan

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.


Example data

Description

Example data

Usage

data("exampleData")

Format

A data frame with 400 rows and 3 variables:

Y

the primary outcome

S

the surrogate marker

A

the treatmentt arm

Examples

data(exampleData)
names(exampleData)

Function to be integrated when calculating the expected primary outcome

Description

Function to be integrated when calculating the expected primary outcome.

Usage

fpred.int(eps, mu, sig, m)

Arguments

eps
mu
sig
m

Value

a function.

Author(s)

Yunshan Duan

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.


Generates the default prior hyperparameters

Description

Generates a list of hyper-parameters we use by default in the inverse-Gamma-Normal prior for the variance and coefficients, including a0_list, b0_list, mu0_list, Gamma0_list, Gamma0_inv_list , each being a list of 5 with 5 parameters under the 5 different candidate models. An Inv-Gamma(a0, b0) - Normal(mu0, \sigma^2 Gamma0) prior is assumed.

Usage

gen.prior()

Value

A list of hyper-parameters, including a0_list, b0_list, mu0_list, Gamma0_list, Gamma0_inv_list , each being a list of 5 with 5 parameters under the 5 different candidate models.

Author(s)

Yunshan Duan

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.

Examples

gen.prior()

# if we want to change the prior parameter a0 in model 1
prior.para <- gen.prior()
prior.para$a0_list[[1]] <- 1

Simple function using Rcpp

Description

Simple function using Rcpp

Usage

gpxi_int(i, m, beta, S0, S1, sig2)	

Examples

## Not run: 
gpxi_int(i, m, beta, S0, S1, sig2)

## End(Not run)

Calculates the posterior probability of the candidate models

Description

Gives the posterior probability of each candidate model being true.

Usage

post.model(Y, S, A, prior.para = NULL)

Arguments

Y

numeric vector; primary outcome, assumed to be continuous.

S

numeric vector; surrogate marker, assumed to be continuous.

A

numeric vector; treatment arm, assumed to be binary. The treatment arm = 1 when the patient is enrolled in the treatment group, treatment arm = 0 when in the control group.

prior.para

a list of hyper-parameters in the inverse-Gamma-Normal prior for the variance and coefficients, including a0_list, b0_list, mu0_list, Gamma0_list, Gamma0_inv_list , each being a list of 5 with 5 parameters under the 5 different candidate models. An Inv-Gamma(a0, b0) - Normal(mu0, \sigma^2 Gamma0) prior is assumed.

Value

a numeric vector; the posterior probabilities of the candidate models.

Author(s)

Yunshan Duan

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.

Examples

data(exampleData)
post.model(Y = exampleData$Y, S = exampleData$S, A = exampleData$A)

Generates posterior samples of the parameters

Description

Provides a function to generate MCMC samples of p(theta_m | M = m, Data).

Usage

post.theta(Y, S, A, m, nmc = 500, prior.para = NULL)

Arguments

Y
S
A
m
nmc
prior.para

Value

a numeric matrix; each row contains a MC sample from the posterior of the parameters given a certain model.

Author(s)

Yunshan Duan

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.


Calculate the expected primary outcome in the treatment group given the model and the parameters

Description

Provides a function to calculate the expected primary outcome in the treatment group given the model and the parameters.

Usage

pred.func(theta, ST, m)

Arguments

theta
ST
m

Value

a numeric vector.

Author(s)

Yunshan Duan

References

Duan, Y. and Parast, L., 2023. Flexible evaluation of surrogate markers with Bayesian model averaging. Statistics in Medicine.


Simple function using Rcpp

Description

Simple function using Rcpp

Usage

rcpp_hello_world()	

Examples

## Not run: 
rcpp_hello_world()

## End(Not run)