Trouble with redefining nodes in model

  • gwh71

    I receive the following error when parsing a model:

    "Attempt to redefine node alpha"

    I've appened the model below. Can anyone suggest a fix? Thx, Gordon

    model {

    for (i in 1:nDays) {

    logK20_ ~ dnorm(0, 0.001)I(0,3);

    K20_ <- exp(logK20_);

    logIota_ ~ dnorm(0, 0.01)I(0,1.61);

    iota_ <- exp(logIota_);

    logRho20_ ~ dnorm(0, 0.01)I(0,1.61);

    rho20_ <- exp(logRho20_);


    Currently a standard non-informative prior set up.

    for(i in 1:nDays) {

    tau.resid_ ~ dgamma (0.001, 0.001);

    sigma.resid_ <- 1/sqrt(tau.resid_);


    For each data point, calculate the predicted O2 concentartion as a function

    of time

    then calculate the normal likelihood.

    for (j in 1:nDays){

    for(f in 1:nTot) {

    alpha <- iotaPAR - rho + K20 DOSat;

    DOHat <- (alpha-(alpha-KO2DOHat)exp(-KO2))/KO2;

    DOObs ~ dnorm(DOHat, tau.resid);



    } __

  • Martyn Plummer
    Martyn Plummer

    You need to defined alpha as a matrix. You're treating it like a local
    variable that can be redefined inside the loop, but this will not work. The
    second problem is that you have forgotten to put indices on iota, K20, etc. so
    JAGS is invoking its vectorization rules and creating alpha as a vector,
    rather than a scalar.

    The variable rho isn't defined in your model so I don't know how big it is.
    Did you mean rho20? I assume you did.

    alpha[f,j] <- iota[j]*PAR[f,j] - rho20[j] + K20[j]* DOSat[f,j];
  • gwh71

    This was exactly the information I needed. Thanks!