runjags-class | R Documentation |
Objects of class 'runjags' are produced by run.jags
, results.jags
and autorun.jags
, and contain the MCMC chains as well as all information required to extend the simulation. These are a number of utility functions associated with these objects.
## S3 method for class 'runjags'
as.mcmc(x, vars = NA, add.mutate = TRUE, ...)
## S3 method for class 'runjags'
as.mcmc.list(x, vars = NA, add.mutate = TRUE, ...)
## S3 method for class 'runjags'
as.jags(x, adapt = 1000, quiet = FALSE, ...)
## S3 method for class 'jags'
as.runjags(
jags.model,
monitor = stop("No monitored variables supplied"),
modules = runjags.getOption("modules"),
factories = runjags.getOption("factories"),
jags = runjags.getOption("jagspath"),
mutate = NA,
check = TRUE,
...
)
is.runjags(x)
cleanup.jags(all.folders = FALSE, silent = FALSE)
cleanup.JAGS(all.folders = FALSE, silent = FALSE)
failed.jags(show = c("model", "output"))
as.jags(x, adapt = 1000, quiet = FALSE, ...)
## Default S3 method:
as.jags(x, ...)
as.runjags(jags.model, ...)
## Default S3 method:
as.runjags(jags.model, ...)
## S3 method for class 'runjags'
residuals(
object,
variable = object$residual,
show.summary = FALSE,
output = "mean",
...
)
## S3 method for class 'runjags'
fitted(
object,
variable = object$fitted,
show.summary = FALSE,
output = "mean",
...
)
x |
an object of class runjags. |
vars |
an optional character vector of variable names to extract. If supplied, only variable names in the object supplied with a partial match to anything in 'vars' will be summarised/plotted/extracted. Note that regular expressions are not allowed, but the caret (^) token can be used to specify the match at the start of a variable name, and a quoted vars will be matched exactly. Default NA meaning all variables available are returned. |
add.mutate |
option to use the inbuild mutate function to produce additional MCMC variables before returning the MCMC object. |
... |
additional options to be passed to default methods or additional functions. |
adapt |
as for |
quiet |
as for |
jags.model |
a model produced by |
monitor |
a character vector of the names of variables to monitor, as for |
modules |
a character vector of external modules to be loaded into JAGS, either as the module name on its own or as the module name and status separated by a space, for example 'glm on'. |
factories |
a character vector of factory modules to be loaded into JAGS. Factories should be provided in the format '\<facname\> \<factype\> \<status\>' (where status is optional), for example: factories='mix::TemperedMix sampler on'. You must also ensure that any required modules are also specified (in this case 'mix'). |
jags |
the system call or path for activating JAGS. Default uses the option given in |
mutate |
either a function or a list with first element a function and remaining elements arguments to this function that can be used to add variables to the model output. See |
check |
option to check that the model can be (re)-compiled. |
all.folders |
option to remove ALL simulation folders created using keep.jags.files=TRUE and not just unsuccessful simulations. |
silent |
option to suppress feedback when deleting simulation folders. |
show |
which parts of the failed JAGS simulation to display - options are: 'model', 'data', 'inits', 'output', 'end.state', 'all' |
object |
an object of class runjags. |
variable |
the name of the variable within the JAGS simulation that denotes the residual/fitted variable. This must be specified to be able to use the residuals and fitted methods. |
show.summary |
option to show the full summary statistics of the returned models before extracting just the residuals/fitted variable information. |
output |
the type of output required for the residuals and fitted methods - options are: 'mean', 'mcmc', 'hpd', 'summary', 'runjags'. |
The functions and methods detailed here permit conversion of runjags objects to MCMC objects and to/from jags models created by jags.model
. There are also S3 methods for print, summary and plot available for runjags class objects - see add.summary
for details of the arguments available to these.
The 'failed.jags' function allows the user to interrogate the details of JAGS models that failed to compile or produce MCMC output. By default, any simulation folders for models that failed to import are kept until the R session is ended - in some circumstances it may be possible to partially recover the results using results.jags
. The cleanup.jags function can be used to remove simulation folders created in the current R session, and is called when the runjags package is unloaded.
add.summary
for details on plot, print and summary methods for runjags class objects, extract.runjags
for a method to extract peripheral information from runjags objects, runjags.options
for general options available, and run.jags
and autorun.jags
for the functions that create objects of this class.
if(require('rjags')){
# Coercion between jags and runjags objects (requires loading the rjags package):
data(LINE)
jags.model <- LINE
runjags.model <- as.runjags(jags.model, monitor=c('alpha','beta'))
## Not run:
runjags.model <- extend.jags(runjags.model)
jags.model <- as.jags(runjags.model)
# Coercion to MCMC (requires loading the coda package):
library('coda')
mcmc <- as.mcmc.list(runjags.model)
summary(mcmc)
## End(Not run)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.