代码如下
model
{
for(i in 1:N) {
H[i]~dnorm(mu[i],tau)
mu[i]<-1.3+a*pow((1-exp(-b*D[i])),c) }
a~ dnorm(0.0, 1.0E-6)
b~ dnorm(0.0, 1.0E-6)
c~ dnorm(0.0, 1.0E-6)
tau ~ dgamma(0.01, 0.01)
}
D=c(6.5,9.86,7.5,20.13,23.41,7.18,23.1,5.24,19.11,26.06,4.6,4.95,31.69,7.39,27.29,9.82,16.08,5.85,2.182,24.42,21.65,4.78,5.05,12.44,19.8,12.68,10.78,23,5.05,5.01,11.82,24.63,19.32,13.96,13.74),H=c(5.2,6.5,5.7,20,19.4,3.65,20.2,6.4,18.9,19.6,5.7,6.3,20.5,5.6,19.8,8.1,19.1,5.2,1.7,19.3,21.2,6.9,3.5,9.3,21.2,8.1,10.3,19.3,6.8,6.7,8.31,19,19,13.3,9.5),N=35)
data=list(D,H,N)
inits=function(){list(a=40,b=0.06,c=1.15)}
output=bugs(data,inits,model.file="output.bug",parameters=c("a","b","c"),n.chains =1,n.iter=5100,n.burnin=100,n.thin=1,bugs.directory="D/WinBUGS14/",codaPkg=FALSE)
winbugs的log:
model is syntactically correct
data loaded
compile(1)
variable N is not defined
command #Bugs:inits cannot be executed (is greyed out)
|