JAGSrun {bayesmix}R Documentation

MCMC sampling of Bayesian models

Description

Calls jags for MCMC sampling.

Usage

JAGSrun(y, prefix = yname, model = BMMmodel(k = 2),
        control = JAGScontrol(variables = c("mu", "tau", "eta")), tmp = TRUE,
        cleanup = TRUE, jags = getOption("jags.exe"), ...)

Arguments

y a numeric vector.
prefix character prefix of files.
model object of class JAGSmodel or output from BMMmodel.
control specification of control by a JAGScontrol object.
tmp logical: shall the files be written in a temporary directory.
cleanup logical: shall the created files be removed.
jags string indicating location of jags executable.
yname a character string with the actual y argument name.
... further parameters handed over to BMMmodel where it is used for the function specifiying the initial values, e.g., initsFS.

Details

If an error occurs when runing jags, the created files are not removed. This function is a wrapper calling JAGSsetup, JAGScall and JAGSread.

Value

Returns a jags object with components

call the matched call.
results results read in from ``jags.out'' if run was successful or from ``jags.dump'' if an error occurred.
model a JAGSmodel object.
variables vector containing the names of the monitored variables.
data a numeric vector.

Author(s)

Bettina Gruen

See Also

JAGSsetup, JAGScall, JAGSread, BMMmodel, initsFS

Examples

data(fish)
prefix <- "fish"
variables <- c("mu","tau","eta")
k <- 3
modelFish <- BMMmodel(k = k, priors = list(kind = "independence",
                      parameter = "priorsFish", hierarchical = "tau"))
controlFish <- JAGScontrol(variables = c(variables, "S"), draw = 100, seed = 1)
## Installation of JAGS necessary for applying these functions
if (haveJAGS()) {
z1 <- JAGSrun(fish, prefix, model = modelFish, initialValues = list(S0 = 2),
              control = controlFish, cleanup = TRUE, tmp = FALSE)
zSort <- Sort(z1, "mu")
BMMposteriori(zSort)
}
data(darwin)
prefix <- "darwin"
k <- 2
modelDarwin <- BMMmodel(k = k, priors = list(kind = "independence",
                        parameter = "priorsUncertain"), aprioriWeights = c(1, 15),
                        no.empty.classes = TRUE, restrict = "tau")
## Installation of JAGS necessary for applying these functions
if (haveJAGS()) {
z2 <- JAGSrun(darwin, prefix, model = modelDarwin, control =
              JAGScontrol(variables = variables, draw = 3000, burnIn = 1000,
              seed = 1), cleanup = TRUE, tmp = FALSE)
plot(z2, variables = "mu")
}

[Package bayesmix version 0.6-0 Index]