[R] R2WinBUGS Error
Hi, I'm trying to run R2WinBUGS using the R code below (Thinkpad Yoga 260, Win8, system x86_64, mingw32, R version 3.3.1). It worked fine for several times but then one error began to pop up in every run: command #Bugs:set cannot be executed (is greyed out). I've been trying for more than one week but still can't figure out where is the problem. It would be great if someone could help me with this. Thanks in advance! Kind regards, JLiu Here's the code: sink("mod1.txt") cat(" model { for( k in 1 : n ) { for( i in 1 : n - 1 ) { for( j in i + 1 : n ) { y[k , i , j] ~ dbern(p[k , i , j]) y[k , j , i] ~ dbern(p[k , j , i]) logit(p[k , i , j]) <- mu + a[i] + b[j] + g[k] + ab[i , j] + ag[i , k] + ag[j , k] logit(p[k , j , i]) <- mu + a[j] + b[i] + g[k] + ab[j , i] + ag[j , k] + ag[i , k] } } } # Compute difference ab[1,2] - ab[2,1] for Figure 3 of the paper dif12 <- ab[1 , 2] - ab[2 , 1] # Prior for the overall mean effect mu mu ~ dnorm(0, 1) # Tri-normal prior for actor, partner, rater effects (a, b, g) # with zero-sum constraints for( i in 1 : n ) { a[i] <- a1[i , 1] - mean(a1[ , 1]) b[i] <- a1[i , 2] - mean(a1[ , 2]) g[i] <- a1[i , 3] - mean(a1[ , 3]) # without zero-sum constraints will make the code run faster # for( i in 1 : n ) { # a[i] <- a1[i,1] # b[i] <- a1[i,2] # g[i] <- a1[i,3] a1[i , 1:3] ~ dmnorm(zero[1:3], S1[ , ]) } # Wishart prior for precision matrix S1 = Sigma_1-inverse # degrees of freedom nu = 3 # Om1 = nu*Identity Matrix is provided in the data list S1[1:3 , 1:3] ~ dwish(Om1[1:3 , 1:3], 3) Sig1[1:3 , 1:3] <- inverse(S1[1:3 , 1:3]) # Compute the correlations and the variances for the main effects rho1 <- Sig1[1 , 2] / sqrt(Sig1[1 , 1] * Sig1[2 , 2]) rho2 <- Sig1[1 , 3] / sqrt(Sig1[1 , 1] * Sig1[3 , 3]) rho3 <- Sig1[2 , 3] / sqrt(Sig1[3 , 3] * Sig1[2 , 2]) sig.a <- Sig1[1 , 1] sig.b <- Sig1[2 , 2] sig.g <- Sig1[3 , 3] # Standard deviation values are reported in the paper (Table 2) sd.a <- sqrt(sig.a) sd.b <- sqrt(sig.b) sd.g <- sqrt(sig.g) # A vector of zero's is needed for the mean values of some vectors for( i in 1 : 4 ) { zero[i] <- 0 } # Priors for interaction effects ab_ij and ag_ij in equation (3) of the paper for( i in 1 : n ) { # alpha_beta[i,i] is not defined in the model, just put =0 ab[i , i] <- 0 # del[i] = personal bias of subject i in reporting his tendency to establish friendship ties # The posterior distribution of del[i]'s is shown as boxplots in Figure 3 of the paper. # Side-by-side boxplots are created using Inference -> Compare menu in WinBUGS del[i] <- ag[i , i] - ag.mean[i] ag.mean[i] <- (sum(ag[i , ]) - ag[i , i]) / (n - 1) ag[i , i] ~ dnorm(0, tau.ag) } # Generate 4 pair-wise interaction parameters as Normal_4 with precision matrix S2 for( i in 1 : n - 1 ) { for( j in i + 1 : n ) { ab[i , j] <- a2[i , j , 1] ab[j , i] <- a2[i , j , 2] ag[i , j] <- a2[i , j , 3] ag[j , i] <- a2[i , j , 4] a2[i , j , 1:4] ~ dmnorm(zero[1:4], S2[ , ]) } } # Get the precision matrix of interaction parameters from the var-cov matrix Sig_2 in the paper # Note that we don't use Inv-Wishart prior for this precision matrix S2[1:4 , 1:4] <- inverse(Sig2[1:4 , 1:4]) # Now build the var-cov matrix Sig2 from variances and correlations (phi's) in equation (7) phi1 ~ dunif(-0.99, 0.99) phi2 ~ dunif(-0.99, 0.99) phi3 ~ dunif(-0.99, 0.99) phi4 ~ dunif(-0.99, 0.99) # Compute two detrminants in equations (9-10) in the paper det1 <- 1 - phi1 * phi1 - phi2 * phi2 - phi3 * phi3 + 2 * phi1 * phi2 * phi3 det2 <- 1 - phi1 * phi1 - 2 * phi2 * phi2 - 2 * phi3 * phi3 - phi4 * phi4 + 4 * phi1 * phi2 * phi3 + 4 * phi2 * phi3 * phi4 + phi1 * phi1 * phi4 * phi4 - 2 * phi2 * phi2 * phi3 * phi3 - 2 * phi1 * phi3 * phi3 * phi4 - 2 * phi1 * phi2 * phi2 * phi4 + phi2 * phi2 * phi2 * phi2 + phi3 * phi3 * phi3 * phi3 # Check if determinants are positive cons1 <- step(det1) cons2 <- step(det2) # Zeros trick O1 <- 0 O2 <- 0 q1 <- 1 - cons1 q2 <- 1 - cons2 O1 ~ dbern(q1) O2 ~ dbern(q2) # Inverse Gamma priors for variance parameters sig.ab, sig.ag tau.ab ~ dgamma(100, 10) tau.ag ~ dgamma(100, 10) sig.ab <- 1 / tau.ab sig.ag <- 1 / tau.ag # Standard deviations sd.ab and sd.ag are reported in the paper (Table 2) sd.ab <- sqrt(sig.ab) sd.ag <- sqrt(sig.ag) Sig2[1 , 1] <- sig.ab Sig2[3 , 3] <- sig.ag Sig2[2 , 2] <- Sig2[1,1] Sig2[4 , 4] <- Sig2[3 , 3] # Create the off-diagonal entries of Sig2 # If the generated set of phi1, phi2, phi3 and phi4 values don't have both det1 > 0 # and det2 > 0, the off-diagonal elements of Sig2 are all set equal to zero Sig2[1,2] <- cons1*cons2*s
Re: [R] R2WinBUGS error
Hi Mariana, Not sure if my post was accepted. Try running R from your desktop but right clicking on the icon and selecting "Run as Administrator", rather than opening R in the normal manner. Good luck, Mark Date: Fri, 18 Sep 2015 08:43:53 -0700 From: ml-node+s789695n4712456...@n4.nabble.com To: msjit...@hotmail.com Subject: Re: R2WinBUGS error I am facing the same problem. I have been able to run my code in another computer with Windows 8 but not in my computer at work, which also runs Windowns 8. I am looking forward for solving this problem. Mariana. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/R2WinBUGS-error-tp4705613p4712456.html To unsubscribe from R2WinBUGS error, click here. NAML -- View this message in context: http://r.789695.n4.nabble.com/R2WinBUGS-error-tp4705613p4712495.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] R2WinBUGS error
Hi Mariana, I was not able to solve this issue entirely satisfactorily, but after speaking to IT personnel, they advised that I try running R from my desktop by right clicking on the R icon and selecting "Run as Administrator", rather than opening in the normal manner. Remarkably this avoided the problem that I previously encountered. I hope this works for you. Good luck, Mark -- View this message in context: http://r.789695.n4.nabble.com/R2WinBUGS-error-tp4705613p4712494.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] R2WinBUGS error
I am facing the same problem. I have been able to run my code in another computer with Windows 8 but not in my computer at work, which also runs Windowns 8. I am looking forward for solving this problem. Mariana. -- View this message in context: http://r.789695.n4.nabble.com/R2WinBUGS-error-tp4705613p4712456.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] R2WINBUGS Error message
On 18.09.2014 08:22, Hanze Zhang wrote: Hi, guys, I am a new user for package R2winbugs. When I run the code a=bugs(...), an error message always comes out, see below: Error in file(con, "wb") : cannot open the connection In addition: Warning messages: 1: In file.create(to[okay]) : cannot create file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry_Rsave.odc', reason 'Permission denied' 2: In file(con, "wb") : cannot open file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry.odc': Permission denied How to solve this issue? Run with Admin privileges or install WinBUGS in a plcce where you have write permissions. Best, Uwe Ligges Thanks a lot! [[alternative HTML version deleted]] __ 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.
[R] R2WINBUGS Error message
Hi, guys, I am a new user for package R2winbugs. When I run the code a=bugs(...), an error message always comes out, see below: Error in file(con, "wb") : cannot open the connection In addition: Warning messages: 1: In file.create(to[okay]) : cannot create file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry_Rsave.odc', reason 'Permission denied' 2: In file(con, "wb") : cannot open file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry.odc': Permission denied How to solve this issue? Thanks a lot! [[alternative HTML version deleted]] __ 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.
Re: [R] R2WinBUGS error message
On 07.02.2012 15:23, anaraster wrote: Hi! I am new to BUGS and running BUGS from R. I am trying to run a regression model from R, however I have this error message: Error in file(con, "wb") : cannot open the connection In addition: Warning messages: 1: In file.create(to[okay]) : cannot create file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry_Rsave.odc', reason 'Permission denied' 2: In file(con, "wb") : cannot open file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry.odc': Permission denied Can anyone help me out ? R2WinBUGS tries to modify the mentioned files. That is not always required, hence R2WinBUGS just tries. If it fails, it continues and you may get perfect results. If things won't work, ask your Sysadmin for write permissions on that files. Uwe Ligges I am running R2WinBUGS from a windows 7 machine. -- View this message in context: http://r.789695.n4.nabble.com/R2WinBUGS-error-message-tp4364838p4364838.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.
[R] R2WinBUGS error message
Hi! I am new to BUGS and running BUGS from R. I am trying to run a regression model from R, however I have this error message: Error in file(con, "wb") : cannot open the connection In addition: Warning messages: 1: In file.create(to[okay]) : cannot create file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry_Rsave.odc', reason 'Permission denied' 2: In file(con, "wb") : cannot open file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry.odc': Permission denied Can anyone help me out ? I am running R2WinBUGS from a windows 7 machine. -- View this message in context: http://r.789695.n4.nabble.com/R2WinBUGS-error-message-tp4364838p4364838.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.
Re: [R] R2WinBUGS: Error in bugs(program="openbugs") but not openbugs()
On 13.11.2010 18:05, Uwe Ligges wrote: I found the problem which is a scoping issue in BRugs::bugsData() and will fix it for the next release. For now, you can workaround by calling your parameters (in this case particularly beta) with a names that are different from R function names (e.g. call it beta1). Errr, nonsense: much better is to pass the data directly rather than just passing the names. Just replace the line where you define data by: data <- list(y=y, n=n, alpha=alpha, beta=beta) Best, Uwe Ligges Best wishes, Uwe On 11.11.2010 17:48, Yuelin Li wrote: I get an error when I call bugs(..., program="OpenBUGS", bugs.directory="c:/Program Files/OpenBUGS/OpenBUGS312"), expecting, as suggested in help(bugs), that it would fit the model with openbugs() via BRugs. > help(bugs) ... either winbugs/WinBUGS or openbugs/OpenBUGS, the latter makes use of function openbugs and requires the CRAN package BRugs. ... However, it works fine when I directly call openbugs(). > All other things are exactly the same. It seems that (in my settings) bugs(program="OpenBUGS") works differently than openbugs(). Am I doing something wrong with bugs()? Or there is something wrong with my OpenBUGS installation? I am using R-2.12.0, R2WinBUGS 2.1-16 (2009-11-06), OpenBUGS 3.1.2 rev 668 (2010-09-28), and BRugs 0.5-3 (2009-11-06) on a Windows XP machine. Yuelin. --- R file - require(R2WinBUGS) require(BRugs) # Example in Albert (2007). Bayesian Computation with R. Springer. # pp. 237-238. Prior = beta(0.5, 0.5), observe Binom(n, p) # y=7 successes out of a sample of n=50. Estimate p. y<- 7 n<- 50 alpha<- 1.0 beta<- 1.0 data<- list("y", "n", "alpha", "beta") inits<- function() { list(p = runif(1)) } param<- "p" # this works Albert.bugs<- openbugs(data=data, inits=inits, parameters.to.save=param, model.file = "C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500) print(Albert.bugs, digits.summary = 4) # this fails Albert.bugs<- bugs(data=data, inits=inits, parameters.to.save=param, model.file="C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500, program="OpenBUGS") --- BUGS file: Albert11.txt -- model { y ~ dbin(p, n) p ~ dbeta( alpha, beta ) } = Please note that this e-mail and any files transmitted with it may be privileged, confidential, and protected from disclosure under applicable law. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this communication or any of its attachments is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting this message, any attachments, and all copies and backups from your computer. __ 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. __ 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.
Re: [R] R2WinBUGS: Error in bugs(program="openbugs") but not openbugs()
I found the problem which is a scoping issue in BRugs::bugsData() and will fix it for the next release. For now, you can workaround by calling your parameters (in this case particularly beta) with a names that are different from R function names (e.g. call it beta1). Best wishes, Uwe On 11.11.2010 17:48, Yuelin Li wrote: I get an error when I call bugs(..., program="OpenBUGS", bugs.directory="c:/Program Files/OpenBUGS/OpenBUGS312"), expecting, as suggested in help(bugs), that it would fit the model with openbugs() via BRugs. > help(bugs) ... either winbugs/WinBUGS or openbugs/OpenBUGS, the latter makes use of function openbugs and requires the CRAN package BRugs. ... However, it works fine when I directly call openbugs(). > All other things are exactly the same. It seems that (in my settings) bugs(program="OpenBUGS") works differently than openbugs(). Am I doing something wrong with bugs()? Or there is something wrong with my OpenBUGS installation? I am using R-2.12.0, R2WinBUGS 2.1-16 (2009-11-06), OpenBUGS 3.1.2 rev 668 (2010-09-28), and BRugs 0.5-3 (2009-11-06) on a Windows XP machine. Yuelin. --- R file - require(R2WinBUGS) require(BRugs) # Example in Albert (2007). Bayesian Computation with R. Springer. # pp. 237-238. Prior = beta(0.5, 0.5), observe Binom(n, p) # y=7 successes out of a sample of n=50. Estimate p. y<- 7 n<- 50 alpha<- 1.0 beta<- 1.0 data<- list("y", "n", "alpha", "beta") inits<- function() { list(p = runif(1)) } param<- "p" # this works Albert.bugs<- openbugs(data=data, inits=inits, parameters.to.save=param, model.file = "C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500) print(Albert.bugs, digits.summary = 4) # this fails Albert.bugs<- bugs(data=data, inits=inits, parameters.to.save=param, model.file="C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500, program="OpenBUGS") --- BUGS file: Albert11.txt -- model { y ~ dbin(p, n) p ~ dbeta( alpha, beta ) } = Please note that this e-mail and any files transmitted with it may be privileged, confidential, and protected from disclosure under applicable law. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this communication or any of its attachments is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting this message, any attachments, and all copies and backups from your computer. __ 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.
[R] R2WinBUGS: Error in bugs(program="openbugs") but not openbugs()
I get an error when I call bugs(..., program="OpenBUGS", bugs.directory="c:/Program Files/OpenBUGS/OpenBUGS312"), expecting, as suggested in help(bugs), that it would fit the model with openbugs() via BRugs. > help(bugs) ... either winbugs/WinBUGS or openbugs/OpenBUGS, the latter makes use of function openbugs and requires the CRAN package BRugs. ... However, it works fine when I directly call openbugs(). All other things are exactly the same. It seems that (in my settings) bugs(program="OpenBUGS") works differently than openbugs(). Am I doing something wrong with bugs()? Or there is something wrong with my OpenBUGS installation? I am using R-2.12.0, R2WinBUGS 2.1-16 (2009-11-06), OpenBUGS 3.1.2 rev 668 (2010-09-28), and BRugs 0.5-3 (2009-11-06) on a Windows XP machine. Yuelin. --- R file - require(R2WinBUGS) require(BRugs) # Example in Albert (2007). Bayesian Computation with R. Springer. # pp. 237-238. Prior = beta(0.5, 0.5), observe Binom(n, p) # y=7 successes out of a sample of n=50. Estimate p. y <- 7 n <- 50 alpha <- 1.0 beta <- 1.0 data <- list("y", "n", "alpha", "beta") inits <- function() { list(p = runif(1)) } param <- "p" # this works Albert.bugs <- openbugs(data=data, inits=inits, parameters.to.save=param, model.file = "C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500) print(Albert.bugs, digits.summary = 4) # this fails Albert.bugs <- bugs(data=data, inits=inits, parameters.to.save=param, model.file="C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500, program="OpenBUGS") --- BUGS file: Albert11.txt -- model { y ~ dbin(p, n) p ~ dbeta( alpha, beta ) } = Please note that this e-mail and any files transmitted with it may be privileged, confidential, and protected from disclosure under applicable law. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this communication or any of its attachments is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting this message, any attachments, and all copies and backups from your computer. __ 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.