BRugs {BRugs} | R Documentation

## Introduction to BRugs

### Description

This manual describes how to use the BRugs software

### Usage

    help.BRugs(browser = getOption("browser"))

### Arguments

`browser` | the name of the program to be used as hypertext browser. It should be in the PATH, or a full path specified.

### Details

BRugs is a collection of R functions that allow users to analys graphical models using MCMC techniques. Most of the R functions in BRugs provide a interface to the BRugs dynamic link library (shared object file). The BRugs dynamic link library is able to make use of many of the WinBUGS components, in particular those components concerned with graphical models and MCMC simulation. BRugs lacks the GUI interface of WinBUGS but is able to use R to create graphical displays of the MCMC simulation. BRugs uses the same model specification language as WinBUGS and the same format for data and initial values. However BRugs always uses plain text files for input inplace of WinBUGS compound documents. The BRugs functions can be split into two groups: those associated with setting up and simulating the graphical model and those associated with making statistical inference. In general the R functions in BRugs correspond to the command buttons and and text entry fields in the menus of WinBUGS. Each WinBUGS text entry field splits into two R functions, one to set the quantity and the other to get the value of the quantity.

Andrew Gelman suggests to use the function `bugs` in the R2WinBUGS package with argument `program="openbugs"` as a wrapper.

### Permission and Disclaimer

BRugs is released under the GNU GENERAL PUBLIC LICENSE. For details see http://mathstat.helsinki.fi/openbugs/ or type `help.BRugs()`.

More informally, potential users are reminded to be extremely careful if using this program for serious statistical analysis. We have tested the program on quite a wide set of examples, but be particularly careful with types of model that are currently not featured. If there is a problem, BRugs might just crash, which is not very good, but it might well carry on and produce answers that are wrong, which is even worse. Please let us know of any successes or failures.

### See Also

`help.WinBUGS` and the meta function `BRugsFit`

### Examples

    ###    Step by step example:    ###
    library(BRugs) # loading BRugs

    ## Now setting the working directory to the examples' one:
    oldwd <- getwd()
    setwd(system.file("OpenBUGS", "Examples", package="BRugs"))

    ## some usual steps (like clicking in WinBUGS):
    modelCheck("ratsmodel.txt")          # check model file
    modelData("ratsdata.txt")            # read data file
    modelCompile(numChains=2)            # compile model with 2 chains
    modelInits(rep("ratsinits.txt", 2))  # read init data file
    modelUpdate(1000)                    # burn in
    samplesSet(c("alpha0", "alpha"))     # alpha0 and alpha should be monitored
    modelUpdate(1000)                    # 1000 more iterations ....

    samplesStats("*")                    # the summarized results

    ## some plots
    samplesHistory("*", mfrow = c(4, 2)) # plot the chain,
    samplesDensity("alpha")              # plot the densities,
    samplesBgr("alpha[1:6]")             # plot the bgr statistics, and
    samplesAutoC("alpha[1:6]", 1)        # plot autocorrelations of 1st chain

    ## switch back to the previous working directory:
    setwd(oldwd)
    ## Not run:
    # Getting more (online-)help:
    help.BRugs()
    ## End(Not run)

[Package BRugs version 0.3-2 Index]