[英]rjags model negative binomial likelihood and gamma prior
I read in my data.我读入了我的数据。 I make the model string.
我制作了 model 字符串。 I hand it JAGS.
我把它交给JAGS。 I get "Error in node y[1] - Node inconsistent with parents".
我得到“节点 y[1] 中的错误 - 节点与父节点不一致”。
Y=read.table("data.txt",header=T)
Y=Y$Y
model_string <- "model{
# Likelihood:
for( i in 1 : N ) {
y[i] ~ dnegbin( l , r )
}
# Prior:
r ~ dgamma(1,1)
l ~ dgamma(.1,.1)
}"
model <- jags.model(textConnection(model_string),
data = list(y=Y,N=200))
First off all, I have no clue if my model is right.首先,我不知道我的 model 是否正确。 I cannot find even basic documentation for JAGS.
我什至找不到 JAGS 的基本文档。 I'm actually ashamed to admit it, because this should be as simple as an internet search, but I cannot find any document to tell me 1) how a JAGS model is set up or 2) what kinds of functions/distribution/parameters are available in JAGS.
我真的很惭愧承认这一点,因为这应该像互联网搜索一样简单,但我找不到任何文件告诉我 1)如何设置 JAGS model 或 2)什么样的功能/分布/参数是在 JAGS 中可用。 I only got this far because I found someone doing a similar model.
我之所以能走到这一步,是因为我发现有人在做类似的 model。 If anyone knows of a JAGS wiki or documentation, that would be great.
如果有人知道 JAGS wiki 或文档,那就太好了。
Edit: If someone could even just tell me what the parameters for dnegbin are that would be a huge help.编辑:如果有人能告诉我 dnegbin 的参数是什么,那将是一个巨大的帮助。 When I plug in random numbers for
l
and r
in dnegbin(l,r)
it 'works' as in it draws numbers for l
and r
, but I have no clue if it means anything.当我在
dnegbin(l,r)
中插入l
和r
的随机数时,它“起作用”,因为它为l
和r
绘制数字,但我不知道它是否意味着什么。
You can find some info about dnegbin
in the JAGS user manual .您可以在JAGS 用户手册中找到有关
dnegbin
的一些信息。
The first parameter of dnegbin
must be between and 0 and 1. You can assign eg a uniform distribution: dnegbin
的第一个参数必须介于 0 和 1 之间。您可以分配例如均匀分布:
library(rjags)
model_string <- "model{
# Likelihood:
for( i in 1 : N ) {
y[i] ~ dnegbin( l , r )
}
# Prior:
r ~ dgamma(1,1)
l ~ dunif(0,1)
}"
y <- rpois(200, 10)
model <- jags.model(textConnection(model_string),
data = list(y=y, N=length(y)))
You also have to be sure that the values of y
are non-negative integers .您还必须确保
y
的值是非负整数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.