使用 Jags 的多元贝叶斯建模 -Rjags

问题描述

The error obtained is shown here in this image and as well written below

> model<-jags.model(file=textConnection(model1),data=df,inits =inits)
Compiling model graph
   Resolving undeclared variables
Deleting model

Error in jags.model(file = textConnection(model1),data = df,inits = inits) : 
  RUNTIME ERROR:
Compilation error on line 4.
Cannot evaluate subset expression for mean_0

我分析的整个代码

library(rjags)
library(coda)
library(matrixStats)
library(tidyverse)
library(cowplot)
library(forecast)

data1<-data[order(nrow(data):1),]
prices<-data1[,c(5,7,9,11)]
y<-data1[,c(6,8,10,12)]


model1 <-  "model  {
  for ( i  in 100 : n )  {
      p[i,] ~ dmnorm(mean_0[],Sigma_0[1:4,1:4])
      mean_0[]<-lambda_hat[,] %*% t(y[i,])+c((p[(i-1),1]),(p[(i-1),2]),3]),4]))
      
  }
  lambda_hat~dwish(mat[1:4,1:4],4)
  Sigma_0~dwish(mat[1:4,4)
  for (j in 1:4){ for (k in 1:4){  mat[j,k] <-equals(j,k)*.1 } }

}"
params <-  c("lambda_hat")
inits <-  list("lambda_hat" = diag(1,1,1),"Sigma_0"=var(prices[1:100,]),"mat"=diag(1,1))
df<-list(p=prices,y=y,n=(dim(y)[1]-99))

model<-jags.model(file=textConnection(model1),inits =inits)
update(mod,10000,progress.bar = "none")

我在运行此特定行时遇到错误

model<-jags.model(file=textConnection(model1),inits =inits)

你能帮我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)