Package 'mmeta'

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

Help Index


Studies on the Association of N-acetyltransferase 2 (NAT2) Acetylation Status and Colorectal Cancer

Description

Results from 20 case-control studies investigating the association between rapid NAT2 acetylator status and colorectal cancer

Format

The data frame contains the following columns:

y1

number of subjects with rapid NAT2 acetylator status in the control group

n1

number of subjects in the control group (without colorectal cancer)

y2

number of subjects with rapid NAT2 acetylator status in the case group

n2

number of subjects in the case group (with colorectal cancer)

studynames

The study names indicating the last name of the first author of each study

Note

The dataset colorectal is used to conduct exact posterior inference of odds ratio for multiple 2X2 tables.

References

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.

Examples

library(mmeta)
data(colorectal)
summary(colorectal)

Studies on the Association of Gestational Diabetes Mellitus (GDM) and Type 2 Diabetes Mellitus (T2DM)

Description

Results from 20 cohort studies investigating the association between GDM and T2DM

Format

The data frame contains the following columns:

y1

number of subjects who developed T2DM among the unexposed subjects (without GDM)

n1

number of unexposed subjects (without GDM)

y2

number of subjects who developed T2DM among the exposed subjects (with GDM)

n2

number of exposed subjects (with GDM)

studynames

The study names indicating the last name of the first author and the year of each study

Note

The dataset diabetes is used to conduct exact posterior inference of relative risk and risk difference for multiple 2X2 tables.

References

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>

Examples

library(mmeta)
data(diabetes)
summary(diabetes)

Create an object of class MultipleTables.

Description

Create an object of class MultipleTables, which is a components list of exact posterior inference based on multiple 2x2 tables.

Usage

MultipleTables.create(data = NULL, measure = NULL, model = NULL)

Arguments

data

a data frame that contains y1, n1, y2, n2 of multiple tables.

measure

a character string specifying a measure. Options are OR, RR, and RD. OR is odds ratio, RR is relative risk, and RD is risk difference.

model

a character string specifying the model. Options are Independent and Sarmanov. Independent is independent beta-binomial model. Sarmanovis Sarmanov beta-binomial model.

Value

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 measure argument.

model

the value of model argument.

data

a data matrix with rows being y1, n1, y2, and n2.

See Also

MultipleTables.modelFit, MultipleTables.summary, and MultipleTables.plot.

Examples

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')

Exact posterior inference based on multiple 2x2 tables.

Description

This function conducts exact posterior inference based on the object created by MultipleTables.create.

Usage

MultipleTables.modelFit(
  multiple_tables_object,
  method = "exact",
  verbose = FALSE,
  control = list()
)

Arguments

multiple_tables_object

The object created by MultipleTables.create.

method

a character string specifying the method. Options are exact and sampling. exact (default) is a method based on Monte Carlo sampling. exact is exact method.

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.

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).

Value

An object inheriting from class MultipleTables is returned. Objects of this class including the following non-null values:

measure

the value of measure argument.

model

the value of model argument.

data

a data matrix with rows being y1, n1, y2, and n2.

method

the value of method argument.

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: a1, b1, a2, b2, rho.

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.

References

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>.

See Also

MultipleTables.create, MultipleTables.summary, and MultipleTables.plot.

Examples

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.

Plot Method for Multipletables objects

Description

Produces a variety of plots for multiple tables analysis

Usage

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"
)

Arguments

multiple_tables_object

The object inheriting from class Multipletables.

plot_type

a character string specifying the kind of plots to produce. Options are density and forest (default). See details

layout_type

a character string specifying the type of the density plots (i.e., when plot_type=‘density’). Options are sidebyside and overlay (default). This argument is NULL when plot_type=‘forest’

selected_study_names

a numeric value or vector specifying which studies to be plotted. By default (when NULL), all of the studies will be plotted.

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 xlim[1] or the upper bound of any measure is larger than xlim[2], arrows will be used at the limits to denote the bounds exceed the specified ranges.

add_vertical

a numeric value specifying the x-value for a vertical reference line at x=addline. Default is NULL.

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 plot_type=‘density’.

by

a character string specifying the way to distinguish different plots. Options are line_type (default) and color.

Details

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.

Value

A ggplot2 object is returned.

See Also

