0

I have recently started trying to do some bayesian modelling with OpenBUGS and R using R2OpenBUGS.

I followed a great link for installing wine and OpenBUGS by David Eagles and the schools example posted there worked fine.

I then tried to run some code I had and kept getting an error after the the model is syntactically correct telling me the data was not loading properly.

After a few days of troubleshooting this it seems that when the datafile is above a certain length the top bit (where you traditionally highlight list in OpenBUGS to load data) is lost and the data cannot be loaded by OpenBUGS.

A screenshot of my OpenBUGS program with the loaded data where the list section has been cut off

This picture shows that at the top of my data.txt file there is no longer a list{ which is basically stopping all of my attempts to run the model.

To confirm this I have ran the example of a simple linear regression where I set the number of points to 1000 and then to 100:

 # Load in paths for running OpenBUGS through wine
source("/Users/dp323/Desktop/R/scripts/Where_is_my_OpenBUGS.R")  

# set up model
linemodel <- function() {
  for (j in 1:N) {
    Y[j] ~ dnorm(mu[j], tau)  ## Response values Y are Normally distributed
    mu[j] <- alpha + beta * (x[j] - xbar)  ## linear model with x values centred
  }
  ## Priors
  alpha ~ dnorm(0, 0.001)
  beta ~ dnorm(0, 0.001)
  tau ~ dgamma(0.001, 0.001)
  sigma <- 1/sqrt(tau)
}

# set up data ####
linedata <- list(Y = c(1:100), x = c(1:100), N = 100, xbar = 3)

# set initial values ####
lineinits <- function() {
  list(alpha = 1, beta = 1, tau = 1)
}

# run bugs ####
lineout <- bugs(data = linedata, inits = lineinits, parameters.to.save = c("alpha", "beta", "sigma"), model.file = linemodel, n.chains = 1, n.iter = 10000, OpenBUGS.pgm = OpenBUGS.pgm, WINE = WINE, WINEPATH = WINEPATH, useWINE = T, debug = T)

The model runs great when linedata <- list(Y = c(1:100), x = c(1:100), N = 100, xbar = 3) but falls apart at the loading in data stage when linedata <- list(Y = c(1:1000), x = c(1:1000), N = 1000, xbar = 3).

I have exhausted a google search of limits of data file size on wine and OpenBUGS and not found anything helpful.

Anyone have any suggestions of what to try/where to start/experience of this before?

  • Afraid I can't help directly, but JAGS is very similar to BUGS, runs on Nix, and works well with R via rjags. http://mcmc-jags.sourceforge.net/ – effel Mar 09 '16 at 14:17
  • Thanks. I have tried jags this but the code I am trying to emulate uses the `cut()` function which jags does not currently support. Maybe in time I will work out how to alter the model but for now would like to keep it as it is. – Daniel Padfield Mar 09 '16 at 14:59
  • Oh, interesting! Here's some discussion that I imagine you've already come across: https://martynplummer.wordpress.com/2014/01/05/mcmski-2014/ http://stats.stackexchange.com/questions/22184/missing-values-in-response-variable-in-jags – effel Mar 09 '16 at 15:16

0 Answers0