Dirichlet参数不会在JAGS中更新

问题描述 投票:0回答:1

我试图在JAGS中运行分层Dirichlet模型,但我没有更新,必须做错事。我尝试用伽马分布近似它:

#Creating some data
set.seed(555)
cat1=rbeta(15,20,60)
cat2=rbeta(15,20,80)
cat3=rbeta(15,20,160)
cat4=1-cat1-cat2-cat3

dat_dirich=list(
  dirF=cbind(cat1, cat2, cat3, cat4),
  AL=c(1,1,1,1),
  K=4
)

require(runjags)

{
  catch_mod="model{

    for(y in 1:15){
      dirF[y,1:K]~ddirch(alpha_dirF1B[y,1:K])

      #Approximation with Gamma
      for(a in 1:K){
          alpha_dirF1B[y,a]<-P2[y,a]/sum(P2[y,1:K])
          P2[y,a]~dgamma(alpha_dirF1[a,y],1)#1 or kappa_dirF
      }
      #hierarchical structure   
      alpha_dirF1[1:K,y]~ddirch(AL*kappa_dirF)
    }
    kappa_dirF~dunif(0.1,5000)   #kappa_dirF~dlnorm(0,0.01)   
  }"
}
bayesian jags dirichlet hierarchical-bayesian
1个回答
0
投票

你必须在代码中的某个地方调用run.jags()。这看起来应该是这样的

results <- run.jags(catch_mod, data = dat_dirich, n.chains = XXX, ...)

这在runjagshttps://cran.r-project.org/web/packages/runjags/vignettes/quickjags.html)的插图中有所描述。

© www.soinside.com 2019 - 2024. All rights reserved.