Comment Problem Set #4, problem 3

The third problem in the fourth problem set (Albert, p. 73, #6) is somewhat ambiguously stated. In particular, it is not stated clearly what the second parameter in the definition of the prior is. Is it a rate, or a scale?

Most people took it to be a scale. I wrote Jim Albert, and learned that throughout the book, he’s using a rate. See Section 3.3, where he defined the gamma density. I did not take any points off if you did the calculation assuming that it is a scale=1/rate. But in the future, when you see a gamma distribution in Albert’s book, remember that the second parameter is a rate!


2 Responses to “Comment Problem Set #4, problem 3”

  1. xyz Says:

    Can you post solution of this example??

  2. bayesrules Says:

    I’ll outline the procedure. The likelihood is (4\lambda)^{y_i} e^{-4\lambda} where y_i is the number of units sold in geographic area i. The priors for the two areas are different, but are gammas with (for example in area 1) parameters 144 and 2.4, so in this instance p(\lambda_1)=\lambda_1^{144-1}e^{-2.4\lambda_1}. Multiplying prior times likelihood we get another gamma, this time with parameters 144+y_1 and 2.4+4. So to get a sample on \lambda_1 simply use the R function rgamma with these parameters to generate a large sample \{\lambda_1^j\}, j=1,...,N

    Similarly generate a sample of \lambda_2^j‘s of the same size.

    Subtract 1.5 times the samples of the \lambda_2‘s from the samples of the \lambda_1‘s to get a sample of the differences. To do this, subtract 1.5 times the first component of sample #2 from the first component of sample #1, and so forth, to get a sample of differences, again of length N. This can be done by simply subtracting 1.5 times the second vector from the first. Then in R, the proportion of the difference that is greater than 0 is the answer you want.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: