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
We will use a noninformative prior proportional to 1/(ab)^2.
Then we have our posterior density
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?