RJAGS模型无法编译

时间:2016-01-15 07:26:41

标签: r jags

我试图让我的模型在RJAGS中编译,但我一直收到一个似乎没有描述问题的运行时错误,如下所示:

model {
  theta ~ dbeta(1,2);
  for (i in 1:N) {
    fp[i] ~ dbeta(1,2);
    fn[i] ~ dbeta(1,2);
    tp[i] <- 1-fn[i];
    tn[i] <- 1-fp[i];
  }
  for (j in 1:M) {
    margprobs[j] <- theta * 
     (fn[1]^(1-x[j,1])) * (tp[1]^x[j,1]) *
     (fn[2]^(1-x[j,2])) * (tp[2]^x[j,2]) 
    + (1-theta) * 
    (tn[1]^(1-x[j,1])) * (fp[1]^x[j,1]) *
    (tn[2]^(1-x[j,2])) * (fp[2]^x[j,2]);

    postprobs[j] <- theta * 
    (fn[1]^(1-x[j,1])) * (tp[1]^x[j,1]) *  
    (fn[2]^(1-x[j,2])) * (tp[2]^x[j,2])
    }

counts ~ dmulti(margprobs, total);
 }

错误:

Compiling model graph
   Resolving undeclared variables 
Deleting model

Error in jags.model(model.file, data = data, inits = init.values,     n.chains = n.chains,  : 
  RUNTIME ERROR:
Compilation error on line 9.
Unknown function: :

Calls: jags -> jags.model -> .Call
Execution halted

我的数据似乎指定了所需的变量:

jags.data <- c("M", "N", "x", "counts", "total");

有谁知道是什么阻止了这个模型的编译?

编辑:这就是数据的样子,如print()给出的 -

$M
[1] 4

$N
[1] 2

$x
     Var1 Var2
[1,]    0    0
[2,]    1    0
[3,]    0    1
[4,]    1    1

$counts
[1] 377558   1001   2000   2000

$total
[1] 382559

0 个答案:

没有答案