- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 BUGS 编写狄利克雷多项式模型。
基本上我有 18 个区域和每个区域 3 个类别。例如,
区域 1:0.50 属于低,0.30 属于中,0.20 属于高。列表当然以不同的比例继续到区域 18。我得到的唯一代码是这个
`model {
for (i in 1:N) {
x[1:3] ~ dmulti(p[],n[i])
p[1:3] ~ ddirch(alpha[])
}
for (k in 1:3) {
alpha[k] <- 1
}
}
DATA list(n=c(38483, 2259, 1900),x=c(29256.42719, 1857.431404, 1548.007808, 29256.42719, 1857.431404, 1548.007808, 29256.42719, 1857.431404, 1548.007808), N=3)`
最佳答案
这可能会有所帮助( source ):
Learning about the parameters of a Dirichlet distribution
Suppose as part of a model there are J probability arrays p[j, 1:K], j = 1, ..., J, where K is the dimension of each array and sum(p[j, 1:K]) = 1 for all j. We give each of them a Dirichlet prior:
p[j, 1:K] ~ ddirch(alpha[])
and we would like to learn about alpha[]. However, the parameters alpha[] of a Dirichlet distribution cannot be stochastic nodes. The trick is to note that if delta[k] ~ dgamma(alpha[k], 1), then the vector with elements delta[k] / sum(delta[1:K]), k = 1, ..., K, is Dirichlet with parameters alpha[k], k = 1, ..., K. So the following construction should allow learning about the parameters alpha[]:
for (k in 1:K) {
p[j, k] <- delta[j, k] / sum(delta[j,])
delta[j, k] ~ dgamma(alpha[k], 1)
}A prior can be put directly on the alpha[k]'s.
关于bayesian - 狄利克雷多项式 WinBUGS 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24349692/
我是一名优秀的程序员,十分优秀!