데이터 블록 및 데이터 = 인수가있는 모든 모델에서 run.jags()에서 직관력이 떨어집니다. 실제 모델에서는 run.jags에 데이터 인수를 사용하지만 데이터 블록에서 사용 된 모든 것이 있는지 환경을 검색하는 것으로 보입니다. 내가 호출 환경에서 변수 "Y"를 만들 경우, 그러나run.jags 데이터 검색 환경
> run.jags('trivial.jags',data=list(y=c(5,5,5,6)),monitor=c('ylen','mu'))
Error: The following error was obtained while attempting to parse the data:
Error in eval(expr, envir, enclos) : object 'y' not found
: 내가 지금처럼 실행하면
data {
ylen <- length(y)
}
model {
for (i in 1:ylen) {
y[i] ~ dnorm(mu,1)
}
mu ~ dnorm(0,1/10^2)
}
, 나는 오류가 발생 : 여기에 아주 간단한 모델의 예입니다 그것은 사용되지만, 아주 이상한 방법 :
> y<-c(-1,-1,-1)
> run.jags('trivial.jags',data=list(y=c(5,5,5,6)),monitor=c('ylen','mu'))
Compiling rjags model...
Calling the simulation using the rjags method...
Note: the model did not require adaptation
Burning in the model for 4000 iterations...
|**************************************************| 100%
Running the model for 10000 iterations...
|**************************************************| 100%
Simulation complete
Calculating summary statistics...
Note: The monitored variable 'ylen' appears to be non-stochastic; it will not be included
in the convergence diagnostic
Calculating the Gelman-Rubin statistic for 2 variables....
Finished running the simulation
JAGS model summary statistics from 20000 samples (chains = 2; adapt+burnin = 5000):
Lower95 Median Upper95 Mean SD Mode MCerr MC%ofSD SSeff AC.10 psrf
ylen 3 3 3 3 0 3 -- -- -- -- --
mu 3.8339 4.9742 6.0987 4.9747 0.57625 -- 0.0040089 0.7 20661 0.011 1.0001
그래서 당신은 3에 도착, 길이를 계산하는 호출 환경에서 Y를 사용하는 것으로 나타나지만 데이터에서 y 값을 사용하는 것을 볼 수있다 실제 데이터 목록, mu = 5에 도착했다.
rjags를 사용하면 실제 모델과 데이터 블록의 파생 변수 계산에 data = 인수를 사용하여 예상대로 작동합니다.
이것은 runjags의 버그입니까? 데이터 블록의 계산을 위해 run.jags()에 data = 인수를 사용하려면 어떻게해야합니까?
난에이 시도 runjags_2.0.3-2 및 runjags_2.0.4-2
감사합니다! 버그 호환성을 필요로하지 않기 때문에 read.jagsfile()의 호출을 데이터 블록을 파싱하는 winbugs.extract *로 제거했습니다. 이 문제를 해결할 다음 릴리스까지는 저를 데려 가야합니다. –
그래, 그 또한 작동합니다! –