11.07.2015 Views

statisticalrethinkin..

statisticalrethinkin..

statisticalrethinkin..

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

70 3. SAMPLING THE IMAGINARYNow once you have the posterior density in hand, how should you use it to maximizeyour expected winnings? It turns out that the parameter value that maximizes expectedwinnings (minimizes expected loss) is the median of the posterior density. Let’s calculatethat fact, without using a mathematical proof. ose interested in the proof should followthe endnote. 48Calculating expected loss for any given decision means using the posterior to averageover our uncertainty in the true value. Of course we don’t know the true value, in mostcases. But if we are going to use our model’s information about the parameter, that meansusing the entire posterior distribution. So suppose we decide p = 0.5 will be our decision.en the expected loss will be:R code3.17sum( posterior*abs( 0.5 - p_grid ) )[1] 0.3128752e symbols posterior and p_grid are the same ones we’ve been using throughout thischapter, containing the posterior probabilities and the parameter values, respectively. Allthe code above does is compute the weighted average loss, where each loss is weighted by itscorresponding posterior probability. ere’s a trick for repeating this calculation for everypossible decision, using the function sapply, said like ess apply. For now, just use this trick.I’ll explain how and why it works, later in the book.R code3.18loss

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

Saved successfully!

Ooh no, something went wrong!