December 1, 2015
Questions for project + confirm the time of prensentations
Bayesian vs. frequentist inference
A study addressed the question of whether the controversial abortion drug RU 486 could be an effective "morning after" contraceptive. The study participants were women who came to a health clinic asking for emergency contraception after having had sex within the previous 72 hours.
Investigators randomly assigned the women to receive either RU486 or standard therapy consisting of high doses of the sex hormones estrogen and a synthetic version of progesterone. Of the women assigned to RU486 (T for Treatment), 4 became pregnant. Of the women who received standard therapy (C for Control), 16 became pregnant. How strongly does this information indicate that T is more effective than C?
Example modified from Don A. Berry’s, Statistics: A Bayesian Perspective, 1995, Ch. 6, pg 15.
To simplify matters let's turn this problem of comparing two proportions to a one proportion problem: consider only the 20 total pregnancies, and ask how likely is it that 4 pregnancies occur in the T group.
If T and C are equally effective, and the sample sizes for the two groups are the same, then the probability the pregnancy come from the T group is simply \(p = 0.5\).
In the frequentist framework we can set up the hypotheses as follows:
Note that here \(p\) is the probability that a given pregnancy comes from the T group.
Useful for calculating the probability of \(k\) successes in \(n\) trials with probability of success \(p\).
P(1 successes in 3 trials, \(p = 0.4\)) = \({3 \choose 1} \times 0.4^1 \times 0.6^2 = 0.432\)
dbinom(x = 1, size = 3, prob = 0.4)
## [1] 0.432
sum(dbinom(0:4, size = 20, p = 0.5))
## [1] 0.005908966
10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, or 90%
| Model (p) | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | Total |
|---|---|---|---|---|---|---|---|---|---|---|
| Prior | 0.06 | 0.06 | 0.06 | 0.06 | 0.52 | 0.06 | 0.06 | 0.06 | 0.06 | 1 |
P(data | model) = P(k = 4 | n = 20, p)
p <- seq(0.1, 0.9, 0.1) prior <- c(rep(0.06, 4), 0.52, rep(0.06, 4)) likelihood <- dbinom(4, size = 20, prob = p)
| 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | Total | |
|---|---|---|---|---|---|---|---|---|---|---|
| prior, P(model) | 0.06 | 0.06 | 0.060 | 0.06 | 0.5200 | 0.06 | 0.06 | 0.06 | 0.06 | 1 |
| likelihood, P(data|model) | 0.0898 | 0.2182 | 0.1304 | 0.035 | 0.0046 | 0.0003 | 0 | 0 | 0 |
P(model | data)
numerator <- prior * likelihood denominator <- sum(numerator) posterior <- numerator / denominator sum(posterior)
## [1] 1
| 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | Total | |
|---|---|---|---|---|---|---|---|---|---|---|
| prior, P(model) | 0.06 | 0.06 | 0.060 | 0.06 | 0.5200 | 0.06 | 0.06 | 0.06 | 0.06 | 1 |
| likelihood, P(data|model) | 0.0898 | 0.2182 | 0.1304 | 0.035 | 0.0046 | 0.0003 | 0 | 0 | 0 | |
| P(data|model) * P(model) | 0.0054 | 0.0131 | 0.0078 | 0.0021 | 0.0024 | 0 | 0 | 0 | 0 | 0.0308 |
| posterior, P(model|data) | 0.1748 | 0.4248 | 0.2539 | 0.0681 | 0.0780 | 0.0005 | 0 | 0 | 0 | 1 |
likelihood <- dbinom(4*2, size = 20*2, prob = p) numerator <- prior * likelihood denominator <- sum(numerator) posterior <- numerator / denominator
likelihood <- dbinom(4*10, size = 20*10, prob = p) numerator <- prior * likelihood denominator <- sum(numerator) posterior <- numerator / denominator
(predictive <- round(p * posterior,4))
## [1] 0.0175 0.0850 0.0762 0.0272 0.0390 0.0003 0.0000 0.0000 0.0000
sum(predictive)
## [1] 0.2452
| Model (p) | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | Total |
|---|---|---|---|---|---|---|---|---|---|---|
| prior, P(model) | 0.06 | 0.06 | 0.06 | 0.06 | 0.52 | 0.06 | 0.06 | 0.06 | 0.06 | 1 |
| posterior, P(model|data) | 0.1748 | 0.4248 | 0.2539 | 0.0681 | 0.0780 | 0.0005 | 0 | 0 | 0 | 1 |
| predictive, p * P(model|data) | 0.0175 | 0.0850 | 0.0762 | 0.0272 | 0.0390 | 0.0003 | 0.0000 | 0.0000 | 0.0000 | 0.2452 |
The continuous uniform distribution is a family of symmetric probability distributions such that for each member of the family, all intervals of the same length on the distribution's support are equally probable.
The support is defined by the two parameters, \(a\) and \(b\), which are its minimum and maximum values.
\[ f(x)=\begin{cases} \frac{1}{b - a} & \mathrm{for}\ a \le x \le b, \\[8pt] 0 & \mathrm{for}\ x<a\ \mathrm{or}\ x>b \end{cases} \]
When \(n = 20\) and \(k = 4\)
When \(n = 40\) and \(k = 8\)
When \(n = 200\) and \(k = 40\)