Learn R Programming

runjags (version 2.2.2-4)

load.runjagsmodule: Load the internal JAGS module provided by runjags

Description

The runjags package contains a JAGS extension module that provides several additional distributions for use within JAGS (see details below). This function is a simple wrapper to load this module. The version of the module supplied within the runjags package can only be used with the rjags package, or with the rjags or rjparallel methods within runjags. For a standalone JAGS module for use with any JAGS method (or independent JAGS runs) please see: https://sourceforge.net/projects/runjags/files/paretoprior/

Usage

load.runjagsmodule(fail = TRUE, silent = FALSE)

unload.runjagsmodule()

load.runJAGSmodule(fail = TRUE, silent = FALSE)

unload.runJAGSmodule()

Value

Invisibly returns TRUE if able to (un)load the module, or FALSE otherwise

Arguments

fail

should the function fail using stop() if the module cannot be loaded?

silent

if !fail, the function will by default print a diagnostic message if the module cannot be loaded - the silent option suppresses this message.

Details

This module provides the following distributions for JAGS:

PARETO TYPE I: dpar1(alpha, sigma) $$ p(x) = \alpha \sigma^{\alpha} x^{-\left(\alpha+1 \right)} $$

$$\alpha > 0, \sigma > 0, x > \sigma$$

PARETO TYPE II: dpar2(alpha, sigma, mu)

$$ p(x) = \frac{\alpha}{\sigma} \left( \frac{\alpha + x - \mu}{\sigma}\right)^{-\left(\alpha+1\right)} $$

$$\alpha > 0, \sigma > 0, x > \mu$$

PARETO TYPE III: dpar3(sigma, mu, gamma)

$$ p(x) = \frac{\frac{x-\mu}{\sigma}^{\frac{1}{\gamma}-1} \left(\frac{x-\mu}{\sigma}^{\frac{1}{\gamma}} +1\right)^{-2}}{\gamma \sigma} $$

$$\sigma > 0, \gamma > 0, x > \mu$$

PARETO TYPE IV: dpar4(alpha, sigma, mu, gamma)

$$ p(x) = \frac{\alpha \frac{x-\mu}{\sigma}^{\frac{1}{\gamma}-1} \left(\frac{x-\mu}{\sigma}^{\frac{1}{\gamma}} +1\right)^{-\left(\alpha+1\right)}}{\gamma \sigma} $$

$$\alpha > 0, \sigma > 0, \gamma > 0, x > \mu$$

LOMAX: dlomax(alpha, sigma)

$$ p(x) = \frac{\alpha}{\sigma} \left(1 + \frac{x}{\sigma}\right)^{-\left(\alpha+1\right)} $$

$$\alpha > 0, \sigma > 0, x > 0$$

GENERALISED PARETO: dgenpar(sigma, mu, xi)

$$ p(x) = \frac{1}{\sigma} \left(1 + \xi \left(\frac{x-\mu}{\sigma}\right)\right)^{-\left(\frac{1}{\xi}+1\right)} $$

For \(\xi=0\):

$$ p(x) = \frac{1}{\sigma} e^{\frac{-\left(x-\mu\right)}{\sigma}} $$

$$\sigma > 0, x > \mu$$

DUMOUCHEL: dmouch(sigma)

$$ p(x) = \frac{\sigma}{\left(x+\sigma\right)^2} $$

$$\sigma > 0, x > 0$$

HALF CAUCHY: dhalfcauchy(sigma)

$$ p(x) = \frac{2 \sigma}{\pi \left(x^2+\sigma^2\right)} $$

$$\sigma > 0, x > 0$$

For an easier to read version of these PDF equations, see the userguide vignette.

References

Denwood, M.J. 2016. runjags: An R Package Providing Interface Utilities, Model Templates, Parallel Computing Methods and Additional Distributions for MCMC Models in JAGS. J. Stat. Softw. 71. doi:10.18637/jss.v071.i09.

See Also

runjags-class, load.module

Examples

Run this code
# Load the module for use with any rjags model:
available <- load.runjagsmodule(fail=FALSE)
if(available){
# A simple model to sample from a Lomax distribution.
# (Requires the rjags or rjparallel methods)
m <- "model{
 L ~ dlomax(1,1)
		}"
if (FALSE) {
results <- run.jags(m, monitor="L", method="rjags", modules="runjags")
}
}

Run the code above in your browser using DataLab