Bayesian Inference - Spring 1996 - Solutions - Chapter 2 ------------------------------------------------------------------------ 1. q is distributed beta(4,4); the data is "fewer than 3 heads in 10 spins" the likelihood is L(q) = Prob(y < 3 | q) = (1 - q)^10 + 10 q (1 - q)^9 + 45 q^2 (1 - q)^8 so the posterior density is p(q | data) = p(q) L(q) = q^2 (1 - q)^12 + 10 q^2 (1 - q)^11 + 45 q^2 (1 - q)^10 I've plotted the density on Minitab using the following commands: MTB > set c1 DATA> 0:1/.01 DATA> end MTB > let 'post'=c1**2*(1-c1)**12+10*c1**2*(1-c1)**11+45*c1**2*(1-c1)**10 MTB > plot 'post'*'theta'; SUBC> connect. ------------------------------------------------------------------------ 2. 2 coins, C1 and C2. Posterior probabilities are P(C1 | data) = K .5 (.4)(.4) and P(C2 | data) = K .5 (.6)(.6) or are P(C1 | data) = .31 and P(C2 | data) = .69. Given a value of q = p(H), the distribution of y = # of spins until the first head is geometric(q) with mean E(y | q) = 1/q. So the expectation we want is E(y) = P(C2 | data) E(y | C1) + P(C2 | data) E(y | C2) = .31 (1/.6) + .69 (1/.4) = 2.24 ---------------------------------------------------------------------------------------- 4. (a) Use the fact that for large n, p(y | q) is normal with mean 1000 q and variance 1000 q (1 - q). The prior predictive density for y is (approximately) p(y) = .25 N(y; 1000 (1/12), 1000 (1/12)(11/12)) + .5 N(y; 1000(1/6)(5/6)) + .25 N(y; 1000(1/4)(3/4)) I will sketch this density by simulation MTB > rand 250 c1 MTB > rand 500 c2 MTB > rand 250 c3 MTB > let c1=1000/12+c1*sqrt(1000*11/12/12) MTB > let c2=1000/6+c2*sqrt(1000*5/6/6) MTB > let c3=1000/4+c3*sqrt(1000*3/4/4) MTB > stack c1 c2 c3 c4 MTB > dotplot c4 Each dot represents 5 points . :: . . :::: .: :::: ::: .::::. ::: ::::::: ::.. .::: :::::::: ..::::. .:::::. :::::::::. :::::::: ..:::::::. ..::::::::::.. ...::::::::::... ---+---------+---------+---------+---------+---------+---C4 50 100 150 200 250 300 (b) A simple way of finding approximate percentage points is to take appropriate order statistics from the above simulated sample of y. For example, a 5% point is approximately the 50th smallest observation in the sample. Alternately, you can find percentage points by finding cumulative probabilities and trial and error. For example, the probability that y is smaller than 100 is P(y < 100) = .25 P(y < 100 | q1) + .5 P(y < 100 | q2) + .25 P(y < 100 | q3) By experimenting with different values, you can find the value y0 such that P(y < y0) = .05. ------------------------------------------------------------------------ 7. (a) The posterior density for q is normal(m1, t1) where m1 = ((n/20^2) y + (1/40^2) 180) / ((n/20^2) + (1/40^2)) t1 = 1/sqrt{((n/20^2) + (1/40^2))} (b) y is normal((m1, sqrt(t12 + 202)) (c and d) formula for a 95% interval estimate from a normal curve is mean +- 1.96 standard deviation ------------------------------------------------------------------------ 8. (a) You are given that the mean a/(a+b) = .6 and sqrt(a*b/(a+b)^2/(a+b=1)) = .3; solving for a and b gives a = 1, b = .67. (b) Your sample is y = 650 and n - y = 350. The posterior is beta(651, 350.67). mean of posterior is 651/(651+350.67) = .650 and standard deviation is sqrt(651*350.57/(1001.67^2 * 1002.67)) = .015 ---------------------------------------------------------------------------------------- 16. (a) By the p_beta output below, we see that a beta(100,100) prior reflects the belief that you think that q is between .4 and .6 with probability .995 (b) The posterior density is beta(100+511, 100+489); the posterior probability (using p_beta) that q > .5 is 1 - .26 = .74. MTB > exec 'p_beta' INPUT VALUES OF BETA PARAMETERS A AND B: DATA> 100 100 TYPE 'y' TO COMPUTE CUMULATIVE PROBABILITIES: y DATA> .4 .6 DATA> end Row P PROB_LT 1 0.4 0.00216 2 0.6 0.99784 MTB > exec 'p_beta' INPUT VALUES OF BETA PARAMETERS A AND B: DATA> 611 589 TYPE 'y' TO COMPUTE CUMULATIVE PROBABILITIES: y DATA> .5 DATA> end Row P PROB_LT 1 0.5 0.262687 ---------------------------------------------------------------------------------------- 17. with a vague prior, posterior for q is N(y bar, sigma/sqrt(n)) and predictive density is N(ybar, sqrt(sigma^2/n + sigma^2)). a 99% tolerance interval for q takes form mean +- 2.58 (standard deviation)