11.07.2015 Views

statisticalrethinkin..

statisticalrethinkin..

statisticalrethinkin..

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.4. MAKING THE MODEL GO 51just the count of water (6), and the start list tells map to start searching at p = 0.5. Now let’ssee the output:Warning messages:1: In dbinom(x = nw, prob = p, size = 9, log = TRUE) : NaNs produced2: In dbinom(x = nw, prob = p, size = 9, log = TRUE) : NaNs producedMean StdDev 2.5% 97.5%p 0.67 0.16 0.36 0.97Before explaining the output, let’s talk about warning messages. Note that the first thing thathappens when you execute map above is that R spits out those scary looking warnings aboutsomething called NaNs. ese warnings are usually harmless. What they indicate in this caseis that, while searching for the value of p that maximizes the posterior probability, R triedsome values outside of the 0–1 interval that p must lie within. In geek-speak, p ∈ [0, 1], butwe never told R that, so it tried values outside the range. When dbinom was told to computethe likelihood using a “probability” less than zero or greater than one, it refused and returnedNaN, which stands for not a number. is is R’s polite way of saying that it was asked a sillyquestion. Try this experiment to directly see this behavior:dbinom( 6 , size=9 , prob=2 )R code2.13[1] NaNWarning message:In dbinom(6, size = 9, prob = 2) : NaNs producedere’s your NaN. Later on, you’ll see how to prevent this kind of thing, mainly by usingtransformations of the parameters. But for now, you do need to know what these warningsmean, so you don’t overreact to them.Returning to the quadratic approximation, the function precis presents a brief summaryof the quadratic approximation. In this case, it shows a MAP value of p = 0.67, whichit calls the “Mean.” e curvature is labeled “StdDev” is stands for standard deviation.is value is the standard deviation of the posterior distribution, while the mean value isits peak. Finally, the last two values in the precis output show the 95% percentile interval,which you’ll learn more about in the next chapter. You can read this kind of approximationlike: Assuming the posterior is Gaussian, it is maximized at 0.67, and it’s standard deviationis 0.16.Since we already know the posterior, let’s compare to see how good the approximationis. I’ll use the analytical approach here, which uses dbeta. I won’t explain this calculation,but it ensures that we have exactly the right answer, with no approximations. You can findan explanation and derivation of it in just about any more advanced textbook on Bayesianinference.# analytical calculationw

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!