Week 2 Homework
6, 8, 13, 15, 16
Question 6. Test of independence.
An ecologist collects presence-absence data of two different species of plants in sample quadrats, and wants to know whether the plants occur independently. The data is:
(a) Both plants: 25% of quadrats, plant A only: 25%, plant B only: 5%
(b) Both plants: 15% of quadrats, plant A only: 35%, plant B only: 15%
Without doing a statistical test, we can assume that if the distributions are independent, then
(a)
So, these are not independent - it seems that B is more likely to occur with A.
(b)
In this dataset they are independent, it seems A and B occur together as much as they occur apart.
In reality, we would do a Chi-square test to compare these and check for independence.
Question 8. Blood transfusion.
Let's find conditional probabilites of a fatal transfusion for each recipient blood type. Since each donor blood type is independent, we add the probabilities for each blood type that's fatal for the recipient.
It's never fatal for
Now, from the law of total probability:
Question 13. Rare disease screening.
A medical test picks out a disease in 100% of the cases when it really occurs, but 5% false positives. The disease affects 0.1% of the population. Your test comes back positive - what is the probability you really have the disease.
We are looking for
We have:
Based on Bayes' Theorem:
So, we need to get
That's lower than I thought.
If you wanted to take another test about this, you would use
Question 15. Bayesian statistics
Let
The coin might be fair (q=0.5), but might be loaded in favor of heads or tails (q<0.5 or q>0.5).
We want to estimate the parameter
If our prior belief is that the coin is fair, we can specify the prior probability of the coin being fair and the probability that it will differ from fairness to different degrees (classes).
Imagine we only have three classes:
| Class | Prior probability | |
|---|---|---|
| fair coins | 0.5 | 0.98 |
| tail coins | 1 | 0.01 |
| head coins | 0 | 0.01 |
| a. Given the above "prior probability" predictions, what is the posterior probability of us getting 6 tails in 6 trials. |
From Bayes' theorem:
From the law of total prob:
So, back to Bayes':
Repeat for tail coins:
For head coins it will of course be zero. since P(6 tails|head coin)=0
b. Repeat except the prior probability is 1/3 for each type of coin:
If there is a 1/3 chance of the coin always giving tails and equal probabilities of fair or heads, we have a 98.5% chance that our coin is a tail coin.
c. What happens to the posteior probabilities if we assume P(tail coin) = 0? or that P(fair coin)=1?
| Class | Prior probability - scenario 1 | Prior probability - scenario 2 | |
|---|---|---|---|
| fair coins | 0.5 | 0.985 | 1 |
| tail coins | 1 | 0 | 0 |
| head coins | 0 | 0.015 | 0 |
Scenario 1:
If we discount the possibility of the coin being tails only, we still have a zero chance of the coin being heads only. So both scenarios will give almost the same result - probability of a fair coin is 100%.
Question 16. Bayes factor.
Also uses Binomial Distribution)
Wolbachia bacteria can infect insects eggs and distorts the sex ratio to create more females.
Our three hypotheses are
First set of data:
And the Bayes factor is 0.197
Since we are just looking at the factor we don't need the total probability to get the posterior probability ratio. We couldn't calculate the total probability since we don't know the sex ratio from
It's still more likely that we have the null hypothesis (no sex ratio distortion), but its getting close.
If in our next test we have
So now it is much more likely that there is a Wolbachia infection than that there is a normal sex ratio.
Given this scenario, let's plot the resultant Bayes factors (y axis) as a function of
left = 20
right=25
top=4
bottom=-1
---
y= 10*(0.5)^{30} / ((0.8)^{x} * 0.2^{(30-x)})
So once we reach