[R] Making R talk to Win/OpenBUGS in Linux (again)

Paul Johnson pauljohn32 at gmail.com
Fri May 5 05:38:16 CEST 2006


Wow! That was quick.

One more thing would make my R2WinBUGS experience more perfect.  I
wish the "bugs" function explained how the user can write out the
model.txt file from within the R code itself, rather than taking the
current advice of creating it separately. The process now escribed in
"bugs" is:

   1.  Write a WinBUGS model in a ASCII file.
   2.  Go into R.

I don't know what the best way to create model.txt might be, but this
does work, and maybe you have even better examples to show:

myTextExample <- c("  model {
       for (j in 1:J){
         y[j] ~ dnorm (theta[j], tau.y[j])
         theta[j] ~ dnorm (mu.theta, tau.theta)
         tau.y[j] <- pow(sigma.y[j], -2)
       }
       mu.theta ~ dnorm (0.0, 1.0E-6)
       tau.theta <- pow(sigma.theta, -2)
       sigma.theta ~ dunif (0, 1000)
     }
")

 zz <- file("model.txt","w")
 writeLines(myTextExample,con=zz)
 close(zz)

The only dicey part here is that the user might save the model in the
wrong directory, but I don't see what prevents that with the current
advice in "bugs"

I suggest this because it allows the creation of one file working
examples in R2WinBUGS.  For the teaching objective, this simplifies
things a lot!

So long,  and thanks for all the fish

pj



On 5/4/06, Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote:
> Paul Johnson wrote:
>
> > Hello, and thanks for the many very rapid responses to my requests for
> > R/WinBUGS conversation.
> >
> > I do not know how to build OpenBUGS in linux, but will snoop around
> > and see if I can't figure out what's wrong with linking R to BRugs.so.
> >
> > In the meanwhile...
> >
> > While we are on the linux/bugs topic, can I please ask for a fix in
> > R2WinBUGS? On my system, the script.txt file is written into the
> > WinBUGS directory,where the user does not ordinarily have write
> > permissions.  If script.txt could be written with the other temporary
> > files, this would be solved.
>
> Will be fixed for the next release.
> We should also add some option to disable running bugs.update.settings()
> which really requires write access in the WinBUGS directory.
>
> Uwe Ligges
>
> > pj
>
>


--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas




More information about the R-help mailing list