Assignment 3
Assignment 3
STAT314/STAT461
Set: Tue, Aug-30. Due: Fri Sept-10
Please type everything in either Word or LaTex, and submit it as a PDF file via Learn. No
handwritten submissions! (And no scans of handwritten submissions, please).
Show your workings: equations for theoretical problems; code and (relevant) output for the
computational problems. It is not sufficient to report an answer. Don’t forget to include
intermediate steps and explain your way of thinking. You may get points for thinking in the
right direction even if you don’t get the answer exactly right.
If you need an extention, please ask for it in advance. Late submissions will not be accepted.
Problem 1.
Let’s get back to the drinkers and teetotallers data.
x <- rep(0:6,c(22,6,18,23,18,10,3))
hist(x,seq(-.25,7.25,.5),col='plum',xlab='number of days drinking, x',main='')
number of days drinking, x
F
re
q
u
e
n
cy
0 2 4 6
0
5
1
0
1
5
2
0
1
Consider the zero-inflated binomial model. Let zi = 1 if the person i drinks alcohol at least sometimes, and
zi = 0 otherwise. And let xi be the number of days in the past week the person i reported as alcohol drinking
days.
Pr(xi = 1|zi = 0) = 1− Pr(xi = 0|zi = 0) = 0
xi|zi = 1 ∼ BIN(7, p)
and the prior for p:
p ∼ Beta(a, b)
for some prior parameters a and b.
Furthermore, assume that zi has a further Bernoulli distribution with probability ω:
zi ∼ Bern(ω),
and that the probability parameter ω also has a beta prior (with parameters different from those for the
prior of p):
ω ∼ Beta(aω, bω)
(a) Derive the posterior conditional distribution of zi given ω and xi.
Hint: zi can only take two values, so it is enough to evaluate the Pr(zi = 1|xi, ω, p). The solution for xi > 0
should be obvious. So, the only remaining challenge is to find Pr(zi = 1|xi = 0, ω, p). Use Bayes’ formula.
4pt
(b) Run the zero-inflated and the standard binomial model using WinBUGS. Calculate the DIC for both
models. Which model is a better fit statistically? 3pt
Problem 2.
You have two coins in your pocket. One is a standard fair coin, so that P(heads)=0.50. The other one is a
two-sided coin, so that P(heads)=1. You draw one of the two coins at random and toss it twice. The result is
“heads” and “heads”.
(a) Use Bayes’ formula to obtain the probability that you have selected the two-sided coin, given your
observations. 1pt
(b) How many consecutive “heads” do you need to observe to be at least 90% certain that the coin is
two-sided? 1pt
(c) Consider a classical approach to testing the null hypothesis: the coin is fair. Let the number of “heads”
observed after two tosses be the test statistic. What is the associated p-value. (Hint: look up the
definition of the classical p-value.) 1pt
2
Problem 1.
Problem 2.