Package 'BayesSenMC'

Title: Different Models of Posterior Distributions of Adjusted Odds Ratio
Description: Generates different posterior distributions of adjusted odds ratio under different priors of sensitivity and specificity, and plots the models for comparison. It also provides estimations for the specifications of the models using diagnostics of exposure status with a non-linear mixed effects model. It implements the methods that are first proposed in <doi:10.1016/j.annepidem.2006.04.001> and <doi:10.1177/0272989X09353452>.
Authors: Jinhui Yang, Haitao Chu, and Lifeng Lin
Maintainer: Jinhui Yang <[email protected]>
License: GPL-2
Version: 0.1.3
Built: 2025-02-23 05:03:09 UTC
Source: https://github.com/formidify/bayessenmc

Help Index


The 'BayesSenMC' package.

Description

This package generates different posterior distributions of adjusted odds ratio under different priors of sensitivity and specificity, and plots the models for comparison. It also provides estimations for the specifications of the models using diagnostics of exposure status with a non-linear mixed effects model.

References

Stan Development Team (2020). RStan: the R interface to Stan. R package version 2.21.2. https://mc-stan.org


Meta-analysis data on Bipolar Disorder diagnosis accuracy

Description

Records the true positive, true negative, false positive and false negative of each diagnosis accuracy study. Also includes the type of screening instruments (Bipolar Spectrum diagnostic scale / HCL-21 / Mood disorder questionnaire), the cut-off value for diagnostics, and the percentage of bipolar cases that were of bipolar disorder type II or not specified.

Usage

data(bd_meta)

Format

An object of class tbl_df (inherits from tbl, data.frame) with 55 rows and 8 columns.

Source

https://www.sciencedirect.com/science/article/pii/S0165032714006466

References

Carvalho et al. (2015) "Screening for bipolar spectrum disorders: A comprehensive meta-analysis of accuracy studies". Journal of Affective Disorders 172: 337 - 346. (ScienceDirect)

Examples

data(bd_meta)

Model with constant nondifferential misclassification

Description

Generate a stanfit object corresponding to a posterior distribution of corrected odds ratio given nondifferential misclassification with Se and Sp (i.e., both are constant and at least one of Se or Sp is lower than 1).

Usage

correctedOR(
  a,
  N1,
  c,
  N0,
  prior_list = NULL,
  se = NULL,
  sp = NULL,
  logitpi0_prior = c(0, 10),
  lor_prior = c(0, 2),
  chains = 2,
  traceplot = FALSE,
  inc_warmup = FALSE,
  window = NULL,
  refresh = 0,
  seed = NA,
  ...
)

Arguments

a

number of exposed subjects in the case group.

N1

number of total subjects in the case group.

c

number of exposed subjects in the control group.

N0

number of total subjects in the control group.

prior_list

list of priors. Can be replaced by the function call to paramEst, or a list of prior parameters (se, sp). If prior_list is specified, the values for the function parameters se and sp will be disregarded.

se

sensitivity. Do not have to specify this if prior_list is given - this will be disregarded.

sp

specificity. Do not have to specify this if prior_list is given - this will be disregarded.

logitpi0_prior

mean and sd of the prior normal distribution of logit(pi0). Default to c(0,10).

lor_prior

mean and sd of the prior normal distribution of corrected log odds ratio. Default to c(0,2).

chains

number of Markov Chains. Default to 2.

traceplot

Logical, defaulting to FALSE. If TRUE it will draw the traceplot corresponding to one or more Markov chains.

inc_warmup

Only evaluated when traceplot = TRUE. TRUE or FALSE, indicating whether or not to include the warmup sample in the traceplot; defaults to FALSE.

window

Only evaluated when traceplot = TRUE. A vector of length 2. Iterations between window[1] and window[2] will be shown in the plot. The default shows all iterations if inc_warmup is TRUE and all iterations from the sampling period only if inc_warmup is FALSE. If inc_warmup is FALSE the iterations specified in window do not include iterations from the warmup period. The default number of iterations is 2000 unless otherwise specified in the optional iter argument.