MultipleTables.create, MultipleTables.modelFit, and MultipleTables.summary.

Examples

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)

Summarize the object of class MultipleTables.

Description

Summarize the model of the class MultipleTables fitted by MultipleTables.modelFit.

Usage

MultipleTables.summary(
  multiple_tables_object,
  alpha = 0.05,
  verbose = TRUE,
  digit = 3,
  control = list()
)

Arguments

multiple_tables_object

The object created by MultipleTables.create and fitted by MultipleTables.modelFit.

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.

Value

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.

See Also

MultipleTables.create, MultipleTables.modelFit, and MultipleTables.plot.

Examples

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)

Create an object of class singletable.

Description

Create an object of class SingleTable, which is a components list of exact posterior inference based on single 2x2 table.

Usage

SingleTable.create(a1,b1,a2,b2,rho,y1,n1,y2,n2,model,measure)

Arguments

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 Independent and Sarmanov. Independent is independent beta-binomial model. Sarmanovis Sarmanov beta-binomial model.

measure

a character string specifying a measure. Options are OR, RR, and RD. OR is odds ratio, RR is relative risk, and RD is risk difference.

Details

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.

Value

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 measure argument.

model

the value of model argument.

data

a numeric vector of input data with components: y1, n1, y2, n2

parameter

a numeric vector of the hyperparameters: a1, b1, a2, b2, and rho.

References

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>

See Also

SingleTable.modelFit, SingleTable.summary, SingleTable.plot.

Examples

## 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")

Exact posterior inference based on a single 2x2 table

Description

This function conducts exact posterior inference based on the object created by SingleTable.create.

Usage

SingleTable.modelFit(
  single_table_Obj,
  method = "exact",
  verbose = TRUE,
  control = list()
)

Arguments

single_table_Obj

The object created by SingleTable.create.

method

a character string specifying the method. Options are exact and sampling. exact (default) is a method based on Monte Carlo sampling. exact is exact method.

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.

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.

Value

An object of singletable class is returned including the following non-null values:

measure

the value of measure argument.

model

the value of model argument.

data

a numeric vector of input data with components: y1, n1, y2, n2.

parameter

a numeric vector of the hyperparameters: a1, b1, a2, b2, and rho.

method

the value of method argument.

sample

a list of samples for the posterior and prior distributions.

density

a list of the density of the posterior and prior distributions.

See Also

SingleTable.summary, SingleTable.plot.

Examples

## 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.

Plot Method for singletable objects.

Description

Produces various plots for single table analysis.

Usage

SingleTable.plot(
  single_table_Obj,
  type = "side_by_side",
  xlim = NULL,
  add_vertical = NULL,
  by = "line_type"
)

Arguments

single_table_Obj

The object inheriting from class singletable.

type

a character string specifying the type of plots to produce. Options are sidebyside(default) and overlay.

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 x=addline. Default is NULL.

by

a character string specifying the way to distinguish different plots. Options are line_type(default) and color.

Details

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.

Value

A ggplot2 object is returned.

Examples

## 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')

Summarize the object of class singletable.

Description

Summarize model of the single table analysis fitted by SingleTable.modelFit.

Usage

SingleTable.summary(
  single_table_Obj,
  alpha = 0.05,
  verbose = TRUE,
  digit = 3,
  control = list()
)

Arguments

single_table_Obj

The object created by SingleTable.create and fitted by SingleTable.modelFit.

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.

Value

A list with the following components: measure, model, posterior mean, posterior median, equal tail CI, and HDR CI.

Examples

## 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)

Studies on the association of withdrawal from study due to adverse events and tricyclic treatment

Description

Results from 16 clinical trials investigating the association of withdrawal from study due to adverse events and tricyclic treatment

Format

The data frame contains the following columns:

y1

number of subjects withdrew due to adverse events in the placebo group

n1

number of subjects in the placebo group

y2

number of subjects withdrew due to adverse events in the tricyclic treatment group

n2

number of subjects in the tricyclic treatment group

studynames

The study names indicating the last name of the first author and the year of each study

Value

No return value, called for side effects

Note

The dataset withdrawal is used to conduct exact posterior inference of relative risks and risk difference for multiple 2X2 tables.

References

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

Examples

library(mmeta)
data(withdrawal)
summary(withdrawal)