R2OpenBUGS quesion

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

R2OpenBUGS quesion

elong zhang
Dear All:

Could anybody help me figure out why I get the Error message below while I
running the example code of bugs() function in R2OpenBUGS packages? I have
tried the code both in Win 7 and Ubuntu 12.04, but they show the same
message. My R version is 2.15.1 in win7 and 2.15.0 in Ubuntu.  Many thanks !

Best,

Yilong


> schools.sim <- bugs(data, inits, parameters, model.file,+                     n.chains=3, n.iter=5000)Error in matrix(, n.sims, n.parameters) :
  invalid 'nrow' value (too large or NA)

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: R2OpenBUGS quesion

Uwe Ligges-3


On 13.07.2012 03:18, elong zhang wrote:
> Dear All:
>
> Could anybody help me figure out why I get the Error message below while I
> running the example code of bugs() function in R2OpenBUGS packages? I have
> tried the code both in Win 7 and Ubuntu 12.04, but they show the same
> message. My R version is 2.15.1 in win7 and 2.15.0 in Ubuntu.  Many thanks !


1. Please always send reproducible examples.
2. Which version of OpenBUGS and which version of R2OpenBUGS (for both
there are recent updates)

Uwe Ligges



> Best,
>
> Yilong
>
>
>> schools.sim <- bugs(data, inits, parameters, model.file,+                     n.chains=3, n.iter=5000)Error in matrix(, n.sims, n.parameters) :
>    invalid 'nrow' value (too large or NA)
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: R2OpenBUGS quesion

felix
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)
Reply | Threaded
Open this post in threaded view
|

Re: R2OpenBUGS quesion

charlie
Received the same error with OpenBUGS322 trying to run the schools example under Wine 1.5.15,  R 2.15.1,  R2OpenBUGS_3.2-1.4,  on a mac pro with Snow Leopard .  I then tried with OpenBUGS321 and it ran fine.
Reply | Threaded
Open this post in threaded view
|

Re: R2OpenBUGS quesion

Dan Polhamus
This post was updated on .
I just ran into this problem on R2OpenBUGS_3.2-1.4 using OpenBUGS v3.22 (on Mac Lion through wine).  The error is being thrown when attempting to parse the index file in bugs.sims:
index <- read.table("CODAindex.txt", header = FALSE, sep=" ")

The CODAindex file is now csv, removing the space delimiter leads to a working bugs.sims.

Regards,
Dan
Reply | Threaded
Open this post in threaded view
|

Re: R2OpenBUGS quesion

Dan Polhamus
This post has NOT been accepted by the mailing list yet.
I'm sorry, the file is tab delimited now, not comma OR space.
Dan
Reply | Threaded
Open this post in threaded view
|

Re: R2OpenBUGS quesion

Paul J Ossenbruggen
In reply to this post by charlie
I recently installed OpenBUGS322 and obtained the same error using the schools example. I suspect that I will run into difficulties with other examples. I want to download the older version but the BUGS website does not seem to have  OpenBUGS321 available any longer.

Are there patches for  OpenBUGS322 or any other location to obtain  OpenBUGS321?

Any suggestion will be greatly appreciated.

Paul
Reply | Threaded
Open this post in threaded view
|

Re: R2OpenBUGS quesion

Dan Polhamus
There is an archive link at the bottom of the downloads page from which you can grab 321.
Dan


On Wed, Feb 13, 2013 at 3:53 PM, Paul J Ossenbruggen [via R] <[hidden email]> wrote:
I recently installed OpenBUGS322 and obtained the same error using the schools example. I suspect that I will run into difficulties with other examples. I want to download the older version but the BUGS website does not seem to have  OpenBUGS321 available any longer.

Are there patches for  OpenBUGS322 or any other location to obtain  OpenBUGS321?

Any suggestion will be greatly appreciated.

Paul


If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/R2OpenBUGS-quesion-tp4636392p4658464.html
To start a new topic under R help, email [hidden email]
To unsubscribe from R2OpenBUGS quesion, click here.
NAML



--
Daniel G Polhamus, PhD
Metrum Research Group, LLC
2 Tunxis Rd, Suite 112
Tariffville, CT 06081
(888) 308-7049 ext 403