Title: | Multivariate Meta-Analysis |
---|---|
Description: | Multiple 2 by 2 tables often arise in meta-analysis which combines statistical evidence from multiple studies. Two risks within the same study are possibly correlated because they share some common factors such as environment and population structure. This package implements a set of novel Bayesian approaches for multivariate meta analysis when the risks within the same study are independent or correlated. The exact posterior inference of odds ratio, relative risk, and risk difference given either a single 2 by 2 table or multiple 2 by 2 tables is provided. Luo, Chen, Su, Chu, (2014) <doi:10.18637/jss.v056.i11>, Chen, Luo, (2011) <doi:10.1002/sim.4248>, Chen, Chu, Luo, Nie, Chen, (2015) <doi:10.1177/0962280211430889>, Chen, Luo, Chu, Su, Nie, (2014) <doi:10.1080/03610926.2012.700379>, Chen, Luo, Chu, Wei, (2013) <doi:10.1080/19466315.2013.791483>. |
Authors: | Sheng Luo [aut], Yong Chen [aut], Xiao Su [aut], Haitao Chu [aut], Jiajie Chen [cre], Wally Gilks [ctb], Giovanni Petris [ctb], Luca Tardella [ctb] |
Maintainer: | Jiajie Chen <[email protected]> |
License: | GPL (>= 2) |
Version: | 3.0.1 |
Built: | 2025-02-27 19:21:03 UTC |
Source: | CRAN |
Results from 20 case-control studies investigating the association between rapid NAT2 acetylator status and colorectal cancer
The data frame contains the following columns:
number of subjects with rapid NAT2 acetylator status in the control group
number of subjects in the control group (without colorectal cancer)
number of subjects with rapid NAT2 acetylator status in the case group
number of subjects in the case group (with colorectal cancer)
The study names indicating the last name of the first author of each study
The dataset colorectal
is used to conduct exact posterior
inference of odds ratio for multiple 2X2 tables.
Chen, Y., Chu, H., Luo, S., Nie, L., and Chen, S. (2011b). Bayesian
analysis on meta-analysis of case-control studies accounting for
within-study correlation.
Statistical Methods in Medical Research,Published online on Dec 4, 2011, PMID: 22143403.
<doi:10.1177/0962280211430889>.
Ye, Z. and Parry, J. (2002) Meta-analysis of 20 case-control studies
on the N -acetyltransferase 2 acetylation status and
colorectal cancer risk.
Med Sci Monit 8, CR558-65.
https://medscimonit.com/abstract/index/idArt/13598.
library(mmeta) data(colorectal) summary(colorectal)
library(mmeta) data(colorectal) summary(colorectal)
Results from 20 cohort studies investigating the association between GDM and T2DM
The data frame contains the following columns:
number of subjects who developed T2DM among the unexposed subjects (without GDM)
number of unexposed subjects (without GDM)
number of subjects who developed T2DM among the exposed subjects (with GDM)
number of exposed subjects (with GDM)
studynames
The study names indicating the last name of the first author and the year of each study
The dataset diabetes
is used to conduct exact posterior inference
of relative risk and risk difference for multiple 2X2 tables.
Chen, Y., Luo, S., Chu, H., Su, X., and Nie, L. (2012a). An empirical
Bayes method for multivariate meta-analysis with an application in
clinical trials.
Communication in Statistics: Theory and Methods.
<https://doi.org/10.1080/03610926.2012.700379>
Bellamy, L, Casas, J.P., Hingorani, A.D., Williams, D. (2009) Type 2 diabetes mellitus after gestational
diabetes: a systematic review and meta-analysis.
The Lancet 373(9677):1773-1779
<doi:10.1097/01.aoa.0000370496.77221.05>
library(mmeta) data(diabetes) summary(diabetes)
library(mmeta) data(diabetes) summary(diabetes)
MultipleTables
.Create an object of class MultipleTables
, which is
a components list of exact posterior inference based on multiple 2x2 tables.
MultipleTables.create(data = NULL, measure = NULL, model = NULL)
MultipleTables.create(data = NULL, measure = NULL, model = NULL)
data |
a data frame that contains |
measure |
a character string specifying a measure. Options are
|
model |
a character string specifying the model. Options are
|
An object is returned, inheriting from class MultipleTables
.
Objects of this class contain the meta-data for generic functions: MultipleTables.modelFit
,
MultipleTables.summary
, and MultipleTables.plot
.
The following valuesof the object must be non-null under MultipleTables.create
.
measure |
the value of |
model |
the value of |
data |
a data matrix with rows being |
MultipleTables.modelFit
, MultipleTables.summary
, and MultipleTables.plot
.
library(mmeta) library(ggplot2) ## Analyze the dataset colorectal to conduct exact inference of the odds ratios data(colorectal) colorectal['study_name'] <- colorectal['studynames'] multiple_tables_obj <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov')
library(mmeta) library(ggplot2) ## Analyze the dataset colorectal to conduct exact inference of the odds ratios data(colorectal) colorectal['study_name'] <- colorectal['studynames'] multiple_tables_obj <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov')
This function conducts exact posterior inference based on the object created by MultipleTables.create
.
MultipleTables.modelFit( multiple_tables_object, method = "exact", verbose = FALSE, control = list() )
MultipleTables.modelFit( multiple_tables_object, method = "exact", verbose = FALSE, control = list() )
multiple_tables_object |
The object created by |
method |
a character string specifying the method. Options are |
verbose |
a logical value; if TRUE, the detailed summary messages are displayed, else FALSE (default) the messages are omitted. |
control |
a list can be specified to control the fitting process. Options are stated in details. |
control list can be specified to control the fitting process:
n_samples
: number of posterior samples; Defualt is 5000.
mcmc_initial
: initial values for (p1, p2) in MCMC; Default is c(0.5, 0.5).
upper_bound
: upper bound for the measure. Default is 100.
lower_bound
: lower bound for the measure. For RD, default is -1. For RR/OR, defualt is 0.
num_grids
: number of grids to calculate density; The defualt is 20498.
optim_method
: optimazation method. Default is “L-BFGS-B”. Please refer to ‘optim’ function.
maxit
: maximum number of iterations for iteration. Default is 1000. Please refer to ‘optim’ function.
initial_values
: initial value for optimization.
The default approach is to fit beta-bin model to generate initial values via aod
package.
There are two kinds of study design, i.e., prospective study or
clinical trial, and retrospective or case-control study. In a
prospective study or clinical trial, data
is a data frame that contains y1
, n1
, y2
, n2
,
studynames
. y1
is the number of subjects
experienced a certain event in the unexposed group. n1
is the number
of subjects in the unexposed group. y2
is the number of subjects experienced
a certain event in the exposed group. n2
is the number of
subjects in the exposed group. In this study, OR
is odds ratio
of event comparing exposed group with unexposed group. RR
is relative risk of event comparing exposed group with unexposed group. RD
is risk
difference of event comparing exposed group with unexposed group.
For case-control study, y1
is the number of subjects with
exposure in the control group. n1
is the number of
subjects in the control group. y2
is the number of
subjects with exposure in the case group. n2
is the
number of subjects in the case group. In this study, OR
is odds ratio
of event comparing case group with control group. RR
is
relative risk of event comparing case group with control group. RD
is risk
difference of event comparing case group with control group.
Empirical Bayes method is used to maximize the marginal likelihood
combining all studies to obtained the estimates of the
hyperparameters a1, b1, a2, b2, and rho. When
method="independent"
, only the estimated hyperparameters
of a1, b1, a2, and b2 are used. When model="Sarmanov"
,
rho
is subject to constraints. See Chen et al (2011) for
details.
The output cov.matrix
and hessian
are the estimated
covariance matrix and hessian matrix of the estimated
parameters in the transformed scales. The estimated parameters
are log(a1), log(b1), log(a2), log(b2), omega, where the
correlation coefficient rho is a function of a1, b1, a2, b2, and
omega. Please see details on page 7 of Chen et al (2012 b).
An object inheriting from class MultipleTables
is returned. Objects of this class including the following non-null values:
measure |
the value of |
model |
the value of |
data |
a data matrix with rows being |
method |
the value of |
study_names |
a character string indicating all the study names. |
chi2_value |
the chi-square test statistics of the likelihood ratio test. |
p_value |
the p-value of the likelihood ratio test. |
prior_mle |
a numeric vector of the estimated hyperparameters in the
following order: |
cov_matrix_log |
the estimated covariance matrix of the estimated parameters in the transformed scales. |
hessian_log |
the estimated hessian matrix of the estimated parameters in the transformed scales. |
samples |
a list of samples for the posterior and prior distributions. |
density |
a list of the density of the posterior and prior distributions. |
These values are essential for generic functions: MultipleTables.summary
and MultipleTables.plot
.
Luo, S., Chen, Y., Su, X., Chu, H., (2014). mmeta: An R Package for
Multivariate Meta-Analysis.
Journal of Statistical Software, 56(11), 1-26.
<https://dukespace.lib.duke.edu/dspace/bitstream/handle/10161/15522/2014Luo_Chen_Su_Chu_JSS_mmeta.pdf?sequence=1>
Chen, Y., Luo, S., (2011a). A Few Remarks on "Statistical Distribution of the Difference of
Two Proportions' by Nadarajah and Kotz, Statistics in Medicine 2007; 26(18):3518-3523".
Statistics in Medicine, 30(15), 1913-1915.
<doi:10.1002/sim.4248>
Chen, Y., Chu, H., Luo, S., Nie, L., and Chen, S. (2014a). Bayesian
analysis on meta-analysis of case-control studies accounting for
within-study correlation.
Statistical Methods in Medical Research, 4.6 (2015): 836-855.
<https://doi.org/10.1177/0962280211430889>.
Chen, Y., Luo, S., Chu, H., Su, X., and Nie, L. (2014b). An empirical
Bayes method for multivariate meta-analysis with an application in
clinical trials.
Communication in Statistics: Theory and Methods, 43.16 (2014): 3536-3551.
<https://doi.org/10.1080/03610926.2012.700379>.
Chen, Y., Luo, S., Chu, H., Wei, P. (2013). Bayesian inference on risk
differences: an application to multivariate meta-analysis of adverse
events in clinical trials.
Statistics in Biopharmaceutical Research, 5(2), 142-155.
<https://doi.org/10.1080/19466315.2013.791483>.
MultipleTables.create
, MultipleTables.summary
, and MultipleTables.plot
.
library(mmeta) library(ggplot2) ## Analyze the dataset colorectal to conduct exact inference of the odds ratios data(colorectal) colorectal['study_name'] <- colorectal['studynames'] # ########################## If exact method is used ############################ ## Create object multiple_tables_obj_exact multiple_tables_obj_exact <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov') ## Model fit default multiple_tables_obj_exact <- MultipleTables.modelFit( multiple_tables_obj_exact, method = 'exact') ## Options for Control; If set number of posterior samples is 5000 multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact', control = list(n_samples = 3000)) ## If set intial values correspoinding to c(a1, b1, a2, b2, rho) as c(1,1,1,1,0): multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact', control = list(initial_values = c(1,1,1,1,0))) ## If maximum number of iterations for iteration is 100 multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact', control = list(maxit = 100)) ## If maximum number of iterations for iteration is 100 and number of posterior samples as 3000 multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact', control = list(maxit = 100, nsamples = 3000)) # ########################## If sampling method is used ############################ multiple_tables_obj_sampling <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov') multiple_tables_obj_sampling <- MultipleTables.modelFit( multiple_tables_obj_sampling, method = 'sampling') ## The options of \code{control} list specifying the fitting process are similar ## to the codes shown above.
library(mmeta) library(ggplot2) ## Analyze the dataset colorectal to conduct exact inference of the odds ratios data(colorectal) colorectal['study_name'] <- colorectal['studynames'] # ########################## If exact method is used ############################ ## Create object multiple_tables_obj_exact multiple_tables_obj_exact <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov') ## Model fit default multiple_tables_obj_exact <- MultipleTables.modelFit( multiple_tables_obj_exact, method = 'exact') ## Options for Control; If set number of posterior samples is 5000 multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact', control = list(n_samples = 3000)) ## If set intial values correspoinding to c(a1, b1, a2, b2, rho) as c(1,1,1,1,0): multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact', control = list(initial_values = c(1,1,1,1,0))) ## If maximum number of iterations for iteration is 100 multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact', control = list(maxit = 100)) ## If maximum number of iterations for iteration is 100 and number of posterior samples as 3000 multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact', control = list(maxit = 100, nsamples = 3000)) # ########################## If sampling method is used ############################ multiple_tables_obj_sampling <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov') multiple_tables_obj_sampling <- MultipleTables.modelFit( multiple_tables_obj_sampling, method = 'sampling') ## The options of \code{control} list specifying the fitting process are similar ## to the codes shown above.
Multipletables
objectsProduces a variety of plots for multiple tables analysis
MultipleTables.plot( multiple_tables_object, plot_type = "forest", layout_type = "overlay", selected_study_names = NULL, xlim = NULL, add_vertical = NULL, show_CI = TRUE, by = "line_type" )
MultipleTables.plot( multiple_tables_object, plot_type = "forest", layout_type = "overlay", selected_study_names = NULL, xlim = NULL, add_vertical = NULL, show_CI = TRUE, by = "line_type" )
multiple_tables_object |
The object inheriting from class |
plot_type |
a character string specifying the kind of plots to
produce. Options are |
layout_type |
a character string specifying the type of the density plots (i.e., when |
selected_study_names |
a numeric value or vector specifying which studies to
be plotted. By default (when |
xlim |
a numeric value specifying the lower and upper limits of the x-axis. Default is NULL.
For forest plots, if the lower bound of any measure is smaller than |
add_vertical |
a numeric value specifying the x-value for a vertical
reference line at |
show_CI |
a logical value; If TRUE (default) the forest plot will show the lower & upper bounds of CIs,
else the the lower & upper bounds of CIs will be omitted. This argument is always NULL when |
by |
a character string specifying the way to distinguish different plots. Options are |
If plot_type=‘density’
and layout_type='sidebyside'
, the posterior distributions of all
study-specific measure are displayed side by side in 4-panel plots with study names.
If plot_type=‘density’
and layout_type='overlap'
, the posterior distributions of all
study-specific measure are displayed in one graph. To clarity, it
is advisable to specify a few studies by selected_study_names
argument.
If type='forest')
and layout_type='NULL'
, a forest plot of all study-specific and
overall measure with 95% credible/confidence intervals are plotted.
A ggplot2 object is returned.
MultipleTables.create
, MultipleTables.modelFit
, and MultipleTables.summary
.
library(mmeta) library(ggplot2) ## Analyze the dataset colorectal to conduct exact inference of the odds ratios data(colorectal) colorectal['study_name'] <- colorectal['studynames'] ## If exact method is used, the codes for sampling method are similar. ## Create object multiple_tables_obj_exact multiple_tables_obj_exact <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov') ## Model fit default multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact') ## Summary of the fitting process (default) multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact) ## Density plot, overlay ## Note: There are no enough types of line, if we have too many densities! MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay') ## Choose Set by = ‘color’ MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay',by = 'color') ## Set by = ‘color’ and specify xlim as 0 to 5. MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay', by = 'color', xlim = c(0,5)) ## Set by = ‘color’ and specify xlim as 0 to 5 and add vertical line at OR = 1 MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay', by = 'color',xlim = c(0,5), add_vertical = 1) ## If select three studies MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay',selected_study_names = c('Bell','Chen','Oda'), xlim = c(0,5)) ## We can add external layouts for the return ggplot2. xlab as Odds ratio ggplot2_obj <- MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay', by = 'color',xlim = c(0,5)) ggplot2_obj + xlab('Odds Ratio') + ggtitle('OR ration for XX cancer') ## density plot, plot side by side MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'side_by_side') ## Forest plot (default) MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'forest') ## forest plot: not show the CIs MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'forest', add_vertical = 1, show_CI = FALSE)
library(mmeta) library(ggplot2) ## Analyze the dataset colorectal to conduct exact inference of the odds ratios data(colorectal) colorectal['study_name'] <- colorectal['studynames'] ## If exact method is used, the codes for sampling method are similar. ## Create object multiple_tables_obj_exact multiple_tables_obj_exact <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov') ## Model fit default multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact') ## Summary of the fitting process (default) multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact) ## Density plot, overlay ## Note: There are no enough types of line, if we have too many densities! MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay') ## Choose Set by = ‘color’ MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay',by = 'color') ## Set by = ‘color’ and specify xlim as 0 to 5. MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay', by = 'color', xlim = c(0,5)) ## Set by = ‘color’ and specify xlim as 0 to 5 and add vertical line at OR = 1 MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay', by = 'color',xlim = c(0,5), add_vertical = 1) ## If select three studies MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay',selected_study_names = c('Bell','Chen','Oda'), xlim = c(0,5)) ## We can add external layouts for the return ggplot2. xlab as Odds ratio ggplot2_obj <- MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'overlay', by = 'color',xlim = c(0,5)) ggplot2_obj + xlab('Odds Ratio') + ggtitle('OR ration for XX cancer') ## density plot, plot side by side MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'density', layout_type = 'side_by_side') ## Forest plot (default) MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'forest') ## forest plot: not show the CIs MultipleTables.plot(multiple_tables_obj_exact, plot_type = 'forest', add_vertical = 1, show_CI = FALSE)
MultipleTables
.Summarize the model of the class MultipleTables
fitted by MultipleTables.modelFit
.
MultipleTables.summary( multiple_tables_object, alpha = 0.05, verbose = TRUE, digit = 3, control = list() )
MultipleTables.summary( multiple_tables_object, alpha = 0.05, verbose = TRUE, digit = 3, control = list() )
multiple_tables_object |
The object created by |
alpha |
a numeric value specifying the significant level. Default value sets to 0.05. |
verbose |
a logical value; if TRUE (default), the detailed summary messages will display. |
digit |
an integer value specifying how many decimal places to keep. Default value sets to 3. |
control |
a list can be specified to control the fitting process. |
A list with the following components: model, posterior mean & equal tail confidence interval of overall measure, estimated hyperparameters, the chi-square test statistics & the p-value of the likelihood ratio test, posterior means & the lower/upper bounds of the equal tail confidence intervals of study-specific measure.
MultipleTables.create
, MultipleTables.modelFit
, and MultipleTables.plot
.
library(mmeta) library(ggplot2) ## Analyze the dataset colorectal to conduct exact inference of the odds ratios data(colorectal) colorectal['study_name'] <- colorectal['studynames'] ## If exact method is used, the codes for sampling method are similar. ## Create object multiple_tables_obj_exact multiple_tables_obj_exact <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov') ## Model fit default multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact') ## Summary of the fitting process (default) multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact) ## Structure of SingleTable object str(multiple_tables_obj_exact) ## If set alpha level to 0.1 multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact, alpha = 0.1) ## If set digit to 4 multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact, alpha = 0.05, digit = 4) ## If decided not to print out multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact, alpha = 0.05, digit = 4,verbose = FALSE)
library(mmeta) library(ggplot2) ## Analyze the dataset colorectal to conduct exact inference of the odds ratios data(colorectal) colorectal['study_name'] <- colorectal['studynames'] ## If exact method is used, the codes for sampling method are similar. ## Create object multiple_tables_obj_exact multiple_tables_obj_exact <- MultipleTables.create(data=colorectal, measure='OR', model= 'Sarmanov') ## Model fit default multiple_tables_obj_exact <- MultipleTables.modelFit(multiple_tables_obj_exact, method = 'exact') ## Summary of the fitting process (default) multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact) ## Structure of SingleTable object str(multiple_tables_obj_exact) ## If set alpha level to 0.1 multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact, alpha = 0.1) ## If set digit to 4 multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact, alpha = 0.05, digit = 4) ## If decided not to print out multiple_tables_obj_exact <- MultipleTables.summary(multiple_tables_obj_exact, alpha = 0.05, digit = 4,verbose = FALSE)
singletable
.Create an object of class SingleTable
, which is
a components list of exact posterior inference based on single 2x2 table.
SingleTable.create(a1,b1,a2,b2,rho,y1,n1,y2,n2,model,measure)
SingleTable.create(a1,b1,a2,b2,rho,y1,n1,y2,n2,model,measure)
a1 |
a numeric value specifying the first hyperparameter of the beta prior for group 1. |
b1 |
a numeric value specifying the second hyperparameter of the beta prior for group 1. |
a2 |
a numeric value specifying the first hyperparameter of the beta prior for group 2. |
b2 |
a numeric value specifying the second hyperparameter of the beta prior for group 2. |
rho |
a numeric value specifying correlation coefficient for Sarmanov bivariate prior distribution. |
y1 |
an integer indicating the number of events in group 1. |
n1 |
an integer indicating the total number of subjects in group 1. |
y2 |
an integer indicating the number of events in group 2. |
n2 |
an integer indicating the total number of subjects in group 2. |
model |
a character string specifying the model. Options are |
measure |
a character string specifying a measure. Options are
|
There are two kinds of study design, i.e., prospective study or
clinical trial, and retrospective or case-control study.
In a prospective study or clinical trial, data
is a data
frame that contains y1
, n1
, y2
, n2
.
y1
is the number of subjects
experienced a certain event in the unexposed group. n1
is the number
of subjects in the unexposed group. y2
is the number of subjects experienced
a certain event in the exposed group. n2
is the number of
subjects in the exposed group. In this study, OR
is odds ratio
of event comparing exposed group with unexposed group. RR
is relative risk of event comparing exposed group with unexposed group. RD
is risk
difference of event comparing exposed group with unexposed group.
For case-control study, y1
is the number of subjects with
exposure in the control group. n1
is the number of
subjects in the control group. y2
is the number of
subjects with exposure in the case group. n2
is the
number of subjects in the case group. In this study, OR
is odds ratio
of event comparing case group with control group. RR
is
relative risk of event comparing case group with control group. RD
is risk
difference of event comparing case group with control group.
When model='Sarmanov
', rho
is subject to constraints. See Chen et al(2011) for details.
An object is returned, inheriting from class singletable
.
The Objects of this class contain the meta-data for generic functions: SingleTable.modelFit
,
SingleTable.summary
, and SingleTable.plot
. The following values
of the object must be non-null under SingleTable.create
:
measure |
the value of |
model |
the value of |
data |
a numeric vector of input data with components: |
parameter |
a numeric vector of the hyperparameters: |
Chen, Y., Luo, S., (2011a). A Few Remarks on "Statistical Distribution of the Difference of
Two Proportions' by Nadarajah and Kotz, Statistics in Medicine 2007; 26(18):3518-3523".
Statistics in Medicine, 30(15), 1913-1915.
<doi:10.1002/sim.4248>
SingleTable.modelFit
, SingleTable.summary
, SingleTable.plot
.
## Specify data (y1, n1, y2, n2), parameters (a1, b1, a2, b2, rho), model (Sarmanov/Independent), ## and Specify measure(OR/RR/RD) ## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5. ## Create object \code{single_table_obj} library(mmeta) library(ggplot2) single_table_obj <- SingleTable.create(a1=0.5,b1=0.5, a2=0.5,b2=0.5,rho=0.5, y1=40, n1=96, y2=49, n2=109,model="Sarmanov",measure="OR")
## Specify data (y1, n1, y2, n2), parameters (a1, b1, a2, b2, rho), model (Sarmanov/Independent), ## and Specify measure(OR/RR/RD) ## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5. ## Create object \code{single_table_obj} library(mmeta) library(ggplot2) single_table_obj <- SingleTable.create(a1=0.5,b1=0.5, a2=0.5,b2=0.5,rho=0.5, y1=40, n1=96, y2=49, n2=109,model="Sarmanov",measure="OR")
This function conducts exact posterior inference based on the object created by SingleTable.create
.
SingleTable.modelFit( single_table_Obj, method = "exact", verbose = TRUE, control = list() )
SingleTable.modelFit( single_table_Obj, method = "exact", verbose = TRUE, control = list() )
single_table_Obj |
The object created by |
method |
a character string specifying the method. Options are |
verbose |
a logical value; if TRUE(default), the detailed summary messages are displayed, else the messages are omitted. |
control |
a list can be specified to control the fitting process. Options are stated in details. |
control list can be specified to control the fitting process:
n_samples
: number of posterior samples; Defualt is 5000.
mcmc_initial
: initial values for (p1, p2) in MCMC; Default is c(0.5, 0.5).
upper_bound
: upper bound for the measure. Default is 100.
lower_bound
: lower bound for the measure. For RD, default is -1. For RR/OR, defualt is 0.
num_grids
: number of grids to calculate density; The defualt is 20498.
An object of singletable
class is returned including the following non-null values:
measure |
the value of |
model |
the value of |
data |
a numeric vector of input data with components: |
parameter |
a numeric vector of the hyperparameters: |
method |
the value of |
sample |
a list of samples for the posterior and prior distributions. |
density |
a list of the density of the posterior and prior distributions. |
SingleTable.summary
, SingleTable.plot
.
## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5. library(mmeta) library(ggplot2) # ########################## If sampling method is used ############################ ## Create object \code{single_table_obj_samling} single_table_obj_samling <- SingleTable.create(a1=0.5,b1=0.5, a2=0.5,b2=0.5,rho=0.5, y1=40, n1=96, y2=49, n2=109,model="Sarmanov",measure="OR") ## model fit single_table_obj_samling <- SingleTable.modelFit(single_table_obj_samling, method = 'sampling') ## Control list option examples ## set number of posterior samples as 3000 (default is 5000) single_table_obj_samling <- SingleTable.modelFit(single_table_obj_samling, method = 'sampling', control = list(n_sample = 3000)) ## set initial values for MCMC is c(0.2, 0,4) (default is c(0.5,0.5)) single_table_obj_samling <- SingleTable.modelFit(single_table_obj_samling, method = 'sampling', control = list(mcmc_initial = c(0.2,0.4))) ## set upper bound for the measure is 20( default is 100) single_table_obj_samling <- SingleTable.modelFit(single_table_obj_samling, method = 'sampling', control = list(upper_bound = 20)) # ########################### If exact method is used ############################## ## Create object \code{single_table_obj_exact} single_table_obj_exact <- SingleTable.create(a1=0.5, b1=0.5, a2=0.5, b2=0.5, rho=0.5, y1=40, n1=96, y2=49, n2=109, model="Sarmanov",measure="OR") ## model fit single_table_obj_exact <- SingleTable.modelFit(single_table_obj_exact, method = 'exact') ## The options of \code{control} list specifying the fitting process are similar ## to the codes shown above.
## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5. library(mmeta) library(ggplot2) # ########################## If sampling method is used ############################ ## Create object \code{single_table_obj_samling} single_table_obj_samling <- SingleTable.create(a1=0.5,b1=0.5, a2=0.5,b2=0.5,rho=0.5, y1=40, n1=96, y2=49, n2=109,model="Sarmanov",measure="OR") ## model fit single_table_obj_samling <- SingleTable.modelFit(single_table_obj_samling, method = 'sampling') ## Control list option examples ## set number of posterior samples as 3000 (default is 5000) single_table_obj_samling <- SingleTable.modelFit(single_table_obj_samling, method = 'sampling', control = list(n_sample = 3000)) ## set initial values for MCMC is c(0.2, 0,4) (default is c(0.5,0.5)) single_table_obj_samling <- SingleTable.modelFit(single_table_obj_samling, method = 'sampling', control = list(mcmc_initial = c(0.2,0.4))) ## set upper bound for the measure is 20( default is 100) single_table_obj_samling <- SingleTable.modelFit(single_table_obj_samling, method = 'sampling', control = list(upper_bound = 20)) # ########################### If exact method is used ############################## ## Create object \code{single_table_obj_exact} single_table_obj_exact <- SingleTable.create(a1=0.5, b1=0.5, a2=0.5, b2=0.5, rho=0.5, y1=40, n1=96, y2=49, n2=109, model="Sarmanov",measure="OR") ## model fit single_table_obj_exact <- SingleTable.modelFit(single_table_obj_exact, method = 'exact') ## The options of \code{control} list specifying the fitting process are similar ## to the codes shown above.
singletable
objects.Produces various plots for single table analysis.
SingleTable.plot( single_table_Obj, type = "side_by_side", xlim = NULL, add_vertical = NULL, by = "line_type" )
SingleTable.plot( single_table_Obj, type = "side_by_side", xlim = NULL, add_vertical = NULL, by = "line_type" )
single_table_Obj |
The object inheriting from class |
type |
a character string specifying the type of plots to
produce. Options are |
xlim |
a numeric value specifying the lower and upper limits of the x-axis. Default is NULL. |
add_vertical |
a numeric value specifying the x-value for a vertical
reference line at |
by |
a character string specifying the way to distinguish different plots. Options are |
If type="sidebyside"
, the posterior distribution of measure
and the prior distribution are drawn side by side in two plots. If
type="overlay"
, the posterior distribution of measure and
the prior distribution are overlaid in one plot.
A ggplot2 object is returned.
## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5. library(mmeta) library(ggplot2) ## If exact method is used, the codes for sampling method are similar. ## Create object \code{single_table_obj_exact} single_table_obj_exact <- SingleTable.create(a1=0.5,b1=0.5, a2=0.5,b2=0.5,rho=0.5, y1=40, n1=96, y2=49, n2=109,model="Sarmanov",measure="OR") ## model fit single_table_obj_exact <- SingleTable.modelFit(single_table_obj_exact, method = 'exact') ## Summary of the fitting process (default) single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, alpha = 0.05) ## Plot the densities side-by-side SingleTable.plot(single_table_obj_exact, type = 'side_by_side') ## set xlim between 0 to 4 and add vertical line at x = 1 SingleTable.plot(single_table_obj_exact, type = 'side_by_side', xlim = c(0,4), add_vertical = 1) ## override xlab and add title via ggplot2 plot_obj <- SingleTable.plot(single_table_obj_exact, type = 'side_by_side', xlim = c(0,4), add_vertical = 1) plot_obj + xlab('Odds ratio') + ggtitle("Plot of density function") ## Overlay plot the density SingleTable.plot(single_table_obj_exact, type = 'overlay') ## Plot by color instead of line type SingleTable.plot(single_table_obj_exact, type = 'overlay',by = 'color')
## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5. library(mmeta) library(ggplot2) ## If exact method is used, the codes for sampling method are similar. ## Create object \code{single_table_obj_exact} single_table_obj_exact <- SingleTable.create(a1=0.5,b1=0.5, a2=0.5,b2=0.5,rho=0.5, y1=40, n1=96, y2=49, n2=109,model="Sarmanov",measure="OR") ## model fit single_table_obj_exact <- SingleTable.modelFit(single_table_obj_exact, method = 'exact') ## Summary of the fitting process (default) single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, alpha = 0.05) ## Plot the densities side-by-side SingleTable.plot(single_table_obj_exact, type = 'side_by_side') ## set xlim between 0 to 4 and add vertical line at x = 1 SingleTable.plot(single_table_obj_exact, type = 'side_by_side', xlim = c(0,4), add_vertical = 1) ## override xlab and add title via ggplot2 plot_obj <- SingleTable.plot(single_table_obj_exact, type = 'side_by_side', xlim = c(0,4), add_vertical = 1) plot_obj + xlab('Odds ratio') + ggtitle("Plot of density function") ## Overlay plot the density SingleTable.plot(single_table_obj_exact, type = 'overlay') ## Plot by color instead of line type SingleTable.plot(single_table_obj_exact, type = 'overlay',by = 'color')
singletable
.Summarize model of the single table analysis fitted by SingleTable.modelFit
.
SingleTable.summary( single_table_Obj, alpha = 0.05, verbose = TRUE, digit = 3, control = list() )
SingleTable.summary( single_table_Obj, alpha = 0.05, verbose = TRUE, digit = 3, control = list() )
single_table_Obj |
The object created by |
alpha |
a numeric value specifying the significant level. Default value sets to 0.05. |
verbose |
a logical value; if TRUE(default), the detailed summary messages will display. |
digit |
an integer value specifying how many decimal places to keep. Default value sets to 3. |
control |
a list can be specified to control the fitting process. |
A list with the following components: measure, model, posterior mean, posterior median, equal tail CI, and HDR CI.
## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5. library(mmeta) library(ggplot2) ## If exact method is used, the codes for sampling method are similar. ## Create object \code{single_table_obj_exact} single_table_obj_exact <- SingleTable.create(a1=0.5,b1=0.5, a2=0.5,b2=0.5,rho=0.5, y1=40, n1=96, y2=49, n2=109,model="Sarmanov",measure="OR") ## model fit single_table_obj_exact <- SingleTable.modelFit(single_table_obj_exact, method = 'exact') ## Summary of the fitting process (default) single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, alpha = 0.05) ## Structure of SingleTable object str(single_table_obj_exact) ## If set alpha level to 0.1 single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, alpha = 0.1) ## If set digit to 2 single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, digit = 2) ## If decided not to print out single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, verbose = FALSE)
## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5. library(mmeta) library(ggplot2) ## If exact method is used, the codes for sampling method are similar. ## Create object \code{single_table_obj_exact} single_table_obj_exact <- SingleTable.create(a1=0.5,b1=0.5, a2=0.5,b2=0.5,rho=0.5, y1=40, n1=96, y2=49, n2=109,model="Sarmanov",measure="OR") ## model fit single_table_obj_exact <- SingleTable.modelFit(single_table_obj_exact, method = 'exact') ## Summary of the fitting process (default) single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, alpha = 0.05) ## Structure of SingleTable object str(single_table_obj_exact) ## If set alpha level to 0.1 single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, alpha = 0.1) ## If set digit to 2 single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, digit = 2) ## If decided not to print out single_table_obj_exact <- SingleTable.summary(single_table_obj_exact, verbose = FALSE)
Results from 16 clinical trials investigating the association of withdrawal from study due to adverse events and tricyclic treatment
The data frame contains the following columns:
number of subjects withdrew due to adverse events in the placebo group
number of subjects in the placebo group
number of subjects withdrew due to adverse events in the tricyclic treatment group
number of subjects in the tricyclic treatment group
The study names indicating the last name of the first author and the year of each study
No return value, called for side effects
The dataset withdrawal
is used to conduct exact posterior
inference of relative risks and risk difference for multiple 2X2 tables.
Jackson, J. L., Shimeall, W., Sessums, L., DeZee, K. J., Becher, D.,
Diemer, M., Berbano, E., OMalley, P. G. (2010). Tricyclic
antidepressants and headaches: systematic review and meta-analysis.
BMJ, 341, C5222-c5234.
<https://doi.org/10.1136/bmj.c5222>. /cr
library(mmeta) data(withdrawal) summary(withdrawal)
library(mmeta) data(withdrawal) summary(withdrawal)