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___
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 in1:(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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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___
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
Your mileage may vary. You can fit your original model in WinBUGS, however.
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?____
Set initial values for "eta.raw" not "eta", which is no longer a stochastic
node in this revised model.
Yeah, now it works well!
Thanks very very much and congratulations for your software
Hi,
I'm updating this old topic to ask for information about the difference between writing:
and
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
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