I'm trying to run some simulations in WinBUGS using R and R2WinBUGS running in Windows 7.
After I prepare all the files a and launch the function bugs() the WinBUGS windows opens but doesn't start the simulations. The same happens with older versions of R and with OpenBUGS. Is it a problem of Windows?
Here's the code:
N <- 1000 #Number of simulations
S <- 100 #Number of sites
Phi <- .4 # Occupancy probability
Occ <- array(NA, dim=c(N, S))
for (n in 1:N){
Occ[n,] <- rbinom(S, 1, Phi)
}
# Model
sink("W.txt")
cat("
model {
# priors
psi ~ dunif(0, 5)
#Model
for (i in 1:nsite) {
#Ocupation model
Z[i] ~ dbern(psi)
}
}# end of model
",fill = TRUE)
sink()
library(R2WinBUGS)
# MCMC settings
ni <- 1000
nt <- 5
nb <- 500
nc <- 5
# Parameters monitored
params <- c("psi")
#Bundle data
data <- list(Z=Occ[1,])
#Initial values
inits <- function(){list(psi =runif(1, 0, 5))}
#Lunch WinBUGS
Bugs <- bugs(data, inits, params, "W.txt", n.chains = nc, n.thin = nt, n.iter = ni, n.burnin = nb, debug=T, working.directory = getwd(), save.history=T)
print(Bugs, dig=3)
Any help would be appreciated! Cheers Mário
I've already found whats was causing the error.
My working directory was:
"E:\\Sim's"
It seems that WinBUGS doesn't work with addresses with apostrophe. I have changed it to:
"E:\\Sims"
And it worked perfectly.
Thanks.
Cheers! Mário
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.