[R] R2OpenBUGS quesion

felix danbeav at hotmail.com
Sun Aug 26 16:44:57 CEST 2012


I haven't seen any further discussion to this issue beyond Uwe's response
below, so I think I have something to add:

I'm having this same issue using the standard R2OpenBUGS schools example
(below). I find that I get the 'nrow' error when I use OpenBUGS 3.2.2, but
when I use OpenBUGS version 3.2.1 the script executes as expected. I'm using
R2OpenBUGS 3.2-1.4 on a Mac Lion OS calling from R 2.15.0 GUI 1.51 Leopard
build 32-bit (6148) using WINE. This might be a communication issue between
R2OpenBUGS and OpenBUGS 3.2.2, but I'm a Mac newbie so I assumed it was a
user error initially.

If you need a quick fix, try v3.2.1 and see if that doesn't fix things.

db


#Load the OpenBUGS Package - make sure XQuartz is running
library(R2OpenBUGS)

#schools data in the R2OpenBUGS library
data(schools)

#define the model
nummodel <- function(){
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)
}

# write the model code out to a file
write.model(nummodel, "nummodel.txt")
model.file1 = paste(getwd(),"nummodel.txt", sep="/")

#prepare the data for input into OpenBUGS
J <- nrow(schools)
y <- schools$estimate
sigma.y <- schools$sd
data <- list ("J", "y", "sigma.y")

#initialization of variables
inits <- function(){
    list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), sigma.theta
= runif(1, 0, 100))}

#set the WINE working directory and the directory to OpenBUGS - change the
OpenBUGS.exe location as necessary
WINE="/opt/local/bin/wine"
WINEPATH="/opt/local/bin/winepath"
OpenBUGS.pgm="/Users/[username]/.wine/drive_c/Program
Files/OpenBUGS/OpenBUGS322/OpenBUGS.exe"

#these are the parameters to save
parameters = c("theta", "mu.theta", "sigma.theta")

#run the model
schools.sim <- bugs(data, inits, model.file =
model.file1,parameters=parameters,n.chains = 3, n.iter = 20000,
OpenBUGS.pgm=OpenBUGS.pgm, WINE=WINE, WINEPATH=WINEPATH,useWINE=T)




--
View this message in context: http://r.789695.n4.nabble.com/R2OpenBUGS-quesion-tp4636392p4641343.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list