1
$\begingroup$

I am trying to estimate the parameters of a uniform distribution, which, by a visual inspection, is between -5 and 25.

I am getting the following error:

"Error in jags.model(filepath, data = list(x = x, N = N), n.chains = 2) : 

   Error in node x[1]

Node inconsistent with parents"

I think the problem is with the .bug file:

model {
for (i in 1:N) {
    x[i] ~ dunif(a, b)
}

a ~ dnorm(-5, .0001)
b ~ dnorm(15,.0001)

}

This code is suppose to estimate "a" and "b", where "x" is uniformly distributed between them.

Any idea why I am getting the error? (Am I even in the right direction?)

$\endgroup$
1
$\begingroup$

You don't have a reproducible example but I'm pretty sure I know what is going on. If any of your observations are outside a, b then the likelihood is undefined and you get the error (which must be happening for x[1], it is either less than -5 or greater than 15.

It's really odd to estimate the uniform distribution this way. Just take a and b to be the min(x) and max(x). I don't see the uniform distribution used as likelihood, more often as a prior.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.