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, ...)

Arguments

y

a numeric vector.

prefix

character: prefix for .bug-file.

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.

yname

a character string with the actual y argument name.

...

further parameters handed over to BMMmodel where it is used for the function specifying the initial values, e.g., initsFS.

Details

This function is a wrapper calling JAGScall.

Value

Returns a JAGSrun object with components

call

the matched call.

results

MCMC results obtained by calling functionality from package rjags.

model

a JAGSmodel object.

variables

vector containing the names of the monitored variables.

data

a numeric vector.

Author(s)

Bettina Gruen

See Also

JAGScall, BMMmodel, initsFS

Examples

data("fish", package = "bayesmix")
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"), n.iter = 100)
z1 <- JAGSrun(fish, prefix, model = modelFish, initialValues = list(S0 = 2),
              control = controlFish, cleanup = TRUE, tmp = FALSE)
zSort <- Sort(z1, "mu")
BMMposteriori(zSort)

data("darwin", package = "bayesmix")
prefix <- "darwin"
k <- 2
modelDarwin <- BMMmodel(k = k, priors = list(kind = "independence",
                        parameter = "priorsUncertain"),
                        aprioriWeights = c(1, 15),
                        no.empty.classes = TRUE, restrict = "tau")
z2 <- JAGSrun(darwin, prefix, model = modelDarwin, control =
              JAGScontrol(variables = variables, n.iter = 3000,
              burn.in = 1000), cleanup = TRUE, tmp = FALSE)
plot(z2, variables = "mu")

[Package bayesmix version 0.7-6 Index]