Title: | Bayesian Meta-Analysis and Network Meta-Analysis |
---|---|
Description: | Contains functions performing Bayesian inference for meta-analytic and network meta-analytic models through Markov chain Monte Carlo algorithm. Currently, the package implements Hui Yao, Sungduk Kim, Ming-Hui Chen, Joseph G. Ibrahim, Arvind K. Shah, and Jianxin Lin (2015) <doi:10.1080/01621459.2015.1006065> and Hao Li, Daeyoung Lim, Ming-Hui Chen, Joseph G. Ibrahim, Sungduk Kim, Arvind K. Shah, Jianxin Lin (2021) <doi:10.1002/sim.8983>. For maximal computational efficiency, the Markov chain Monte Carlo samplers for each model, written in C++, are fine-tuned. This software has been developed under the auspices of the National Institutes of Health and Merck & Co., Inc., Kenilworth, NJ, USA. |
Authors: | Daeyoung Lim [aut, cre], Ming-Hui Chen [ctb], Sungduk Kim [ctb], Joseph Ibrahim [ctb], Arvind Shah [ctb], Jianxin Lin [ctb] |
Maintainer: | Daeyoung Lim <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3 |
Built: | 2024-11-20 04:53:40 UTC |
Source: | https://github.com/daeyounglim/metapack |
This is a function the fits the model introduced in Bayesian Network Meta-Regression Models Using Heavy-Tailed Multivariate Random Effects with Covariate-Dependent Variances. The first seven arguments are required except ZCovariate
. If not provided, ZCovariate
will be assigned a vector of ones, rep(1, length(Outcome))
. ZCovariate
is the centerpiece of the modeling of variances and the heavy-tailed random effects distribution.
bayes_nmr( Outcome, SD, XCovariate, ZCovariate, Treat, Trial, Npt, prior = list(), mcmc = list(), control = list(), init = list(), Treat_order = NULL, Trial_order = NULL, scale_x = FALSE, verbose = FALSE )
bayes_nmr( Outcome, SD, XCovariate, ZCovariate, Treat, Trial, Npt, prior = list(), mcmc = list(), control = list(), init = list(), Treat_order = NULL, Trial_order = NULL, scale_x = FALSE, verbose = FALSE )
Outcome |
the aggregate mean of the responses for each arm of every study. |
SD |
the standard deviation of the responses for each arm of every study. |
XCovariate |
the aggregate covariates for the fixed effects. |
ZCovariate |
the aggregate covariates associated with the variance of the random effects. |
Treat |
the treatment identifiers for trial arm. This is equivalent to the arm labels in each study. The elements within will be coerced to consecutive integers |
Trial |
the study/trial identifiers. The elements within will be coerced to consecutive integers. |
Npt |
the number of observations/participants for a unique |
prior |
(Optional) a list of hyperparameters. The hyperparameters include |
mcmc |
(Optional) a list of MCMC specification. |
control |
(Optional) a list of parameters for the Metropolis-Hastings algorithm. |
init |
(Optional) a list of initial values for the parameters to be sampled: |
Treat_order |
(Optional) a vector of unique treatments to be used for renumbering the |
Trial_order |
(Optional) a vector unique trials. The first element will be assigned trial zero. If not provided, the numbering will default to an alphabetical/numerical order. |
scale_x |
(Optional) a logical variable indicating whether |
verbose |
(Optional) a logical value indicating whether to print the progress bar during the MCMC sampling. |
bayes_nmr
returns an object of class "bayesnmr"
. The functions summary
or print
are used to obtain and print a summary of the results. The generic accessor function fitted
extracts the posterior mean, posterior standard deviation, and the interval estimates of the value returned by bayes_nmr
.
An object of class bayesnmr
is a list containing the following components:
Outcome
- the aggregate response used in the function call.
SD
- the standard deviation used in the function call.
Npt
- the number of participants for (k,t)
used in the function call.
XCovariate
- the aggregate design matrix for fixed effects used in the function call. Depending on scale_x
, this may differ from the matrix provided at function call.
ZCovariate
- the aggregate design matrix for random effects. bayes_nmr
will assign rep(1, length(Outcome))
if it was not provided at function call.
Trial
- the renumbered trial indicators. Depending on Trial_order
, it may differ from the vector provided at function call.
Treat
- the renumbered treatment indicators. Depending on Treat_order
, it may differ from the vector provided at function call.
TrtLabels
- the vector of treatment labels corresponding to the renumbered Treat
. This is equivalent to Treat_order
if it was given at function call.
TrialLabels
- the vector of trial labels corresponding to the renumbered Trial
. This is equivalent to Trial_order
if it was given at function call.
K
- the total number of trials.
nT
- the total number of treatments.
scale_x
- a Boolean indicating whether XCovariate
has been scaled/standardized.
prior
- the list of hyperparameters used in the function call.
control
- the list of tuning parameters used for MCMC in the function call.
mcmctime
- the elapsed time for the MCMC algorithm in the function call. This does not include all the other preprocessing and post-processing outside of MCMC.
mcmc
- the list of MCMC specification used in the function call.
mcmc.draws
- the list containing the MCMC draws. The posterior sample will be accessible here.
Daeyoung Lim, [email protected]
Li, H., Chen, M. H., Ibrahim, J. G., Kim, S., Shah, A. K., Lin, J., & Tershakovec, A. M. (2019). Bayesian inference for network meta-regression using multivariate random effects with applications to cholesterol lowering drugs. Biostatistics, 20(3), 499-516.
Li, H., Lim, D., Chen, M. H., Ibrahim, J. G., Kim, S., Shah, A. K., & Lin, J. (2021). Bayesian network meta-regression hierarchical models using heavy-tailed multivariate random effects with covariate-dependent variances. Statistics in Medicine.
bmeta_analyze
for using the Formula
interface
library(metapack) data(TNM) groupInfo <- list(c("PBO"), c("R")) nz <- length(groupInfo) ns <- nrow(TNM) XCovariate <- model.matrix(~ 0 + bldlc + bhdlc + btg + age + white + male + bmi + potencymed + potencyhigh + durat, data = TNM) XCovariate <- scale(XCovariate, center = TRUE, scale = FALSE) ZCovariate <- matrix(0, ns, nz) for (j in 1:length(groupInfo)) { for (i in 1:ns) { if (TNM$treat[i] %in% groupInfo[[j]]) { ZCovariate[i, j] <- 1 } } } addz <- scale(cbind(TNM$bldlc, TNM$btg), center=TRUE, scale=TRUE) ZCovariate <- cbind(1, ZCovariate, addz) theta_init <- c(0.05113, -1.38866, 1.09817, -0.85855, -1.12056, -1.14133, -0.22435, 3.63453, -2.09322, 1.07858, 0.80566, -40.76753, -45.07127, -28.27232, -44.14054, -28.13203, -19.19989, -47.21824, -51.31234, -48.46266, -47.71443) set.seed(2797542) fit <- bayes_nmr(TNM$ptg, TNM$sdtg, XCovariate, ZCovariate, TNM$treat, TNM$trial, TNM$n, prior = list(c01 = 1.0e05, c02 = 4, df = 3), mcmc = list(ndiscard = 1, nskip = 1, nkeep = 1), init = list(theta = theta_init), Treat_order = c("PBO", "S", "A", "L", "R", "P", "E", "SE", "AE", "LE", "PE"), scale_x = TRUE, verbose = FALSE)
library(metapack) data(TNM) groupInfo <- list(c("PBO"), c("R")) nz <- length(groupInfo) ns <- nrow(TNM) XCovariate <- model.matrix(~ 0 + bldlc + bhdlc + btg + age + white + male + bmi + potencymed + potencyhigh + durat, data = TNM) XCovariate <- scale(XCovariate, center = TRUE, scale = FALSE) ZCovariate <- matrix(0, ns, nz) for (j in 1:length(groupInfo)) { for (i in 1:ns) { if (TNM$treat[i] %in% groupInfo[[j]]) { ZCovariate[i, j] <- 1 } } } addz <- scale(cbind(TNM$bldlc, TNM$btg), center=TRUE, scale=TRUE) ZCovariate <- cbind(1, ZCovariate, addz) theta_init <- c(0.05113, -1.38866, 1.09817, -0.85855, -1.12056, -1.14133, -0.22435, 3.63453, -2.09322, 1.07858, 0.80566, -40.76753, -45.07127, -28.27232, -44.14054, -28.13203, -19.19989, -47.21824, -51.31234, -48.46266, -47.71443) set.seed(2797542) fit <- bayes_nmr(TNM$ptg, TNM$sdtg, XCovariate, ZCovariate, TNM$treat, TNM$trial, TNM$n, prior = list(c01 = 1.0e05, c02 = 4, df = 3), mcmc = list(ndiscard = 1, nskip = 1, nkeep = 1), init = list(theta = theta_init), Treat_order = c("PBO", "S", "A", "L", "R", "P", "E", "SE", "AE", "LE", "PE"), scale_x = TRUE, verbose = FALSE)
This is a function for running the Markov chain Monte Carlo algorithm for the Bayesian inference for multivariate meta-regression with a partially observed within-study sample covariance matrix model. The first six arguments are required.
fmodel can be one of 5 numbers: 1, 2, 3, 4, and 5. The first model, fmodel = 1 denoted by M1, indicates that the
are diagonal matrices with zero covariances. M2 indicates that
are all equivalent but allowed to be full symmetric
positive definite. M3 is where
are allowed to differ across treatments, i.e.,
.
M4 assumes thata the correlation matrix,
, is identical for all trials/treatments, but the variances are allowed to vary.
Finally, M5 assumes a hierarchical model where
follows an inverse-Wishart distribution with fixed
degrees of freedom and scale matrix
.
then follows another inverse-Wishart distribution with fixed parameters.
bayes_parobs( Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, fmodel = 1, prior = list(), mcmc = list(), control = list(), init = list(), Treat_order = NULL, Trial_order = NULL, group = NULL, group_order = NULL, scale_x = FALSE, verbose = FALSE )
bayes_parobs( Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, fmodel = 1, prior = list(), mcmc = list(), control = list(), init = list(), Treat_order = NULL, Trial_order = NULL, group = NULL, group_order = NULL, scale_x = FALSE, verbose = FALSE )
Outcome |
the aggregate mean of the responses for each arm of every study. |
SD |
the standard deviation of the responses for each arm of every study. |
XCovariate |
the aggregate covariates for the fixed effects. |
WCovariate |
the aggregate covariates for the random effects. |
Treat |
the treatment identifiers. This is equivalent to the arm number of each study. The number of unique treatments must be equal across trials. The elements within will be coerced to consecutive integers. |
Trial |
the trial identifiers. This is equivalent to the arm labels in each study. The elements within will be coerced to consecutive integers |
Npt |
the number of observations/participants for a unique |
fmodel |
the model number. The possible values for
|
prior |
(Optional) a list of hyperparameters. Despite |
mcmc |
(Optional) a list for MCMC specification. |
control |
(Optional) a list of tuning parameters for the Metropolis-Hastings algorithm. |
init |
(Optional) a list of initial values for the parameters to be sampled: |
Treat_order |
(Optional) a vector of unique treatments to be used for renumbering the |
Trial_order |
(Optional) a vector of unique trials. The first element will be assigned zero. If not provided, the numbering will default to an alphabetical/numerical order. |
group |
(Optional) a vector containing binary variables for |
group_order |
(Optional) a vector of unique group labels. The first element will be assigned zero. If not provided, the numbering will default to an alphabetical/numerical order. |
scale_x |
(Optional) a logical variable indicating whether |
verbose |
(Optional) a logical variable indicating whether to print the progress bar during the MCMC sampling. |
bayes_parobs
returns an object of class "bayesparobs"
. The functions summary
or print
are used to obtain and print a summary of the results. The generic accessor function fitted
extracts the posterior mean, posterior standard deviation, and the interval estimates of the value returned by bayes_parobs
.
An object of class bayesparobs
is a list containing the following components:
Outcome
- the aggregate response used in the function call.
SD
- the standard deviation used in the function call.
Npt
- the number of participants for (k,t)
used in the function call.
XCovariate
- the aggregate design matrix for fixed effects used in the function call. Depending on scale_x
, this may differ from the matrix provided at function call.
WCovariate
- the aggregate design matrix for random effects.
Treat
- the renumbered treatment indicators. Depending on Treat_order
, it may differ from the vector provided at function call.
Trial
- the renumbered trial indicators. Depending on Trial_order
, it may differ from the vector provided at function call.
group
- the renumbered grouping indicators in the function call. Depending on group_order
, it may differ from the vector provided at function call. If group
was missing at function call, bayes_parobs
will assign NULL
for group
.
TrtLabels
- the vector of treatment labels corresponding to the renumbered Treat
. This is equivalent to Treat_order
if it was given at function call.
TrialLabels
- the vector of trial labels corresponding to the renumbered Trial
. This is equivalent to Trial_order
if it was given at function call.
GroupLabels
- the vector of group labels corresponding to the renumbered group
. This is equivalent to group_order
if it was given at function call. If group
was missing at function call, bayes_parobs
will assign NULL
for GroupLabels
.
K
- the total number of trials.
T
- the total number of treatments.
fmodel
- the model number as described here.
scale_x
- a Boolean indicating whether XCovariate
has been scaled/standardized.
prior
- the list of hyperparameters used in the function call.
control
- the list of tuning parameters used for MCMC in the function call.
mcmctime
- the elapsed time for the MCMC algorithm in the function call. This does not include all the other preprocessing and post-processing outside of MCMC.
mcmc
- the list of MCMC specification used in the function call.
mcmc.draws
- the list containing the MCMC draws. The posterior sample will be accessible here.
Daeyoung Lim, [email protected]
Yao, H., Kim, S., Chen, M. H., Ibrahim, J. G., Shah, A. K., & Lin, J. (2015). Bayesian inference for multivariate meta-regression with a partially observed within-study sample covariance matrix. Journal of the American Statistical Association, 110(510), 528-544.
bmeta_analyze
for using the Formula
interface
library(metapack) data("cholesterol") Outcome <- model.matrix(~ 0 + pldlc + phdlc + ptg, data = cholesterol) SD <- model.matrix(~ 0 + sdldl + sdhdl + sdtg, data = cholesterol) Trial <- cholesterol$trial Treat <- cholesterol$treat Npt <- cholesterol$n XCovariate <- model.matrix(~ 0 + bldlc + bhdlc + btg + age + durat + white + male + dm, data = cholesterol) WCovariate <- model.matrix(~ treat, data = cholesterol) fmodel <- 1 set.seed(2797542) fit <- bayes_parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, fmodel, mcmc = list(ndiscard = 1, nskip = 1, nkeep = 1), scale_x = TRUE, group = cholesterol$onstat, verbose = FALSE)
library(metapack) data("cholesterol") Outcome <- model.matrix(~ 0 + pldlc + phdlc + ptg, data = cholesterol) SD <- model.matrix(~ 0 + sdldl + sdhdl + sdtg, data = cholesterol) Trial <- cholesterol$trial Treat <- cholesterol$treat Npt <- cholesterol$n XCovariate <- model.matrix(~ 0 + bldlc + bhdlc + btg + age + durat + white + male + dm, data = cholesterol) WCovariate <- model.matrix(~ treat, data = cholesterol) fmodel <- 1 set.seed(2797542) fit <- bayes_parobs(Outcome, SD, XCovariate, WCovariate, Treat, Trial, Npt, fmodel, mcmc = list(ndiscard = 1, nskip = 1, nkeep = 1), scale_x = TRUE, group = cholesterol$onstat, verbose = FALSE)
All other worker functions are superseded by this function, so that users can forget about the implementation details and focus on modeling. Meta-analytic data can be either aggregate or individual participant data (IPD). Aggregate data implies that the response consists of estimated effect sizes and their corresponding standard errors, whereas IPD is raw data. Data sets to be used for metapack should be formatted as follows:
Outcome | SD | DesignM1 | DesignM2 | Trial indicator (k ) |
Treatment indicator (t ) |
n |
|
|
|
|
1 | 3 | 1000 |
|
|
|
|
1 | 0 | 545 |
|
|
|
|
2 | 0 | 1200 |
The first treatment indicator is intentionally selected to be 3, a number greater than 1, to indicate that this data format works for both meta-regression and network meta-regression. Meta-regression refers to when trials included have 2 treatments (i.e., for all
), and the treatments are compared head to head. On the other hand, network meta-regression includes more than two treatments, where each trial can have a different set of treatments, allowing indirect comparison between treatments that are not compared head to head as long as consistency holds (see Higgins et al. (2012) for consistency).
bmeta_analyze()
and bmeta_analyse()
are synonyms.
bmeta_analyze( formula, data, prior = list(), mcmc = list(), control = list(), init = list() ) bmeta_analyse( formula, data, prior = list(), mcmc = list(), control = list(), init = list() )
bmeta_analyze( formula, data, prior = list(), mcmc = list(), control = list(), init = list() ) bmeta_analyse( formula, data, prior = list(), mcmc = list(), control = list(), init = list() )
formula |
an object of class Formula: a symbolic description of the meta-analytic model to fit. For aggregate models, the vector of arm sample sizes must be provided using the function |
data |
a data frame, list, or environment (or an object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in |
prior |
an optional object that contains the hyperparameter values for the model. To see the complete list of hyperparameters for a specific model, refer to the corresponding worker function's help page, e.g.,
For network meta-analysis,
|
mcmc |
an optional object containing MCMC specification. |
control |
an optional object that contains the control tuning parameters for the Metropolis-Hastings algorithm. Similar to
|
init |
(Optional) a list of initial values for the parameters to be sampled. The following is the list of available parameters for meta-analysis and network meta-analysis.
The dimensions of the initial values must be conformable for matrix operations. If dimensions don't agree, |
bmeta_analyze
currently subsumes two worker functions: bayes_parobs
and bayes_nmr
. bmeta_analyze
offers a formula interface.
All formulas are parsed using Formula. Formulas for bmeta_analyze
are constrained to have a strict structure: one or two LHS, and two or three RHS. That is, lhs_1 ~ rhs_1 | rhs2 | rhs3
or lhs_1 | lhs_2 ~ rhs_1 | rhs2 | rhs3
(see Examples for more). The tilde (~
) separates the LHS's and RHS's, each side further separated into parts by vertical bars (|
).
The meaning of each part is syntactically determined by its location inside the formula, like an English sentence. Therefore, all parts must come in the exact order as prescribed for bmeta_analyze
to correctly configure your model.
The first LHS, the responses, is required for all models.
The second LHS is only required for aggregate models, corresponding to the standard deviations of the responses.
The first RHS corresponds to fixed-effects covariates.
The second RHS corresponds to the variables in either the random-effects matrix (') for multivariate meta-analysis or modeling the variances (
=
) for univariate network meta-analysis.
The third RHS corresponds to the treatment and trial indicators, and optionally the grouping variable if it exists. The order must be treat + trial + group
, or treat + trial
if no grouping exists. Variables here must be supplied in the exact order described; otherwise, model will not be correctly identified.
Internally, bmeta_analyze
looks for three things: multivariate/univariate, meta-analyis/network meta-analysis, and aggregate/IPD.
multivariate/univariate: the dimension of the response is explicit in the formula, and determines univariate versus multivariate.
meta-analysis/network meta-analysis: the number of levels (nlevels
) of treatments determines this. If treat
is not already a factor variable, it is coerced to one.
aggregate/IPD: bmeta_analyze
looks for ns()
in the first RHS. Aggregate models must provide the arm sample sizes using the function ns()
(e.g., if n
is the sample sizes, y1 + y2 | sd1 + sd2 ~ x1 + x2 + ns(n))
). If there is no ns()
, IPD is assumed. Currently, IPD models are a work in progress and not supported yet.
Currently, only univariate/multivariate
+ meta-analysis
and univariate
+ network meta-analysis
are allowed. More models will be added in the future.
bmeta_analyze
returns a classed object of bsynthesis
for Bayesian synthesis
Daeyoung Lim, [email protected]
Yao, H., Kim, S., Chen, M. H., Ibrahim, J. G., Shah, A. K., & Lin, J. (2015). Bayesian inference for multivariate meta-regression with a partially observed within-study sample covariance matrix. Journal of the American Statistical Association, 110(510), 528-544.
Li, H., Chen, M. H., Ibrahim, J. G., Kim, S., Shah, A. K., Lin, J., & Tershakovec, A. M. (2019). Bayesian inference for network meta-regression using multivariate random effects with applications to cholesterol lowering drugs. Biostatistics, 20(3), 499-516.
Li, H., Lim, D., Chen, M. H., Ibrahim, J. G., Kim, S., Shah, A. K., & Lin, J. (2021). Bayesian network meta-regression hierarchical models using heavy-tailed multivariate random effects with covariate-dependent variances. Statistics in Medicine.
bayes_parobs
for multivariate meta-analysis, and bayes_nmr
for univariate network meta-analysis.
set.seed(2797542) data("cholesterol") f_1 <- 'pldlc + phdlc + ptg | sdldl + sdhdl + sdtg ~ 0 + bldlc + bhdlc + btg + age + durat + white + male + dm + ns(n) | treat | treat + trial + onstat' out_1 <- bmeta_analyze(as.formula(f_1), data = cholesterol, prior = list(model="NoRecovery"), mcmc = list(ndiscard = 3, nskip = 1, nkeep = 1), control=list(scale_x = TRUE, verbose=FALSE)) set.seed(2797542) data("TNM") TNM$group <- factor(match(TNM$treat, c("PBO", "R"), nomatch = 0)) f_2 <- 'ptg | sdtg ~ 0 + bldlc + bhdlc + btg + age + white + male + bmi + potencymed + potencyhigh + durat + ns(n) | scale(bldlc) + scale(btg) + group | treat + trial' out_2 <- bmeta_analyze(as.formula(f_2), data = TNM, mcmc = list(ndiscard = 1, nskip = 1, nkeep = 1), control=list(scale_x = TRUE, verbose=FALSE))
set.seed(2797542) data("cholesterol") f_1 <- 'pldlc + phdlc + ptg | sdldl + sdhdl + sdtg ~ 0 + bldlc + bhdlc + btg + age + durat + white + male + dm + ns(n) | treat | treat + trial + onstat' out_1 <- bmeta_analyze(as.formula(f_1), data = cholesterol, prior = list(model="NoRecovery"), mcmc = list(ndiscard = 3, nskip = 1, nkeep = 1), control=list(scale_x = TRUE, verbose=FALSE)) set.seed(2797542) data("TNM") TNM$group <- factor(match(TNM$treat, c("PBO", "R"), nomatch = 0)) f_2 <- 'ptg | sdtg ~ 0 + bldlc + bhdlc + btg + age + white + male + bmi + potencymed + potencyhigh + durat + ns(n) | scale(bldlc) + scale(btg) + group | treat + trial' out_2 <- bmeta_analyze(as.formula(f_2), data = TNM, mcmc = list(ndiscard = 1, nskip = 1, nkeep = 1), control=list(scale_x = TRUE, verbose=FALSE))
A data set containing clinical trial on hypercholesterolemia including 26 trials and 2 treatment arms each, and other attributes of the participants
data(cholesterol)
data(cholesterol)
A data frame with 52 rows and 19 variables
study identifier
trial identifier
treatment indicator for Statin or Statin+Ezetimibe
the number of participants in the study arms corresponding to the trial and treatment
aggregate percentage change in LDL-C
aggregate percentage change from baseline in HDL-C
aggregate percentage change from baseline in triglycerides (TG)
sample standard deviation of percentage change in LDL-C
sample standard deviation of percentage change in HDL-C
sample standard deviation of percentage change in triglycerides (TG)
whether the participants were on Statin prior to the trial
baseline LDL-C
baseline HDL-C
baseline triglycerides (TG)
age in years
the proportion of white participants
the proportion of male participants
the proportion of participants with diabetes mellitus
duration in weeks
data(cholesterol)
data(cholesterol)
get the posterior mean of fixed-effect coefficients
## S3 method for class 'bsynthesis' coef(object, ...)
## S3 method for class 'bsynthesis' coef(object, ...)
object |
a class of |
... |
other arguments |
Coefficients extracted from the model object object
get fitted values
## S3 method for class 'bayesnmr' fitted(object, level = 0.95, HPD = TRUE, ...)
## S3 method for class 'bayesnmr' fitted(object, level = 0.95, HPD = TRUE, ...)
object |
the output model from fitting a meta analysis/regression model |
level |
credible level for interval estimation; set to 0.95 by default |
HPD |
a logical argument indicating whether HPD intervals should be computed; if FALSE, equal-tail credible intervals are computed |
... |
additional arguments for fitted |
a list of fitted values
get fitted values
## S3 method for class 'bayesparobs' fitted(object, level = 0.95, HPD = TRUE, ...)
## S3 method for class 'bayesparobs' fitted(object, level = 0.95, HPD = TRUE, ...)
object |
the output model from fitting a meta analysis/regression model |
level |
credible level for interval estimation; set to 0.95 by default |
HPD |
a logical argument indicating whether HPD intervals should be computed; if FALSE, equal-tail credible intervals are computed |
... |
additional arguments for fitted |
a list of fitted values
get the highest posterior density (HPD) interval
hpd(object, parm, level = 0.95, HPD = TRUE)
hpd(object, parm, level = 0.95, HPD = TRUE)
object |
the output model from fitting a (network) meta analysis/regression model |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the probability which the HPD interval will cover |
HPD |
a logical value indicating whether HPD or equal-tailed credible interval should be computed; by default, TRUE |
A % HPD interval for
is given by
where is the largest constant that satisfies
.
hpd
computes the HPD interval from an MCMC sample by letting be the
th smallest of the MCMC sample,
and denoting
for . Once
's are sorted, the appropriate
is chosen so that
dataframe containing HPD intervals for the parameters
Chen, M. H., & Shao, Q. M. (1999). Monte Carlo estimation of Bayesian credible and HPD intervals. Journal of Computational and Graphical Statistics, 8(1), 69-92.
get the highest posterior density (HPD) interval
## S3 method for class 'bayesnmr' hpd(object, parm, level = 0.95, HPD = TRUE)
## S3 method for class 'bayesnmr' hpd(object, parm, level = 0.95, HPD = TRUE)
object |
the output model from fitting a (network) meta analysis/regression model |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the probability which the HPD interval will cover |
HPD |
a logical value indicating whether HPD or equal-tailed credible interval should be computed; by default, TRUE |
dataframe containing HPD intervals for the parameters
get the highest posterior density (HPD) interval or equal-tailed credible interval
## S3 method for class 'bayesparobs' hpd(object, parm, level = 0.95, HPD = TRUE)
## S3 method for class 'bayesparobs' hpd(object, parm, level = 0.95, HPD = TRUE)
object |
the output model from fitting a (network) meta analysis/regression model |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the probability which the HPD interval will cover |
HPD |
a logical value indicating whether HPD or equal-tailed credible interval should be computed; by default, TRUE |
dataframe containing HPD intervals for the parameters
The metapack package provides one category of functions: bayes.parobs and bayes.nmr
The bayes.parobs function fits the multivariate meta-regression model with partially observed sample covariance matrix to the given data.
The bayes.nmr function fits the network meta-regression model with heavy-tailed random effects distribution to the given data.
model_comp
is a generic function that computes the model comparison measures (DIC and LPML) or the Pearson's residuals. Note that the Pearson's residuals are not available for bayes.nmr
when df
is either random or fixed but smaller than 2 since the variance of the random effects is not finite.
model_comp(object, type = "lpml", verbose = FALSE, ncores = NULL)
model_comp(object, type = "lpml", verbose = FALSE, ncores = NULL)
object |
the output model from fitting a meta analysis/regression model |
type |
the type of model comparison measure to compute; DIC or LPML |
verbose |
FALSE by default; If TRUE, then progress bar will appear |
ncores |
the number of CPU cores to use for parallel processing. It must not exceed the number of existing cores. If unspecified, it will default to 2 cores or the number of existing cores, whichever is smaller. |
dataframe containing the compute the model comparison measures
get compute the model comparison measures
## S3 method for class 'bayesnmr' model_comp(object, type = "lpml", verbose = FALSE, ncores = NULL)
## S3 method for class 'bayesnmr' model_comp(object, type = "lpml", verbose = FALSE, ncores = NULL)
object |
the output model from fitting a meta analysis/regression model |
type |
the type of model comparison measures; DIC or LPML |
verbose |
FALSE by default; If TRUE, then progress bar will appear |
ncores |
the number of CPU cores to use for parallel processing. It must not exceed the number of existing cores. If unspecified, it will default to 2 cores or the number of existing cores, whichever is smaller. |
dataframe containing the compute the model comparison measures
compute the model comparison measures
## S3 method for class 'bayesparobs' model_comp(object, type = "lpml", verbose = FALSE, ncores = NULL)
## S3 method for class 'bayesparobs' model_comp(object, type = "lpml", verbose = FALSE, ncores = NULL)
object |
the output model from fitting a meta analysis/regression model |
type |
the type of model comparison measures; DIC or LPML |
verbose |
FALSE by default; If TRUE, then progress bar will appear |
ncores |
the number of CPU cores to use for parallel processing. It must not exceed the number of existing cores. If unspecified, it will default to 2 cores or the number of existing cores, whichever is smaller. |
dataframe containing the compute the model comparison measures
helper function encoding trial sample sizes in formulas
ns(x)
ns(x)
x |
the name of the variable containing trial sample sizes |
get goodness of fit
## S3 method for class 'bayesnmr' plot(x, ...)
## S3 method for class 'bayesnmr' plot(x, ...)
x |
the output model from fitting a meta analysis/regression model |
... |
additional parameters for plot |
No return value
get goodness of fit
## S3 method for class 'bayesparobs' plot(x, ...)
## S3 method for class 'bayesparobs' plot(x, ...)
x |
the output model from fitting a meta analysis/regression model |
... |
additional parameters for plot |
No return value
plot the surface under the cumulative ranking curve (SUCRA)
## S3 method for class 'sucra' plot(x, legend.position = "none", ...)
## S3 method for class 'sucra' plot(x, legend.position = "none", ...)
x |
the output model from fitting a network meta analysis/regression model |
legend.position |
the position of the legend that will be passed onto ggplot |
... |
additional arguments for plot |
No return value
Print results
## S3 method for class 'bayesnmr' print(x, level = 0.95, HPD = TRUE, ...)
## S3 method for class 'bayesnmr' print(x, level = 0.95, HPD = TRUE, ...)
x |
the output model from fitting a network meta analysis/regression model |
level |
credible level for interval estimation; set to 0.95 by default |
HPD |
a logical argument indicating whether HPD intervals should be computed; if FALSE, equal-tail credible intervals are computed |
... |
additional arguments for print |
No return value; print a summary of the output
Print results
## S3 method for class 'bayesparobs' print(x, level = 0.95, HPD = TRUE, ...)
## S3 method for class 'bayesparobs' print(x, level = 0.95, HPD = TRUE, ...)
x |
the output model from fitting a meta analysis/regression model |
level |
credible level for interval estimation; set to 0.95 by default |
HPD |
a logical argument indicating whether HPD intervals should be computed; if FALSE, equal-tail credible intervals are computed |
... |
additional arguments for print |
No return value; print a summary of the output
get surface under the cumulative ranking curve (SUCRA)
sucra(object)
sucra(object)
object |
the output model from fitting a network meta analysis/regression model |
a list containing SUCRA and the discrete rank probability matrix of size T by T
get surface under the cumulative ranking curve (SUCRA)
## S3 method for class 'bayesnmr' sucra(object)
## S3 method for class 'bayesnmr' sucra(object)
object |
the output model from fitting a network meta analysis/regression model |
a list containing SUCRA and the discrete rank probability matrix of size T by T
'summary' method for class "'bayesnmr'"
## S3 method for class 'bayesnmr' summary(object, level = 0.95, HPD = TRUE, ...)
## S3 method for class 'bayesnmr' summary(object, level = 0.95, HPD = TRUE, ...)
object |
the output model from fitting a network meta analysis/regression model |
level |
credible level for interval estimation; set to 0.95 by default |
HPD |
a logical argument indicating whether HPD intervals should be computed; if FALSE, equal-tail credible intervals are computed |
... |
additional arguments for print |
does not return anything; print a summary of the output
summary
method for class "bayesparobs
"summary
method for class "bayesparobs
"
## S3 method for class 'bayesparobs' summary(object, level = 0.95, HPD = TRUE, ...)
## S3 method for class 'bayesparobs' summary(object, level = 0.95, HPD = TRUE, ...)
object |
the output model from fitting a meta analysis/regression model |
level |
credible level for interval estimation; set to 0.95 by default |
HPD |
a logical argument indicating whether HPD intervals should be computed; if FALSE, equal-tail credible intervals are computed |
... |
additional arguments for summary |
print summary for the model fit
A systemically reviewed network meta data set on tryglyceride (TG) lowering drugs
data(TNM)
data(TNM)
A data frame with 73 rows and 15 variables
trial identifier
treatment indicator for placebo (PBO), simvastatin (S), atorvastatin (A), lovastatin (L), rosuvastatin (R), pravastatin (P), ezetimibe (E), simvastatin+ezetimibe (SE), atorvastatin+ezetimibe (AE), lovastatin+ezetimibe (LE), or pravastatin+ezetimibe (PE)
the number of participants in the study corresponding to the trial and treatment
percentage change from baseline in triglycerides (TG)
sample standard deviation of percentage change in triglycerides (TG)
baseline LDL-C
baseline HDL-C
baseline triglycerides (TG)
age in years
the proportion of white participants
the proportion of male participants
body fat index
the proportion of medium statin potency
the proportion of high statin potency
duration in weeks
data(TNM)
data(TNM)