Menu

Prop odds model: unable to resolve node...

alexander
2011-12-01
2012-11-06
  • alexander

    alexander - 2011-12-01

    Hi, I'm trying to fit a proportional odds model where 'volume' is the ordinal
    response (K categories) and 'temp30' is a dicotomic factor, but I receive the
    following error:

    Errore in jags.model(model.file, data = data, inits = inits, n.chains =
    n.chains, :

    RUNTIME ERROR:

    Compilation error on line 18.

    Unable to resolve node eta

    This may be due to an undefined ancestor node or a directed cycle in the graph

    This is the code:

    model{

    for (i in 1:N) {

    for (j in 1:K-1) {

    logit(cump) <- eta-b*temp30_+delta[assessor_]

    }

    p <- cump

    for (j in 2:K-1) {

    p <- cump-cump

    }

    p <- 1-cump

    volume_ ~ dcat(p)

    }

    b ~ dnorm(0,0.001)

    OR <- exp(b)

    tau ~ dgamma(0.001,0.001)

    sigma.u <- 1/sqrt(tau)

    for (aux in 1:L) {

    delta ~ dnorm(0,tau)

    }

    eta ~ dnorm(0,1) I(,eta)

    for (aux in 2:K-2) {

    eta ~ dnorm(0,1) I(eta,eta)

    }

    eta ~ dnorm(0,1) I(eta,)

    }

    Any suggestioon?

    Many thanks in advance and best wishes,

    Alessandro Magrini___

     
  • Martyn Plummer

    Martyn Plummer - 2011-12-01

    As the error message says, you have a directed cycle in your model: eta is
    defined in terms of eta and eta is defined in terms of eta. This is not
    allowed in JAGS.

    You want to impose a prior ordering on eta ... eta. Specifically, these are
    the order statistics of K-1 samples from a normal(0,1) distribution. An
    alternative way of getting this is given in the manual

    for (j in 1:(K-1)) {
       eta.raw[j] ~ dnorm(0,1)
    }
    eta <- sort(eta.raw)
    

    Your mileage may vary. You can fit your original model in WinBUGS, however.

     
  • alexander

    alexander - 2011-12-02

    Thanks a lot for the reply. I've tryed this:

    model{

    for (i in 1:N) {

    for (j in 1:(K-1)) {

    logit(cum) <- eta-b.temp30*temp30_+delta[assessor_]

    }

    p <- cum

    for (j in 2:(K-1)) {

    p <- cum-cum

    }

    p <- 1-cum

    volume_ ~ dcat(p)

    }

    for (j in 1:(K-1)) {

    eta.raw ~ dnorm(0,1)

    }

    eta <- sort(eta.raw)

    b.temp30 ~ dnorm(0,0.001)

    tau ~ dgamma(0.001,0.001)

    sigma.u <- 1/sqrt(tau)

    for (j in 1:L) {

    delta ~ dnorm(0,tau)

    }

    }

    and I get:

    "Error in setParameters(init.values[_], i) : Error in node eta. Attempt to set
    value of non-variable node"

    Am I wrong?____

     
  • Martyn Plummer

    Martyn Plummer - 2011-12-02

    Set initial values for "eta.raw" not "eta", which is no longer a stochastic
    node in this revised model.

     
  • alexander

    alexander - 2011-12-02

    Yeah, now it works well!

    Thanks very very much and congratulations for your software

     
  • alexander

    alexander - 2012-11-06

    Hi,

    I'm updating this old topic to ask for information about the difference between writing:

    for (j in 1:(K-1)) {
       eta.raw[j] ~ dnorm(0,1)
    }
    eta <- sort(eta.raw)
    

    and

    eta[1] ~ dnorm(0,1)
    eta[2] ~ dnorm(0,1)T(eta[1],)
    ...
    eta[K-1] ~ dnorm(0,1)T(eta[K-2],)
    

    the first solution has proven to be more efficient, I suppose because no sampled value is discarded, but is really analogous to the truncation, which is the theoretically correct way to solve the problem?

    If so, why? (anyway, avoid an in depth technical explanation...)

     

    Last edit: Martyn Plummer 2012-11-06
  • Martyn Plummer

    Martyn Plummer - 2012-11-06

    No these are definitely not the same.

    Suppose you have no data and are just sampling from the prior. In the first case, eta[1] is the smallest of (K-1) standard normal distributions. For K=11, eta[1] has mean -1.54 and standard deviation (SD) 0.59. In the second case, eta[1] has a standard normal distribution with mean 0 and SD 1

     

Log in to post a comment.