| 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 |
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.
load_JAGSmodule() unload_JAGSmodule()load_JAGSmodule() unload_JAGSmodule()
This module provides the following distributions for JAGS:
PARETO TYPE I: dpar1(alpha, sigma)
PARETO TYPE II: dpar2(alpha, sigma, mu)
PARETO TYPE III: dpar3(sigma, mu, gamma)
PARETO TYPE IV: dpar4(alpha, sigma, mu, gamma)
LOMAX: dlomax(alpha, sigma)
GENERALISED PARETO: dgenpar(sigma, mu, xi)
For :
DUMOUCHEL: dmouch(sigma)
HALF CAUCHY: dhalfcauchy(sigma)
For an easier to read version of these PDF equations, see the userguide vignette.
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.
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))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))
Some basic facilities to test the distributions provided by the package module. TODO: remove and replace with d/p/q/rlomax etc
test_JAGSmodule( distribution, funtype, parameters, x, uselog = FALSE, lower = TRUE )test_JAGSmodule( distribution, funtype, parameters, x, uselog = FALSE, lower = TRUE )
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" |
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.
test_JAGSmodule("lomax", "d", c(1,1), 1) test_JAGSmodule("mouch", "p", c(1), 1)test_JAGSmodule("lomax", "d", c(1,1), 1) test_JAGSmodule("mouch", "p", c(1), 1)