Error message

  • Shravan
    Shravan
    2014-01-10

    I want to fit a fairly simple model but I am getting an error message I was not able to diagnose.

    dat<-list(n=c(47,211,810,148,196,360,119,207,97,256,148,215),
    x=c(0,8,46,9,13,24,8,14,8,29,18,31),
    N=12)

    cat("model
    {
    for(i in 1:N){
    logit(theta[i]) ~ dnorm(mu,tau) ##<- something wrong here
    x[i] <- dbin(theta[i],n[i])
    }
    ## priors:
    mu ~ dnorm(0,0.0001)
    tau ~ dgamma(0.001,0.001)
    sigma <- 1/sqrt(tau)
    }",file="mod.jag")

    mod <- jags.model(
    file="mod.jag",
    data = dat,
    n.chains = 2,
    n.adapt =2000 , quiet=T)

    The error message:

    Error in jags.model(file = "mod.jag", data = dat, n.chains = 2, n.adapt = 2000, :

    Error parsing model file:
    syntax error on line 4 near "~"

    What is wrong with line 4 of my JAGS code?