refresh

an integer value used to control how often the progress of sampling is reported. By default, the progress indicator is turned off, thus refresh <= 0. If on, refresh = max(iter/10, 1) is generally recommended.

seed

the seed for random number generation. See stan for more details.

...

optional parameters passed to stan.

Value

It returns a stanfit object of this model, which inherits stanfit class methods. See rstan for more details.

Examples

# Case-control study data of Bipolar Disorder with rheumatoid arthritis (Farhi et al. 2016)
# Data from \url{https://www.sciencedirect.com/science/article/pii/S0165032715303864#bib13}\

mod <- nlmeNDiff(bd_meta, lower = 0) # see \code{nlmeNDiff()} for detailed example.
prior_list <- paramEst(mod)
correctedOR(a = 66, N1 = 11782, c = 243, N0 = 57973, prior_list = prior_list,
chains = 3, iter = 10000)

Model without misclassification

Description

Generate a stanfit object corresponding to a posterior distribution of uncorrected odds ratio given no misclassification.

Usage

crudeOR(
  a,
  N1,
  c,
  N0,
  logitpi0_prior = c(0, 10),
  lor_prior = c(0, 2),
  chains = 2,
  traceplot = FALSE,
  inc_warmup = FALSE,
  window = NULL,
  refresh = 0,
  seed = NA,
  ...
)

Arguments

a

number of exposed subjects in the case group.

N1

number of total subjects in the case group.

c

number of exposed subjects in the control group.

N0

number of total subjects in the control group.

logitpi0_prior

mean and sd of the prior normal distribution of logit(pi0). Default to c(0,10).

lor_prior

mean and sd of the prior normal distribution of corrected log odds ratio. Default to c(0,2).

chains

number of Markov Chains. Default to 2.

traceplot

Logical, defaulting to FALSE. If TRUE it will draw the traceplot corresponding to one or more Markov chains.

inc_warmup

Only evaluated when traceplot = TRUE. TRUE or FALSE, indicating whether or not to include the warmup sample in the traceplot; defaults to FALSE.

window

Only evaluated when traceplot = TRUE. A vector of length 2. Iterations between window[1] and window[2] will be shown in the plot. The default shows all iterations if inc_warmup is TRUE and all iterations from the sampling period only if inc_warmup is FALSE. If inc_warmup is FALSE the iterations specified in window do not include iterations from the warmup period. The default number of iterations is 2000 unless otherwise specified in the optional iter argument.

refresh

an integer value used to control how often the progress of sampling is reported. By default, the progress indicator is turned off, thus refresh <= 0. If on, refresh = max(iter/10, 1) is generally recommended.

seed

the seed for random number generation. See stan for more details.

...

optional parameters passed to stan.

Value

It returns a stanfit object of this model, which inherits stanfit class methods. See rstan for more details.

Examples

# Case-control study data of Bipolar Disorder with rheumatoid arthritis (Farhi et al. 2016)
# Data from \url{https://www.sciencedirect.com/science/article/pii/S0165032715303864#bib13}

# 3 MCMC chains with 10000 iterations each
crudeOR(a = 66, N1 = 11782, c = 243, N0 = 57973, chains = 3, iter = 10000)

Model with differential misclassification

Description

Generate a stanfit object corresponding to a posterior distribution of corrected odds ratio given a four-variate differential misclassification.

Usage

diffOR(
  a,
  N1,
  c,
  N0,
  mu,
  s.lg.se0,
  s.lg.se1,
  s.lg.sp0,
  s.lg.sp1,
  corr.sesp0,
  corr.sesp1,
  corr.group = 0,
  z = NULL,
  logitpi0_prior = c(0, 10),
  lor_prior = c(0, 2),
  chains = 2,
  traceplot = FALSE,
  inc_warmup = FALSE,
  window = NULL,
  refresh = 0,
  seed = 0,
  ...
)

Arguments

a

