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.

64 3. SAMPLING THE IMAGINARYR code3.7sum( samples < 0.5 ) / 1e4[1] 0.1726And that’s nearly the same answer as the grid approximation provided, although your answerwill not be exactly the same, because the exact samples you drew from the posterior will bedifferent. is region is shown in the upper-le plot in FIGURE 3.2. Using the same approach,you can ask how much posterior probability lies between 0.5 and 0.75:R code3.8sum( samples > 0.5 & samples < 0.75 ) / 1e4[1] 0.6059So about 61% of the posterior probability lies between 0.5 and 0.75. is region is shown inthe upper-right plot of FIGURE 3.2.Overthinking: Counting with sum. In the R code examples just above, I used the function sumto effectively count up how many samples fulfill a logical criterion. Why does this work? It worksbecause R internally converts the a logical expression, like samples < 0.5, to a vector of TRUE andFALSE results, one for each element of samples, saying whether or not each element matches thecriterion. Go ahead and enter samples < 0.5 on the R prompt, to see this for yourself. en whenyou sum this vector of TRUE and FALSE, R counts each TRUE as 1 and each FALSE as 0. So it ends upcounting how many TRUE values are in the vector, which is the same as the number of elements insamples that match the logical criterion.3.2.2. Intervals of defined mass. It is more common to see scientific journals reporting aninterval of defined mass, usually known as a CONFIDENCE INTERVAL. An interval of posteriorprobability, such as the ones we are working with, may instead be called a CREDIBLEINTERVAL, although the terms may also be used interchangeably, in the usual polysemy thatarises when commonplace words are used in technical definitions. It’s easy to keep track ofwhat’s being summarized, however, as long as you pay attention to how the model is defined.In this book, I’ll try to be clear by always writing posterior interval when referring to summariesof posterior probability and instead confidence interval when referring to summariesof data or simulated data.ese posterior intervals report two parameter values that contain between them a specifiedamount of posterior probability, a probability mass. For this type of interval, it is easierto find the answer by using samples from the posterior than by using a grid approximation.Suppose for example you want to know the boundaries of the lower 80% posterior probability.You know this interval starts at p = 0. To find out where it stops, think of the samplesas data and ask where the 80th percentile lies:R code3.9quantile( samples , 0.8 )80%0.7607608is region is shown in the bottom-le plot in FIGURE 3.2. Similarly, the middle 80% intervallies between the 10th percentile and the 90th percentile. ese boundaries are found usingthe same approach:

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

Saved successfully!

Ooh no, something went wrong!