## 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.708Posterior mean : 31.8320261Posterior std. deviation : 1.1592201Prob. Quantile ------ ---------0.005 28.84607310.01 29.1352770.025 29.55999650.05 29.92527880.5 31.83202610.95 33.73877340.975 34.10405570.99 34.52877520.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.948710.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.