number of exposed subjects in the case group.

N1

number of total subjects in the case group.

c

number of exposed subjects in the control group.

N0

number of total subjects in the control group.

mu

vector of length 4; multivariate normal distribution of z(mu,varz)z \sim (mu, varz), where each μ\mu corresponds to the logit mean of Se0Se_0, Se1Se_1, Sp0Sp_0 and Sp1Sp_1 (0 for controls, 1 for cases group).

s.lg.se0

standard deviation of logit Se in the control group.

s.lg.se1

standard deviation of logit Se in the case group.

s.lg.sp0

standard deviation of logit Sp in the control group.

s.lg.sp1

standard deviation of logit Sp in the case group.

corr.sesp0

correlation between Se_0 and Sp_0.

corr.sesp1

correlation between Se_1 and Sp_1.

corr.group

correlation between Se_0 and Se_1, Sp_0 and Sp_1. Default to 0.

z

vector of length 4; used as an initial value for z(mu,varz)z \sim (mu, varz). Default to mu.

logitpi0_prior

mean and sd of the prior normal distribution of logit(pi0). Default to c(0,10).

lor_prior

mean and sd of the prior normal distribution of corrected log odds ratio. Default to c(0,2).

chains

number of Markov Chains. Default to 2.

traceplot

Logical, defaulting to FALSE. If TRUE it will draw the traceplot corresponding to one or more Markov chains.

inc_warmup

Only evaluated when traceplot = TRUE. TRUE or FALSE, indicating whether or not to include the warmup sample in the traceplot; defaults to FALSE.

window

Only evaluated when traceplot = TRUE. A vector of length 2. Iterations between window[1] and window[2] will be shown in the plot. The default shows all iterations if inc_warmup is TRUE and all iterations from the sampling period only if inc_warmup is FALSE. If inc_warmup is FALSE the iterations specified in window do not include iterations from the warmup period. The default number of iterations is 2000 unless otherwise specified in the optional iter argument.

refresh

an integer value used to control how often the progress of sampling is reported. By default, the progress indicator is turned off, thus refresh <= 0. If on, refresh = max(iter/10, 1) is generally recommended.

seed

the seed for random number generation. See stan for more details.

...

optional parameters passed to stan.

Value

It returns a stanfit object of this model, which inherits stanfit class methods. See rstan for more details.

Examples

# Case-control study data of Bipolar Disorder with rheumatoid arthritis (Farhi et al. 2016)
# Data from \url{https://www.sciencedirect.com/science/article/pii/S0165032715303864#bib13}

diffOR(a = 66, N1 = 11782, c = 243, N0 = 57973, mu = c(1.069, 1.069, 1.126, 1.126),
  s.lg.se0 = 0.712, s.lg.se1 = 0.712, s.lg.sp0 = 0.893, s.lg.sp1 = 0.893, corr.sesp0 = -0.377,
  corr.sesp1 = -0.377, corr.group = 0, chains = 3, iter = 10000)

Model with nondifferential, correlated misclassification

Description

Generate a stanfit object corresponding to a posterior distribution of corrected odds ratio given nondifferential misclassification that extends from the logit model but allows there to be a fixed correlation between sentivity and specificity.

Usage

fixedCorrOR(
  a,
  N1,
  c,
  N0,
  prior_list = NULL,
  m.lg.se = NULL,
  m.lg.sp = NULL,
  s.lg.se = NULL,
  s.lg.sp = NULL,
  lg.se = NULL,
  lg.sp = NULL,
  rho = NULL,
  logitpi0_prior = c(0, 10),
  lor_prior = c(0, 2),
  chains = 2,
  traceplot = FALSE,
  inc_warmup = FALSE,
  window = NULL,
  refresh = 0,
  seed = NA,
  ...
)

Arguments

a

number of exposed subjects in the case group.

N1

number of total subjects in the case group.

c

number of exposed subjects in the control group.

N0

number of total subjects in the control group.

prior_list

