我正在尝试使用介绍性文本中的示例从R运行WinBUGS。实际上,我使用相同的例子并且对这个人有一个非常类似的问题:
但是我收到了一条不同的错误消息,这个帖子中的建议(例如以管理员身份运行R,定义了BUGS目录)都没有用。
我的电脑属于我的大学,因此我怀疑某些权限问题是错误的。我最初在Program Files文件夹中安装了WinBUGS,但是我在阅读此站点后尝试将其安装在我的Users文件夹中。无论如何,我都收到了相同的错误消息。
以下是我收到的警告信息:
警告讯息: 运行命令"" C:/Users/crowe106/WinBUGS14/WinBUGS14.exe" / par" C:/ Users / crowe106 / Desktop / School Stuff / R / WinBUGS / script.txt"'状态为28462
WinBUGS运行,但是R崩溃并且没有创建对象out。有谁知道28462的含义是什么?
感谢您的帮助。
克里斯
以下是代码:
library(R2WinBUGS) # Load the R2WinBUGS library
# Save BUGS description of the model to the working directory
sink("model.txt")
cat("
model {
#Priors
population.mean~dunif(0,5000) # Normal parameterized by precision
precision <- 1/population.variance # Precision = 1/variance
population.variance <- population.sd * population.sd
population.sd~dunif(0,100)
# Likelihood
for(i in 1:nobs) {
mass[i]~dnorm(population.mean, precision)
}
}
", fill=TRUE)
sink()
# Package all the stuff to be handed over to WinBUGS
# Bundle data
win.data <- list(mass=y1000, nobs=length(y1000))
# Function to generate starting values
inits <- function()
list(population.mean=rnorm(1,600), population.sd=runif(1,1,30))
# Parameters to be monitored (= to estimate)
params <- c("population.mean", "population.sd", "population.variance")
# MCMC settings
nc <- 3 # Number of chains
ni <- 1000 # Number of draws from posterior (for each chain)
nb <- 1 # Number of draws to discard as burn-in
nt <- 1 # Thinning rate
# Start Gibbs sampler: Run model in WinBUGS and save results in object called out
out <- bugs(data=win.data, inits=inits, parameters.to.save=params, model.file="model.txt",
n.thin=nt, n.chains=nc, n.burnin=nb, n.iter=ni, debug=TRUE, DIC=TRUE, working.directory=getwd(),
bugs.directory = "C:/Users/crowe106/WinBUGS14")
我最初在没有bugs.directory行的情况下运行它并得到了相同的错误消息。