GithubHelp home page GithubHelp logo

r2multibugs's Introduction

R2MultiBUGS

Build status

R2MultiBUGS is an R interface to MultiBUGS. MultiBUGS is a parallel implementation of the BUGS modelling framework.

R2MultiBUGS is a port of R2OpenBUGS for MultiBUGS. R2OpenBUGS was

originally written as R2WinBUGS by Andrew Gelman; changes and packaged by Sibylle Sturtz and Uwe Ligges. With considerable contributions by Gregor Gorjanc and Jouni Kerman. Adapted to R2OpenBUGS from R2WinBUGS by Neal Thomas.''

Installation

R2MultiBUGS requires MultiBUGS, which currently works only on Windows. (A Linux port is under preparation.) See the main MultiBUGS website for installation instructions for MultiBUGS.

The current development version of R2MultiBUGS can be installed in R using

# install.packages("devtools")
devtools::install_github("MultiBUGS/R2MultiBUGS")

Alternatively, if you have difficulties with devtools, you can download the latest auto-built Windows binary version of the package, and install in R using

install.packages("R2MultiBUGS_0.9.zip", repos = NULL, type = "win.binary")

Usage

The main functions in R2MultiBUGS are the same as R2OpenBUGS, except you specify the number of workers to be used via the n.workers argument to bugs()

# An example model file is given in:
model.file <- system.file(package='R2MultiBUGS', 'model', 'schools.txt')
# Let's take a look:
#file.show(model.file)

# Some example data (see ?schools for details):
data(schools)
schools

J <- nrow(schools)
y <- schools$estimate
sigma.y <- schools$sd
data <- list ('J', 'y', 'sigma.y')
inits <- function(){
    list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100),
         sigma.theta=runif(1, 0, 100))
}
## or alternatively something like:
# inits <- list(
#   list(theta=rnorm(J, 0, 90), mu.theta=rnorm(1, 0, 90),
#        sigma.theta=runif(1, 0, 90)),
#   list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100),
#        sigma.theta=runif(1, 0, 100))
#   list(theta=rnorm(J, 0, 110), mu.theta=rnorm(1, 0, 110),
#        sigma.theta=runif(1, 0, 110)))

parameters <- c('theta', 'mu.theta', 'sigma.theta')

## You may need to specify 'MultiBUGS.pgm'
## also you need write access in the working directory:
schools.sim <- bugs(data, inits, parameters, model.file,
    n.chains=3, n.workers = 2, n.iter=5000)
print(schools.sim)
plot(schools.sim)

r2multibugs's People

Contributors

rjbgoudie avatar snthomas99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

r2multibugs's Issues

over.relax = TRUE

Using the option "over.relax = TRUE" in R2MultiBUGS returns an error "Error in bugs.check.coda() : MultiBUGS did not run correctly".
Using debug=TRUE, MultiBUGS says "script failed in interpretation".
Using MultiBUGS directly in script mode "modelUpdate(1000,1,1000,"T")" also creates the same error.
However, directly using the MultiBUGS GUI, over relaxation is available, checking the box causes no errors and the model compiles and runs.
From my reading of the R2MultiBUGS code, it doesn't implement the request to over-relax, but nor does MultiBUGS scripting. So is this more of an issue with MultiBUGS itself?

Error occures with 'debug = TRUE' option

Using the latest build of MultiBUGS with the latest R2MultiBUGS

If 'debug = FALSE' everything seems fine, but with 'debug = FALSE' then following messages was displayed in R console:

