schools <- read.table ("schools.dat", header=TRUE)
J <- nrow(schools)
y <- schools$estimate
sigma.y <- schools$sd
data <- list ("J", "y", "sigma.y")
inits <- function() {list (theta=rnorm(J,0,100), mu.theta=rnorm(1,0,100), sigma.theta=runif(1,0,100))}
parameters <- c("theta", "mu.theta", "sigma.theta")
schools.sim <- bugs(data, inits, parameters, "schools.bug", n.chains=3, n.iter=1000) (这句总是提示错误!说Error in eval.with.vis(expr, envir, enclos) : could not find function "bugs",数据在附件中,请高手指教!)
print (schools.sim)
plot (schools.sim)
附件列表
WinBUG.zip
大小:1.42 KB
马上下载
本附件包括:
- schools.dat
- schools.R
- schools.txt
- schools.bug