0

获得的错误显示在此图像中,如下所示

IE,

> 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])
       ,(p[(i-1),3]),(p[(i-1),4]))
      
  }
  lambda_hat~dwish(mat[1:4,1:4], 4)
  Sigma_0~dwish(mat[1:4,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,1),"Sigma_0"=var(prices[1:100,]),"mat"=diag(1,1,1,1))
df<-list(p=prices,y=y,n=(dim(y)[1]-99))

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

运行此特定行时出现错误。

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

你能帮帮我吗?

4

0 回答 0