Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error message: Node inconsistent with parents #21

Open
mustfa5 opened this issue Dec 13, 2017 · 0 comments
Open

error message: Node inconsistent with parents #21

mustfa5 opened this issue Dec 13, 2017 · 0 comments

Comments

@mustfa5
Copy link

mustfa5 commented Dec 13, 2017

Hi,

I am trying to run a model but getting an error message. Here is my entire code. Could anyone please help me to understand why I am getting this error message. Thanks in advance

library(R2WinBUGS);
library(R2jags);
library(coda) ;
library(boot);
library(R2jags);

dat<-matrix(c(
6 ,5 , 1 ,1 , 1, 1,
5 ,1 , 1 ,3 , 1, 1,
6 ,5 , 6 ,1 , 1, 1,
6 ,6 , 3 ,1 , 1, 1,
6 ,6 , 6 ,1 , 2, 1,
6 ,6 , 6 ,1 , 1, 1,
6 ,6 , 6 ,6 , 6, 1,
6 ,6 , 6 ,1 , 1, 1,
6 ,6 , 6 ,6 , 6, 5,
6 ,6 , 6 ,1 , 1, 1,
6 ,6 , 1 ,2 , 1, 1,
6 ,6 , 6 ,6 , 4, 1), ncol=6)

N=nrow(dat) #index for rows
I=ncol(dat) #index for columns
rater=c(1,2,3,1,2,3)
item=c(1,1,1,2,2,2)
K <- apply(dat, 2, max)
rater1 <- function() {
for (i in 1:N) {
for (j in 1:I) {
dat[i,j] ~ dcat(prob[i,j,1:K[j]])
}
theta[i] ~ dnorm(0,1)

for(j in 1:I) {
  for(k in 1:(K[j]-1)) {
    logit( P[i,j,k] ) <- theta[i]-B[item[j]] -C[item[j],k]-D[rater[j]]
  }
  P[i, j,K[j]] <- 1
}
for(j in 1:I) {
  prob[i, j, 1] <- P[i, j, 1]
  for (k in 2:(K[j])){
    prob[i, j, k] <- P[i, j, k] - P[i, j, k-1]
  }
}

}
for(j in 1:2) {
B[j] ~ dnorm(0,4)
}
for (j in 1:3) {
D[j] ~ dnorm(0,4)
}
for (j in 1:2) {
for(k in 1:(K[j])) {
C[j,k] ~ dnorm(0,1)
}
}
}
write.model(rater1, con = "rater.bug", digits = 5)
data=list("dat", "N", "I","rater","item", "K")
#R2jugs
rjags=jags(data=data, inits = NULL, n.chains = 1, n.iter = 1500,
n.thin = 1, model.file = "rater.bug", n.burnin = 300,DIC = T,
parameters.to.save=c("B","C","theta","D"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant