Learn R Programming

rbugs (version 0.5-9.1)

genBugsScript: Generating Script File for BUGS

Description

Generating a script file to run BUGS batch-mode.

Usage

genBugsScript(paramSet, n.chains, n.iter, n.burnin, n.thin, dic,
              model.file, data.file, inits.files,
              bugsWorkingDir=getwd(),
              script, debug = FALSE,
              OpenBugs=TRUE, Windows=TRUE, seed=NULL)

Arguments

paramSet

A character vector of the names of the parameter to be monitored.

n.chains

The number of chains to be monitored.

n.iter

The number of iterations of each chain.

n.burnin

The length of the burn-in.

n.thin

Thinning rate.

dic

If TRUE, dic will be monitored

model.file

A character string of the name of file which contains the model specification for BUGS. It should end with .txt to be recognizable by BUGS.

data.file

A character string of the name of the data file. It should end with .txt to be recognizable by BUGS.

inits.files

A vector of file names of initial values. They should end with .txt to be recognizable by BUGS.

bugsWorkingDir

A character string specifying the directory to store temporary files for running BUGS.

script

A character string naming the files to print the script to. It must end with .txt to be recognizable by BUGS.

debug

A logical value indicating whether or not closing the BUGS window after running the script.

OpenBugs

If TRUE, OpenBugs is used.

Windows

If TRUE, Windows plataform is used.

seed

An integer of random number seed.

Value

None.

Details

This function only write a script to script, which uses the file names of model.file, data.file, and inits.files, without actually reading them. These file names should be correct when using runBugs.

workingDir and bugsWorkingDir establish the translation between a directory native to the operating system and a directory recognizable by wine. They are the same if useWine == FALSE.

See Also

genDataFile, genInitsFile, format4Bugs

Examples

Run this code
# NOT RUN {
## no tested examples for mac-os.
# }
# NOT RUN {
script.file <- paste(tempfile("script"), ".txt", sep="")
genBugsScript(paramSet=c("alpha", "theta"), n.chains=2, n.keep=1500,
              n.burnin=500, n.thin=1,
              model.file="~/tmp/model.txt",
              data.file="~/tmp/data.txt",
              inits.file=c("~/tmp/init1.txt",
                           "~/tmp/init2.txt"),
              bugsWorkingDir=" ~/tmp/",
              script=script.file)
file.show(script.file)
unlink(script.file)
script.file <- paste(tempfile("script"), ".txt", sep="")
genBugsScript(paramSet=c("alpha", "theta"), n.chains=2, n.keep=1500,
              n.burnin=500, n.thin=1,
              model.file="c:/tmp/model.txt",
              data.file="c:/tmp/data.txt",
              inits.file=c("c:/tmp/init1.txt",
                           "c:/tmp/init2.txt"),
              bugsworkingDir="c:/tmp",
              script=script.file)
file.show(script.file)
unlink(script.file)
# }

Run the code above in your browser using DataLab