Error in bugs.run(n.burnin, MultiBUGS.pgm, debug = debug, WINE = WINE,  : 
  Look at the log file in  D:/HONG/SLR  and
try again with 'debug=TRUE' to figure out what went wrong within MultiBUGS.

Error in bugs.run

Error in bugs.run(n.burnin, MultiBUGS.pgm, debug = debug, WINE = WINE, :
MultiBUGS did not run correctly. No log file was produced. It might help to try again with 'debug=TRUE' to figure out what went wrong within MultiBUGS.

Please suggest some solution.

Help pages missing in current release

The help page is missing in the R help and reads "There are no help pages in this package"
I'm now reading the info in the R files in this pacakge to get help info.
Please have a look into this issue, thanks.

Poor error message when a function is supplied as inits

Hi there,

I'm not sure if this issue belongs here but I'll give it a go. I've written some models and they run fine in JAGS using jagsUI from R. However, fitting the same model in Multi/OpenBUGS gives me the error:

Error in datalist[[i]]: subscript out of bounds

Google hasn't told me how to solve this... I'd like to use MultiBUGS to speed up running the models but for some reason this is happening.

Cheers,
Matt

Installation failure for latest commit (1f85d9c)

When running devtools::install_github("MultiBUGS/R2MultiBUGS") for the latest commit, my R (v3.5.1, with RStudio 1.1.456) complains:

Downloading GitHub repo MultiBUGS/R2MultiBUGS@master
from URL https://api.github.com/repos/MultiBUGS/R2MultiBUGS/zipball/master
Installing R2MultiBUGS
"C:/PROGRA~1/R/R-35~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore  \
  --quiet CMD INSTALL  \
  "C:/Users/USER/AppData/Local/Temp/RtmpWWnvPh/devtools140c586a376/MultiBUGS-R2MultiBUGS-1f85d9c"  \
  --library="C:/Users/USER/Documents/R/win-library/3.5" --install-tests 

* installing *source* package 'R2MultiBUGS' ...
** R
Error in parse(outFile) : 
  C:/Users/USER/AppData/Local/Temp/RtmpWWnvPh/devtools140c586a376/MultiBUGS-R2MultiBUGS-1f85d9c/R/bugs.script.R:193:25: unexpected ','
192:     if (!restart){
193:       "modelDistribute(",
                             ^
ERROR: unable to collate and parse R files for package 'R2MultiBUGS'
* removing 'C:/Users/USER/Documents/R/win-library/3.5/R2MultiBUGS'
In R CMD INSTALL
Installation failed: Command failed (1)

As previous commit can be installed successfully, maybe some recent modifications cause this problem.

Thanks

R2MultiBUGS always fail with "not updated to be able to change RN generator"

MultiBUGS will stop with the following message:

BugsCmds.SetDisplay('log')

BugsCmds.SetFilePath('____________.txt' ); BugsCmds.ParseGuard; BugsCmds.Parse
model is syntactically correct

BugsCmds.SetFilePath('____________.txt' ); BugsCmds.LoadDataGuard; BugsCmds.LoadData
data loaded

BugsCmds.CompileGuard; BugsCmds.specificationDialog.numChains := 2; BugsCmds.Compile
model compiled in 0 s

BugsCmds.SetRNGuard; BugsCmds.SetRNState(1)
model must have been compiled but not updated to be able to change RN generator
script failed

And if I remove the modelSetRN(1) from the generated script, then MultiBUGS can run.

Error occures with 'saveExec = TRUE'

Using the latest build of MultiBUGS with the latest R2MultiBUGS
When run with 'saveExec = TRUE', the following message appears in the MultiBUGS window:

TRAP 99  (postcondition violated)

 BugsSerialize.Externalize   [0000053EH] 
	.f	Files.File	[02B5D570H] 
	.fileName	ARRAY 1024 OF CHAR	"D:/TrialRun/SLR/bugs_model.bug"   ...
	.offsetGraph	INTEGER	1152
	.offsetMonitor	INTEGER	6137
	.offsetMutable	INTEGER	5281
	.pos	INTEGER	0
	.res	INTEGER	1
	.wr	Stores.Writer	fields
 BugsCmds.ExternalizeModel   [00002835H] 
	.fileName	ARRAY 1024 OF CHAR	"D:/TrialRun/SLR/bugs_model.bug"   ...
 BugsInterpreter.CmdInterpreter   [000003C1H] 
	.boolCmd	BugsInterpreter.RECORD	fields
	.cmd	BugsInterpreter.RECORD	fields
	.command	ARRAY 1024 OF CHAR	"BugsCmds UpdateGuard  BugsCmds E"   ...
	.guard	BugsInterpreter.RECORD	fields
	.intCmd	BugsInterpreter.RECORD	fields
	.item	Meta.Item	fields
	.item0	Meta.Item	fields
	.item1	Meta.Item	fields
	.ok	BOOLEAN	TRUE
	.realCmd	BugsInterpreter.RECORD	fields
	.res	INTEGER	0
	.s	BugsMappers.Scanner	fields
	.string	ARRAY 1024 OF CHAR	"BugsCmds UpdateGuard  BugsCmds E"   ...
	.stringCmd	BugsInterpreter.RECORD	fields
 BugsScripting.Script   [000005BCH] 
	.bugsCommand	ARRAY 1024 OF CHAR	"modelExternalize(s)"   ...
	.i	INTEGER	1
	.numPar	INTEGER	1
	.p	ARRAY 10, 1024 OF CHAR	elements
	.pascalCommand	ARRAY 1024 OF CHAR	"BugsCmds.UpdateGuard; BugsCmds.E"   ...
	.pat	ARRAY 1024 OF CHAR	"^0"   ...
	.pos	INTEGER	-1
	.pos1	INTEGER	18
	.res	INTEGER	0
	.s	BugsMappers.Scanner	fields
 BugsCmds.ScriptAction.Do   [000011A5H] 
	.a	BugsCmds.ScriptAction	[02D0EAB0H] 
	.res	INTEGER	0
 Services.Exec   [00000140H] 
	.a	Services.Action	[02D0EAB0H] 
	.t	POINTER	[68280BB0H]
 Services.IterateOverActions   [000002F2H] 
	.p	Services.Action	[02D0EAB0H] 
	.time	LONGINT	88027687
 Services.StdHook.Step   [0000034BH] 
	.h	Services.StdHook	[02B75A00H] 
 HostWindows.Idle   [000049DBH] 
	.focus	BOOLEAN	FALSE
	.tick	Controllers.TickMsg	fields
	.w	HostWindows.Window	NIL
 HostMenus.TimerTick   [00003675H] 
	.lParam	INTEGER	0
	.ops	Controllers.PollOpsMsg	fields
	.wParam	INTEGER	1
	.wnd	INTEGER	394252
 Kernel.Try   [000045F9H] 
	.a	INTEGER	394252
	.b	INTEGER	1
	.c	INTEGER	0
	.h	PROCEDURE	HostMenus.TimerTick
 HostMenus.ApplWinHandler   [00003A40H] 
	.Proc	PROCEDURE	NIL
	.hit	BOOLEAN	FALSE
	.lParam	INTEGER	0
	.message	INTEGER	275
	.res	INTEGER	0
	.s	ARRAY 256 OF CHAR	"?c????"   ...
	.w	INTEGER	63
	.wParam	INTEGER	1
	.wnd	INTEGER	394252
<system>   (pc=7717BE6AH,  fp=0063FCB0H)
<system>   (pc=77178339H,  fp=0063FD98H)
<system>   (pc=77177BEDH,  fp=0063FE14H)
<system>   (pc=771779CFH,  fp=0063FE20H)
 HostMenus.Loop   [00003DDDH] 
	.done	BOOLEAN	FALSE
	.f	SET	{0..5}
	.n	INTEGER	0
	.res	INTEGER	0
	.w	HostWindows.Window	NIL
 Kernel.Start   [000036E3H] 
	.code	PROCEDURE	HostMenus.Loop

Is this safe to use?

Hello,

Could you please confirm whether this is safe to use (reliable results) for e.g. publication and decision making projects or should we use multiBUGS directly?

BugsMaster:LinkingFailure

Hello,
I am using the package „R2MultiBUGS“ to run MultiBUGS.
While running a model, the log file showed “BugsMaster:LinkingFailure script command modelDistribute failed“
Below is the screenshot of the log file.
Could you please let me know how to fix this issue?
Multibugs_log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.