list of priors. Can be replaced by the function call to paramEst, or a list of prior parameters (m.lg.se, s.lg.se, m.lg.sp, s.lg.sp, rho). If prior_list is specified, the values for the corresponding function parameters will be disregarded.

m.lg.se

normal distribution of logit Se with (mean = m.lg.se, sd = s.lg.se). Do not have to specify this if prior_list is given - it will be disregarded.

m.lg.sp

conditional normal distribution of logit Sp given Se with (m.lg.sp, s.lg.sp). Do not have to specify this if prior_list is given - it will be disregarded.

s.lg.se

standard deviation of logit Se. Do not have to specify this if prior_list is given - it will be disregarded.

s.lg.sp

standard deviation of logit Sp. Do not have to specify this if prior_list is given - it will be disregarded.

lg.se

used as an initial value for logit Se. Default to m.lg.se

lg.sp

used as an initial value for logit Sp. Default to m.lg.sp

rho

correlation between Se and Sp. Do not have to specify this if prior_list is given - it will be disregarded.

logitpi0_prior

mean and sd of the prior normal distribution of logit(pi0). Default to c(0,10).

lor_prior

mean and sd of the prior normal distribution of corrected log odds ratio. Default to c(0,2).

chains

number of Markov Chains. Default to 2.

traceplot

Logical, defaulting to FALSE. If TRUE it will draw the traceplot corresponding to one or more Markov chains.

inc_warmup

Only evaluated when traceplot = TRUE. TRUE or FALSE, indicating whether or not to include the warmup sample in the traceplot; defaults to FALSE.

window

Only evaluated when traceplot = TRUE. A vector of length 2. Iterations between window[1] and window[2] will be shown in the plot. The default shows all iterations if inc_warmup is TRUE and all iterations from the sampling period only if inc_warmup is FALSE. If inc_warmup is FALSE the iterations specified in window do not include iterations from the warmup period. The default number of iterations is 2000 unless otherwise specified in the optional iter argument.

refresh

an integer value used to control how often the progress of sampling is reported. By default, the progress indicator is turned off, thus refresh <= 0. If on, refresh = max(iter/10, 1) is generally recommended.

seed

the seed for random number generation. See stan for more details.

...

optional parameters passed to stan.

Value

It returns a stanfit object of this model, which inherits stanfit class methods. See rstan for more details.

Examples

# Case-control study data of Bipolar Disorder with rheumatoid arthritis (Farhi et al. 2016)
# Data from \url{https://www.sciencedirect.com/science/article/pii/S0165032715303864#bib13}

mod <- nlmeNDiff(bd_meta, lower = 0) # see \code{nlmeNDiff()} for detailed example.
prior_list <- paramEst(mod)
fixedCorrOR(a = 66, N1 = 11782, c = 243, N0 = 57973, prior_list = prior_list,
chains = 3, iter = 10000)

Model with nondifferential, logit normal-distributed misclassification

Description

Generate a stanfit object corresponding to a posterior distribution of corrected odds ratio given nondifferential misclassification under a logit-transformed scaled bivariate normal distribution.

Usage

logitOR(
  a,
  N1,
  c,
  N0,
  prior_list = NULL,
  m.lg.se = NULL,
  m.lg.sp = NULL,
  s.lg.se = NULL,
  s.lg.sp = NULL,
  lg.se = NULL,
  lg.sp = NULL,
  logitpi0_prior = c(0, 10),
  lor_prior = c(0, 2),
  chains = 2,
  traceplot = FALSE,
  inc_warmup = FALSE,
  window = NULL,
  refresh = 0,
  seed = NA,
  ...
)

Arguments

a

number of exposed subjects in the case group.

N1

number of total subjects in the case group.

c

number of exposed subjects in the control group.

N0

number of total subjects in the control group.

prior_list

list of priors. Can be replaced by the function call to paramEst, or a list of prior parameters (m.lg.se, s.lg.se, m.lg.sp, s.lg.sp). If prior_list is specified, the values for the corresponding function parameters will be disregarded.

