1

I'm currently trying to develop a model in JAGS, but I unfortunately keep getting the following error:

Error in jags.model(file = "Model.txt", n.adapt = MCMCAdapt) : 
RUNTIME ERROR:
Compilation error on line 15.
Unknown variable precedentCount
Either supply values for this variable with the data
or define it  on the left hand side of a relation.

The following is what is in the file titled, "Model.txt":

model {
for (i in 1:citationCount) {

    Z[i] ~ dbern(Z.hat[i])
    Z.hat[i] <- phi(kappa - lambda*pow(x.precedent[newPrecedentID[i]] - x.brief[newBriefID[i]], 2))

}

for (j in 1:briefCount) {

    x.brief[newBriefID[j]] ~ dnorm(0,1)

}

for (k in 1:precedentCount) {

    x.precedent[newPrecedentID[k]] ~ dnorm(0,1)

}

kappa ~ dunif(-10,10)
lambda ~ dunif(-10, 0)

}

I'm a little confused as to why the error is occurring, as precedentCount is already defined in R's environment:

> precedentCount
[1] 650

The same thing is true for briefCount and citationCount, yet these have not yielded the same error (yet, at least):

> briefCount
[1] 126
> citationCount
[1] 2948

If anyone can advise how I can address this problem, I would greatly appreciate it.

1 Answer 1

3

You need to give JAGS all data as the argument jags.model(data = list(...)). precedentCount came up because it was just the first error.

data_list <- list(precedentCount = 650, 
                  briefCount = 126, 
                  citationCount = 2948,
                  newPrecedentID = ...))

jags.model(file = "Model.txt", n.adapt = MCMCAdapt, data = data_list)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.