R 및 OpenBugs에 비교적 익숙하지 않으며이 모델의 문제를 해결하는 데 많은 시간을 투자했습니다. 나는 리소스를 통해 스스로 혼자 공정한 금액을 알아낼 수 있었지만이 오류가 붙어 있습니다. 그것은 "노드 더미의 다중 정의 [1]"입니다. 온라인에서이 오류는 색인이없는 for-loop 내에서 변수를 정의하려고 시도 할 때 자주 발생하지만 변수는이를 수행합니다. 이 모델은 리소스 here을 기반으로 만들었습니다.R - OpenBugs - 노드 오류에 대한 여러 정의 - 사용자 지정 배포
나는 오류를 찾는 데 어려움을 겪고 있습니다. 아래에 나열된 코드는 내가 보는 것과 동일한 오류가 발생합니다. 또한 OpenBugs에서 본 로그 오류도 포함되었습니다. 도와 주셔서 감사합니다.
데이터 :
library(R2OpenBUGS)
n1=20 ; k1=1 ; m1=5; R.x=c(3,3,3,3,3); x=c(1.008195, 1.212885, 1.349857, 1.909607, 7.134668)
n2=20 ; k2=1 ; m2=5; R.y=c(3,3,3,3,3); y=c(0.7507421, 1.3103649, 1.5022302, 1.7875087, 3.1900460)
모델 :
mtemp<-function(){
for (i in 1:m1)
{
dummyx[i]<-0
dummyx[i] ~ dloglik(logLikex[i])
logLikex[i] <- -log(a)-log(c)-(c-1.0)*log(x[i])+(a*k1*(R.x[i]+1.0)+1.0)*log(1.0 + pow(x[i],c))
for(j in 1:m2){
dummyy[j]<-0
dummyy[j] ~ dloglik(logLikey[j])
logLikey[j] <- -log(b)-log(c)-(c-1.0)*log(y[j])+(b*k2*(R.y[j]+1.0)+1.0)*log(1.0 + pow(y[j],c))
}
a ~ dgamma(0.001, 0.0001)
b ~ dgamma(0.001, 0.0001)
c ~ dgamma(0.001, 0.0001)
}
}
model.file <- file.path(tempdir(), "model.txt") #create temporary directory
write.model(mtemp, model.file) #write to temporary directory
file.show(model.file) #verify model was created
datatemp<- list("x","y","R.x","k1","m1","R.y","k2","m2")
initstemp<-function(){list(a=7.0,b=7.0,c=4.5)}
bugstemp = bugs(data=datatemp,inits=initstemp,parameters=c("a","b","c"),model.file=model.file,
n.chains=3,n.iter= 10000, n.burnin=1000,n.thin=1, debug=T)
로그 보고서 : 당신은 오히려 모델의 끝에서 (M1)의 루프 닫는 중괄호를 뒀다
model is syntactically correct
data loaded
multiple definitions of node dummyy[1]
model must have been compiled but not updated to be able to change RN generator
BugsCmds:NoCompileInits
BugsCmds:NoCompileInits
BugsCmds:NoCompileInits
model must be compiled before generating initial values
model must be initialized before updating
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before DIC can be monitored
model must be initialized before updating
model must be initialized before monitors used
DIC monitor not set