m.lg.se

normal distribution of logit Se with (mean = m.lg.se, sd = s.lg.se). Do not have to specify this if prior_list is given - it will be disregarded.

m.lg.sp

normal distribution of logit Sp with (m.lg.sp, s.lg.sp). Do not have to specify this if prior_list is given - it will be disregarded.

s.lg.se

standard deviation of logit Se. Do not have to specify this if prior_list is given - it will be disregarded.

s.lg.sp

standard deviation of logit Sp. Do not have to specify this if prior_list is given - it will be disregarded.

lg.se

used as an initial value for logit Se. Default to m.lg.se

lg.sp

used as an initial value for logit Sp. Default to m.lg.sp

logitpi0_prior

mean and sd of the prior normal distribution of logit(pi0). Default to c(0,10).

lor_prior

mean and sd of the prior normal distribution of corrected log odds ratio. Default to c(0,2).

chains

number of Markov Chains. Default to 2.

traceplot

Logical, defaulting to FALSE. If TRUE it will draw the traceplot corresponding to one or more Markov chains.

inc_warmup

Only evaluated when traceplot = TRUE. TRUE or FALSE, indicating whether or not to include the warmup sample in the traceplot; defaults to FALSE.

window

Only evaluated when traceplot = TRUE. A vector of length 2. Iterations between window[1] and window[2] will be shown in the plot. The default shows all iterations if inc_warmup is TRUE and all iterations from the sampling period only if inc_warmup is FALSE. If inc_warmup is FALSE the iterations specified in window do not include iterations from the warmup period. The default number of iterations is 2000 unless otherwise specified in the optional iter argument.

refresh

an integer value used to control how often the progress of sampling is reported. By default, the progress indicator is turned off, thus refresh <= 0. If on, refresh = max(iter/10, 1) is generally recommended.

seed

the seed for random number generation. See stan for more details.

...

optional parameters passed to stan.

Value

It returns a stanfit object of this model, which inherits stanfit class methods. See rstan for more details.

Examples

# Case-control study data of Bipolar Disorder with rheumatoid arthritis (Farhi et al. 2016)
# Data from \url{https://www.sciencedirect.com/science/article/pii/S0165032715303864#bib13}

mod <- nlmeNDiff(bd_meta, lower = 0) # see \code{nlmeNDiff()} for detailed example.
prior_list <- paramEst(mod)
logitOR(a = 66, N1 = 11782, c = 243, N0 = 57973, prior_list = prior_list,
chains = 3, iter = 10000)

Non-differential Generalized Linear Mixed Effects Model

Description

Fit a bivariate generalized linear mixed-effects model (GLMM) for non-differential sensitivity and specificity using the glmer function in lme4. Lower and upper bounds for Se and Sp can be specified according to the assumptions of the study.

Usage

nlmeNDiff(data, lower = 0.5, upper = 1, id = FALSE, ...)

Arguments

data

a data frame containing the 2 by 2 data of the diagnostics table of exposure status for every study in a meta-analysis. It contains at least 4 columns in the data named as following: n11 indicates the true positives, n01 the false positives, n00 the true negatives and n10 the false negatives. Each column is a vector of same length, which is the number of meta-analysis study results used in the model.

lower

an optional argument specifying the lower bound assumption of Se and Sp. Default to 0.5 (or the lowest Se/Sp of all studies, whichever is lower), which provides the mild assumption that Se and Sp are better than chance.

upper

an optional argument specifying the upper bound assumption of Se and Sp. Default to 1.

id

a TRUE of FALSE argument indicating if the supplied data has a sid column that gives same studies the same subject ID. Default to FALSE, which assumes that all studies have different IDs.

...

optional parameters passed to glmer.

Value

It returns an object of class merMod. Besides generic class methods, paramEst() is implemented in BayesSenMC to get the parameter estimates used in the Bayesian misclassification model functions.

Examples

data(bd_meta)

mod <- nlmeNDiff(bd_meta, lower = 0)

