Bayesian analysis of a case-control study (without covariates).
case_control_b(
cases,
controls,
x,
large_sample_approx,
ROPE,
prior_mean = 0,
prior_sd = log(10)/1.96,
plot = TRUE,
CI_level = 0.95,
seed = 1,
mc_error = 0.005
)(returned invisible) list including the following:
data: data
posterior_mean: posterior mean of the odds ratio (cases vs. controls)
CI: Credible interval
Pr_oddsratio_in_ROPE: Probability the odds ratio (cases vs. controls) is in the ROPE
posterior_draws: posterior draws of the odds ratio (cases vs. controls)
or_plot: odds ratio (cases vs. controls) posterior plot
vector of length 2, giving the numbers at risk and not at risk, respectively, for cases
vector of length 2, giving the numbers at risk and not at risk, respectively, for controls
2x2 contingency table. The rows should depict the at risk status (first row is at risk, second row is not at risk), and the columns should depict the case control status (first column is case, second column is control).
If all cell counts of x are not too low
(\(\geq 5\)) then use the approximation that the empirical log odds are
normally distributed. (See details for more.) If missing, this will be
set to TRUE iff all cell counts are greater than or equal to 5.
ROPE for odds ratio. Provide either a single value or a vector of length two. If the former, the ROPE will be taken as (1/ROPE,ROPE). If the latter, these will be the bounds of the ROPE.
numeric. The prior mean on the log odds ratio
numeric. The prior sd on the log odds ratio. See details for default values.
logical. Should a plot be shown?
The posterior probability to be contained in the credible interval.
integer. Always set your seed!!! (ignored if large_sample_approx = TRUE.)
The relative monte carlo error of the quantiles of the CIs.
(ignored if large_sample_approx = TRUE.)
If large_sample_approx = TRUE (the default if left missing and all
cell counts are at least 5), then the likelihood is
$$
\log(\hat\omega) \sim N\left(\log(\omega),\frac{1}{n_{11}} + \frac{1}{n_{12}} +
\frac{1}{n_{21}} + \frac{1}{n_{22}} \right),
$$
where \(\omega\) is the odds ratio, \(\hat\omega\) is the
empirical odds ratio, \(n_{ij}\), \(i,j = 1,2\) are the cells of the
2x2 contingency table. The prior on \(\log\omega\) is
$$
\log\omega \sim N(a,b^2).
$$
If the large sample approximation is not used, then inference is made on the odds ratio by instead putting uniform priors on \(\Pr(exposure|outcome)\).
case_control_b(matrix(c(8,47,1,26),2,2))
case_control_b(c(8,47),
c(1,26))
Run the code above in your browser using DataLab