Package 'JAGSmodule'

Title: Minimal Example of a JAGS Module
Description: This R package shows how to configure a JAGS extension module for compatibility with the new (as of October 2026) facilities within rjags.
Authors: Matthew Denwood [aut, cre]
Maintainer: Matthew Denwood <[email protected]>
License: GPL (>= 2)
Version: 0.9.0-4
Built: 2026-10-14 18:49:31 UTC
Source: https://github.com/mdenwood/JAGSmodule

Help Index


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). For now, this is duplicated within the JAGSmodule package for testing and demonstration purposes.

Usage

load_JAGSmodule()

unload_JAGSmodule()

Details

This module provides the following distributions for JAGS:

PARETO TYPE I: dpar1(alpha, sigma)

p(x)=ασαx−(α+1)p(x) = \alpha \sigma^{\alpha} x^{-\left(\alpha+1 \right)}

α>0,σ>0,x>σ\alpha > 0, \sigma > 0, x > \sigma

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

p(x)=ασ(α+x−μσ)−(α+1)p(x) = \frac{\alpha}{\sigma} \left( \frac{\alpha + x - \mu}{\sigma}\right)^{-\left(\alpha+1\right)}

α>0,σ>0,x>μ\alpha > 0, \sigma > 0, x > \mu

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

p(x)=x−μσ1γ−1(x−μσ1γ+1)−2γσp(x) = \frac{\frac{x-\mu}{\sigma}^{\frac{1}{\gamma}-1} \left(\frac{x-\mu}{\sigma}^{\frac{1}{\gamma}} +1\right)^{-2}}{\gamma \sigma}

σ>0,γ>0,x>μ\sigma > 0, \gamma > 0, x > \mu

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

p(x)=αx−μσ1γ−1(x−μσ1γ+1)−(α+1)γσ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}

α>0,σ>0,γ>0,x>μ\alpha > 0, \sigma > 0, \gamma > 0, x > \mu

LOMAX: dlomax(alpha, sigma)

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

α>0,σ>0,x>0\alpha > 0, \sigma > 0, x > 0

GENERALISED PARETO: dgenpar(sigma, mu, xi)

p(x)=1σ(1+ξ(x−μσ))−(1ξ+1)p(x) = \frac{1}{\sigma} \left(1 + \xi \left(\frac{x-\mu}{\sigma}\right)\right)^{-\left(\frac{1}{\xi}+1\right)}

For ξ=0\xi=0:

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

σ>0,x>μ\sigma > 0, x > \mu

DUMOUCHEL: dmouch(sigma)

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

σ>0,x>0\sigma > 0, x > 0

HALF CAUCHY: dhalfcauchy(sigma)

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

σ>0,x>0\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

load.pkg.module

Examples

library("rjags")
# The JAGS module is loaded when the package is attached:
list.modules()
# But can be unloaded:
unload_JAGSmodule()
list.modules()
# And re-loaded:
load_JAGSmodule()
list.modules()

# A simple model using the package module:
m <- "model{ L ~ dlomax(1,1) }"
jags.model(textConnection(m))

Load the internal JAGS module provided by runjags

Description

Some basic facilities to test the distributions provided by the package module. TODO: remove and replace with d/p/q/rlomax etc

Usage

test_JAGSmodule(
  distribution,
  funtype,
  parameters,
  x,
  uselog = FALSE,
  lower = TRUE
)

Arguments

distribution

One of lomax, mouch, genpar of halfcauchy

funtype

One of d, p or q

parameters

a vector of parameters

x

the x (for funtype="d"), q (for funtype="p"), or p (for funtype="q") value to use in the distribution

uselog

should the probability be returned (or given) on the log axis?

lower

ignored for funtype="d"

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

load_JAGSmodule

Examples

test_JAGSmodule("lomax", "d", c(1,1), 1)
test_JAGSmodule("mouch", "p", c(1), 1)