Parameter estimates of the GLMM model

Description

Get parameter estimates of the GLMM model to plug into modeling functions in BayesSenMC for Bayesian inference of adjusted odds ratio.

Usage

paramEst(model, lower = 0.5, upper = 1)

Arguments

model

a GLMM model built with the nlmeNDiff() function.

lower

an optional argument matching the lower bound assumption of Se and Sp of the input model. Default to 0.5 as in nlmeNDiff().

upper

an optional argument matching the upper bound assumption of Se and Sp. Default to 1 as in nlmeNDiff.

Value

It returns a list of parameter estimates which can be input into the Bayesian model functions in BayesSenMC. (m.lg.se, s.lg.se) and (m.lg.sp, s.lg.sp) are the logit prior distributions for Se and Sp. se and sp are the corresponding mean values given the logit prior means. rho is the correlation estimate between Se and Sp. m.fisher is the Fisher's mean of the correlation assume a Fisher's distribution.

Examples

data(bd_meta)

mod <- nlmeNDiff(bd_meta, lower = 0) # see \code{nlmeNDiff()} for detailed example.
prior_list <- paramEst(mod)

Plot Model

Description

Plot the posterior distribution of adjusted odds ratio given the stanfit object. It also plots the density lines of crude/uncorrected odds ratio and corrected odds ratio with constant misclassification, assuming log-normality is true. If both Se and Sp are set to 1 (i.e., no misclassification), then only the density line of crude OR will be plotted.

Usage

plotOR(
  model,
  a,
  N1,
  c,
  N0,
  se = 1,
  sp = 1,
  x.min = 0,
  x.max = NULL,
  y.max = NULL,
  binwidth = 0.25,
  fill = "gray",
  ...
)

Arguments

model

A stanfit object.

a

number of exposed subjects in the case group. Along with N1, c, N0, se and sp, they are used to plot probability density with no misclassification and constant misclassification as a comparison.

N1

number of total subjects in the case group.

c

number of exposed subjects in the control group.

N0

number of total subjects in the control group.

se

sensitivity. Default to 1. If no other values are specified for either se or sp, then only the density curve of corrected model will be drawn.

sp

specificity. Default to 1.

x.min

shows only samples with corrected odds ratio larger or equal to x.min. Default to 0.

x.max

shows only samples with corrected odds ratio smaller or equal to x.max. Default to the largest OR in the posterior samples.

y.max

shows only samples or density line within the range of (0, y.max).

binwidth

default to 0.25

fill

default to "gray"

...

optional additional arguments passed to geom_histogram

Value

It returns a ggplot that can be further customized using the ggplot2 package.

Examples

# Case-control study data of Bipolar Disorder with rheumatoid arthritis (Farhi et al. 2016)
# Data from \url{https://www.sciencedirect.com/science/article/pii/S0165032715303864#bib13}

library(ggplot2)
my.mod <- randCorrOR(a = 66, N1 = 11782, c = 243, N0 = 57973, m.lg.se = 1.069,
m.lg.sp = 1.126, s.lg.se = 0.893, s.lg.sp = 0.712, m.z = -0.399, s.z = 0.139,
seed = 0)

my.plot <- plotOR(my.mod, a = 66, N1 = 11782, c = 243, N0 = 57973, se = 0.744,
sp = 0.755, x.max = 3, y.max = 5, binwidth = 0.1) + ggtitle("Model with random correlation")

# the user can also directly extract the data from a stanfit object using the following
my.data <- as.data.frame(my.mod)

Model with nondifferential, randomly correlated misclassification

Description

Generate a stanfit object corresponding to a posterior distribution of corrected odds ratio given nondifferential misclassification that extends from the logit model but allows a random correlation between Sensitivity and Specificity.

Usage

