Menu

Unexpected error

runjags
2016-08-22
2016-08-24
  • Trung Dung Tran

    Trung Dung Tran - 2016-08-22

    Hi all,

    I run properly the following model in OpenBUGS and JAGS but when I move to runjags, it gives me an error

    model{
    for (i in 1 : Nsubj){
    for (j in 2: 5){
    ptemp[i, j] <- exp(beta[1]+ beta[2]Age[i] +beta[3]Y[i, j-1])/(1+exp(beta[1]+ beta[2]Age[i] +beta[3]Y[i, j-1]))

            p[i, j] <- max(0.00001, min(0.99999, ptemp[i, j]))
    
            Y[i, j] ~ dbern(p[i, j])
        }
    }
    
    for (i in 1:3){
        beta[i]  ~ dnorm(0.0, 1.0E-6)
    }
    

    }

    ERROR: Error in node Age[1]
    Cannot overwrite value of observed node.

    Do anyone know why it is in runjags?

    Thank you!
    Tran.

     

    Last edit: Trung Dung Tran 2016-08-22
  • Matt Denwood

    Matt Denwood - 2016-08-24

    Hi Tran

    The error you quote is coming from JAGS rather than runjags, and at a guess is related to the initial values and data you are trying to use (although I can't tell as you have not included these in your post). If you are supplying Age as data, then make sure you don't have any initial values set for this.

    If that isn't the problem can you post a minimal reproducible example so I can try and help further?

    Also, there is a formatting error in your post - I assume line 4 of the model should read:

    ptemp[i, j] <- exp(beta[1] + beta[2]*Age[i] + beta[3]*Y[i,j-1]) / (1 + exp(beta[1] + beta[2]*Age[i] + beta[3]*Y[i, j-1]))
    

    [By the way, there is also an inverse logit (ilogit) function in JAGS.]

    Hope that helps,

    Matt

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.