1

We consider model data set collected by Gilchrist (1984), in which a series of 33 insect traps were set across sand dunes and the numbers of di↵erent insects caught over a fixed time were recorded. The number of insects of the taxa Staphylinoidea caught in the traps is shown here (data1):

2,5,0,2,3,1,3,4,3,0,3,
2,1,1,0,6,0,0,3,0,1,1,
5,0,1,2,0,0,2,1,1,1,0

Question: Generate a contour plot of the joint posterior distribution, for your choice of at least three levels.

We will model the data using a two parameter Poisson/gamma density function, which is often appropriate when the observed counts show more dispersion than predicted under a Poisson model. For parameters a > 0, b > 0, we have

LINK TO POISSION/GAMMA DENSTIY FUNCTION

We will use a noninformative prior proportional to 1/(ab)^2.

Then we have our posterior density

LINK TO POSTERIOR DENSITY FUNCTION

Here is the code template I have but I don't know where to start? I don't need exact codes but the thoughts to solve the problem.

logpost <- function(theta,y){ a <- theta[1]; b <- theta[2]
  retval <- [Log of prior]
  for (i in 1:length(y)){
     retval <- retval + [Log of p(y[i]|a,b)]
  }
  return(retval) }
mycontour(logpost,c(MIN_A,MAX_A,MIN_B,MAX_B),data1)

Any suggestions?

merv
  • 67,214
  • 13
  • 180
  • 245
Peony cc
  • 11
  • 3
  • 1
    can you please give us a little more to go on? "I don't know where to start" is a bit too much like "please do my homework for me". Can you ask your instructor or TA for help getting started? – Ben Bolker Dec 02 '19 at 23:04
  • How does this differ from the question you posted earlier today that was closed for being unfocused and unclear? Take a look back through the guidance on [mcve] and [reproducible R examples](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – camille Dec 02 '19 at 23:38

0 Answers0