## Assume we have a 2x2 table:{{40,56},{49,60}} and set prior parameters as a1=b1=a2=b2=rho=0.5.
# \donttest{
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.
# }
Run the code above in your browser using DataLab