Sunday, July 26, 2009

Bayes 11: one-sided hypothesis

Consider the previous example (yearling trout) where we had a prior that was normal(30,4) and observed data with n = 5 and y = 32.

v = c(31.1,28.2,34.2,35,31.5)


Let's change the problem a little bit: suppose the stream we sampled from is downstream of a nuclear power plant. We know that the population mean for unpolluted streams is 35 with a standard deviation of 4. We use the same variance, but since we guess that the trout are going to be smaller in this stream, we use a normal(30,4) prior. And we calculate the population standard deviation for our stream from the observed values. (No value is given for sigma.x).

library(Bolstad)
v = c(31.1,28.2,34.2,35,31.5)
p = normnp(v,30,4,ret=T)


We want to test the one-sided hypothesis that the trout in this stream are smaller on average than normal trout. The posterior is calculated in the usual way.

Standard deviation of the residuals :2.708
Posterior mean : 31.8320261
Posterior std. deviation : 1.1592201

Prob. Quantile
------ ---------
0.005 28.8460731
0.01 29.135277
0.025 29.5599965
0.05 29.9252788
0.5 31.8320261
0.95 33.7387734
0.975 34.1040557
0.99 34.5287752
0.995 34.8179791


We see that P(35 cm) < 0.005. We reject the hypothesis that the trout are "normal" in length. It makes some difference, but not a lot, that we used a prior mean of 30. If we had used 35, we would have

0.99 34.94871
0.995 35.2379138


P(35 cm) < 0.01. I'll let Bolstad say it:


The posterior distribution of g ( μ | y1, ..., yn ) summarizes our entire belief about the parameter, after viewing the data.