Description Usage Arguments Details Value Examples
Performs Objective Bayesian analysis on the odds ratio θ of a 2x2 contingency table using the reference prior of Snyder and Sun 2018.
1 2 |
x |
a 2x2 contingency table in matrix form |
conf.int |
Should a credible interval be computed using numerical integration? |
conf.level |
confidence level for the returned credible interval. NOTE: Equal tailed |
post.sample |
Should Posterior sampling be conducted? |
sampling.depth |
Depth of sampling. 1 for theta only, 2 to add eta1, 3 to add eta3, 4 to add eta2 |
num.samples |
Number of Posterior Samples |
This methdology takes an unstructured 2x2 table of the form
n1 | n2 |
n3 | n4 |
where each ni~Poisson(λi). From this, we primarilly seek to perform inference on the odds ratio θ = λ1λ4/λ2λ3.
The Bayesian reference structure also contains several other nuisance parameters that may be of interest to the researcher. We have
θ = λ1λ4/λ2λ3, η1 = λ1/(λ1+λ3), η2 = λ1+λ3, η3 = λ2/λ1
We first note that despite being “nuisance" parameters, the three ηi have highly informative interpretations. η_1 represents the proportion of negative/positive outcomes in the control/treatment group. η_2 represents the total average number of negative/positive outcomes, and is a parameter that is related to the "scale" of the table. Finally, η_3 represents the relative risk of a positive outcome in the control group.
CI |
The Credible interval and median |
Theta.Samples |
If |
Eta1.Samples |
If |
Eta2.Samples |
If |
Eta3.Samples |
If |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # Snyder and Sun (2018), Data were collected to establish a relationship between
# mobile phone and laptop operating system types for an undergraduate statistics class.
MyTable <- rbind(c(5,0),
c(8,15))
dimnames(MyTable) <- list(Phone = c("Android", "Iphone"),Computer = c("Windows", "Mac"))
MyTable
# Fisher's exact test yields an infinitely wide interval and no sample estimate
fisher.test(MyTable)
# Results from a reference Bayesian Analysis are sensible.
res <- OR_Ref(MyTable,conf.int = TRUE,num.samples = 1000)
res$CI
quantile(res$Theta.Samples,c(.025,.5,.975))
# Agresti (1990, p. 61f; 2002, p. 91) Fisher's Tea Tasting Experiment
# A colleague of Fisher claimed to be able to distinguish if milk or
# tea was added to a cup first. She was given 8 cups of
# tea, in which she was told that four of which had milk added first.
# The null hypothesis is that there is no association between the true
# order of pouring and the woman's guess, the alternative that there
# is a positive association (that the odds ratio is greater than 1).
TeaTasting <-
matrix(c(3, 1, 1, 3),
nrow = 2,
dimnames = list(Guess = c("Milk", "Tea"),
Truth = c("Milk", "Tea")))
fisher.test(TeaTasting, alternative = "greater")
# => p = 0.2429, association could not be established
res <- OR_Ref(TeaTasting,conf.int = FALSE,num.samples = 2500)
sum(res$Theta.Samples>1)/sum(res$Theta.Samples<1)
# Bayes Factor indicates substantial evidence of her ability
# Fisher (1962, 1970), Criminal convictions of like-sex twins
Convictions <-
matrix(c(2, 10, 15, 3),
nrow = 2,
dimnames =
list(c("Dizygotic", "Monozygotic"),
c("Convicted", "Not convicted")))
Convictions
fisher.test(Convictions, alternative = "less")
#Fisher's exact test is infinitely wide on log scale.
res <- OR_Ref(Convictions,conf.int = FALSE,num.samples = 5000)
quantile(res$Theta.Samples,c(.025,.5,.975))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.