randCorrOR(
  a,
  N1,
  c,
  N0,
  prior_list = NULL,
  m.lg.se = NULL,
  m.lg.sp = NULL,
  s.lg.se = NULL,
  s.lg.sp = NULL,
  lg.se = NULL,
  lg.sp = NULL,
  m.z = NULL,
  s.z = NULL,
  z = NULL,
  logitpi0_prior = c(0, 10),
  lor_prior = c(0, 2),
  chains = 2,
  traceplot = FALSE,
  inc_warmup = FALSE,
  window = NULL,
  refresh = 0,
  seed = NA,
  ...
)

Arguments

a

number of exposed subjects in the case group.

N1

number of total subjects in the case group.

c

number of exposed subjects in the control group.

N0

number of total subjects in the control group.

prior_list

list of priors. Can be replaced by the function call to paramEst, or a list of prior parameters (m.lg.se, s.lg.se, m.lg.sp, s.lg.sp, m.z, s.z). If prior_list is specified, the values for the corresponding function parameters will be disregarded.

m.lg.se

normal distribution of logit Se with (mean = m.lg.se, sd = s.lg.se). Do not have to specify this if prior_list is given - it will be disregarded.

m.lg.sp

conditional normal distribution of logit Sp given Se with (m.lg.sp, s.lg.sp). Do not have to specify this if prior_list is given - it will be disregarded.

s.lg.se

standard deviation of logit Se. Do not have to specify this if prior_list is given - it will be disregarded.

s.lg.sp

standard deviation of logit Sp. Do not have to specify this if prior_list is given - it will be disregarded.

lg.se

used as an initial value for logit Se. Default to m.lg.se. Do not have to specify this if prior_list is given - it will be disregarded. Default to m.lg.se

lg.sp

used as an initial value for logit Sp. Default to m.lg.sp. Do not have to specify this if prior_list is given - it will be disregarded. Default to m.lg.sp

m.z

normal distribution of Z with (mean = m.z, sd = s.z). Do not have to specify this if prior_list is given - it will be disregarded.

s.z

normal distribution of Z with (mean = m.z, sd = s.z). Do not have to specify this if prior_list is given - it will be disregarded.

z

used as an initial value of Fisher's Z transformed of rho, where correlation rho = (exp(2z)-1)/(1+exp(2z))). Do not have to specify this if prior_list is given - it will be disregarded. Default to m.z

logitpi0_prior

mean and sd of the prior normal distribution of logit(pi0). Default to c(0,10).

lor_prior

mean and sd of the prior normal distribution of corrected log odds ratio. Default to c(0,2).

chains

number of Markov Chains. Default to 2.

traceplot

Logical, defaulting to FALSE. If TRUE it will draw the traceplot corresponding to one or more Markov chains.

inc_warmup

Only evaluated when traceplot = TRUE. TRUE or FALSE, indicating whether or not to include the warmup sample in the traceplot; defaults to FALSE.

window

Only evaluated when traceplot = TRUE. A vector of length 2. Iterations between window[1] and window[2] will be shown in the plot. The default shows all iterations if inc_warmup is TRUE and all iterations from the sampling period only if inc_warmup is FALSE. If inc_warmup is FALSE the iterations specified in window do not include iterations from the warmup period. The default number of iterations is 2000 unless otherwise specified in the optional iter argument.

refresh

an integer value used to control how often the progress of sampling is reported. By default, the progress indicator is turned off, thus refresh <= 0. If on, refresh = max(iter/10, 1) is generally recommended.

seed

the seed for random number generation. See stan for more details.

...

optional parameters passed to stan.

Value

It returns a stanfit object of this model, which inherits stanfit class methods. See rstan for more details.

Examples

# Case-control study data of Bipolar Disorder with rheumatoid arthritis (Farhi et al. 2016)
# Data from \url{https://www.sciencedirect.com/science/article/pii/S0165032715303864#bib13}

mod <- nlmeNDiff(bd_meta, lower = 0) # see \code{nlmeNDiff()} for detailed example.
prior_list <- paramEst(mod)
randCorrOR(a = 66, N1 = 11782, c = 243, N0 = 57973, prior_list = prior_list,
chains = 3, iter = 10000)