Hello...

I'm going a bit nuts trying to convert some of my bugs models to JAGS. I keep

getting this error over and over again:

Compilation error on line 2.

Cannot evaluate upper index of counter i

So I tried to see if I made the model less and less complex until I finally

used one of the simplest examples. Here is the model specification.

model {

for (i in 1:N) {

x_ ~ dnorm(mu, tau)

}

mu ~ dnorm(0, .0001)

tau <- pow(sigma, -2)

sigma ~ dunif(0, 100)

}

Then I call it in R with rjags. Here is the code for that.

library("rjags")

N <- 20

x <- rnorm(N)

test <- jags.model("jagsmod.bug",data =list(N="N",x="x"),n.chains =

3,n.adapt=100)

update(jags, 1000)

samples <-coda.samples(jags,c('mu', 'sigma'),1000)

I then get the following error:

Compiling model graph

Resolving undeclared variables

Deleting model

Error in jags.model("jagsmod.bug", data = list(N = "N", x = "x"), n.chains =

3, :

RUNTIME ERROR:

Compilation error on line 4.

Cannot evaluate upper index of counter i

In addition: Warning messages:

1: In jags.model("jagsmod.bug", data = list(N = "N", x = "x"), n.chains = 3, :

NAs introduced by coercion

2: In jags.model("jagsmod.bug", data = list(N = "N", x = "x"), n.chains = 3, :

NAs introduced by coercion

I truly am completely confused. This is the most basic example, taken directly

from a how-to page. I'm totally lost as to how I got that error. Any help?

_