I am trying to run WinBUGS from R, using an example from an introductory text. Actually, I am using the same example and having a very similar problem to this guy:
but I am getting a different error message and the suggestions in this thread (e.g. run R as an administrator, define the BUGS directory) have not worked.
My computer is owned by my university, so I suspect that some problem with permissions is at fault. I originally had WinBUGS installed in the Program Files folder, but I tried with it installed in my Users folder instead after reading this site. I got the same error message regardless.
Here is the warning message I get:
Warning message: running command '"C:/Users/crowe106/WinBUGS14/WinBUGS14.exe" /par "C:/Users/crowe106/Desktop/School Stuff/R/WinBUGS/script.txt"' had status 28462
WinBUGS runs, but R crashes and the object out is not created. Does anyone know what status 28462 means?
Thanks for the help.
Chris
Here is the code:
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")
I originally ran it without the bugs.directory line and got the same error message.