简体   繁体   中英

Passing existing matrix into JAGS model using R package rjags

Very simple question, but I somehow cannot find a solution. How would you pass existing value(matrices, vectors) into JAGS model using rjags?

Here is a sample code:

model{
      A = inverse(B)
     }

And somehow I want to pass B = diag(100) into the model above, how should I do that?

You pass data to a model with the data arg to jags.model :

For example:

library(rjags)

M <- 'model {
  A <- inverse(B)
}'

j <- jags.model(textConnection(M), data=list(B=diag(10)), n.chains=3)
jags.samples(j, 'A', 1000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM