Re: [R] density function always evaluating to zero

2011-12-04 Thread Sarah Goslee
I didn't try out your extensive code, but here's one potentially serious problem: You only pass two arguments to f(), alpha and h, but within f you nonetheless use x1 and y and several other things. This is bad practice, and dangerous: you should pass all the necessary arguments to f(), not rely o

Re: [R] density function always evaluating to zero

2011-12-04 Thread napps22
Sorry that was my poor copying and pasting. Here's the correct R code. The problem does seem to be with the function I define as f. # Model selection example in a bayesian framework # two competiting non-nested models # M0: y_t = alpha * x1^2 + e_t # M1: y_t = beta * x1^4 + e_t # where e_t ~ iidN(

Re: [R] density function always evaluating to zero

2011-12-03 Thread David Winsemius
On Dec 3, 2011, at 5:42 PM, napps22 wrote: Dear R users, I'm trying to carry out monte carlo integration of a posterior density function which is the product of a normal and a gamma distribution. The problem I have is that the density function always returns 0. How can I solve this proble

[R] density function always evaluating to zero

2011-12-03 Thread napps22
Dear R users, I'm trying to carry out monte carlo integration of a posterior density function which is the product of a normal and a gamma distribution. The problem I have is that the density function always returns 0. How can I solve this problem? Here is my code #generate data x1 <- runif(100