On 03.10.2012 17:51, yiyiwang wrote:
Dear all I used R2WinBUGS package's bugs() function to generate MCMC results. Then I tried to save the simulation draws in R, using read.bugs() function. Here is a simple test: ###################### library(coda) library(R2WinBUGS) #fake some data to test beta0=1 beta1=1.5 beta2=-1 beta3=2 N=200 x1=rnorm(N, mean=0,sd=1) x2=rnorm(N, mean=0,sd=1) x3=rnorm(N, mean=0,sd=1) lambda2= exp(beta0+ beta1*x1+ beta2 * x2 + beta3 * x3) y=rep(NA,N) for (i in 1: N) { y[i]=rpois(1,lambda2[i]) } #generate inputs required by winbugs data <- list(Y20=y,x1=x1, x2=x2, x3=x3, N=N) inits<- function(){ list(beta0=0, beta1=0, beta2=0, beta3=0)} parameters <- c("beta0", "beta1", "beta2", "beta3") #call winbugs using bugs() function model <- bugs(data, inits, parameters, model.file="C:/Jinmodel/test_codes/model_poisson.txt", n.chains=1, n.iter=30, n.burnin=0,n.thin=1, codaPkg=TRUE, DIC=TRUE, debug=TRUE, bugs.directory="C:/Users/Yiyi/Desktop/winbugs14/WinBUGS14") ########################################### I can get pretty good traceplots & parameter estimate outputs in WinBUGS. However, when I switched back to the R Console (by pressing ESC key)
.... which is the explanation. Just close WinBUGS regularly rather than interrupting the R function that executes WinBUGS and waits for its results.
You may also want to update to a recent version of R. Best, Uwe Ligges > , a
warning message occurred: Warning message: running command '"C:/Users/Yiyi/Desktop/winbugs14/WinBUGS14/WinBUGS14.exe" /par "C:/Users/Yiyi/AppData/Local/Temp/Rtmpgdvr4Z/script.txt"' had status 93 I ignored this message & typed in the following code to save the outputs into R: ################### myres <- read.bugs(model) #################### An error message occurred: Error in is.vector(X) : object 'model' not found I've been trying to solve this mystery for several weeks but couldn't make any breakthough. Any suggestions are highly appreciated! Best, Yiyi p.s. 0) the program is running in a Windows 7 Home Premium, 64-bit operating system machine. R version: 2.13.2, WinBUGS 14 1) some old posts suggest running the software as the administrator (to kill the warning message). Can anyone shed more light on how to log in as the administrator? I am the sole user of my own laptop, not using the pc's at my office. So I doubt administrator is the issue. 2) The second time I run the bugs() function, no warning message of status 93 emerged. 3) perhaps the warning message & the error message are somehow related?? -- View this message in context: http://r.789695.n4.nabble.com/Errors-when-saving-output-from-WinBUGS-to-R-tp4644899.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.