jagshelper-package | R Documentation |
Functions are provided to help run Bayesian analyses in JAGS using the 'jagsUI' package. Included are functions for extracting output in simpler format, functions for streamlining assessment of convergence, and functions for producing summary plots of output. Also included is a function that provides a simple template for running JAGS from R.
Package: | jagshelper |
Type: | Package |
Version: | 0.4.0 |
Date: | 2024-10-21 |
License: | GPL-2 |
The jagshelper package is intended to extend and streamline Bayesian analysis using the 'jagsUI' package.
The skeleton function prints a template JAGS model with associated R code to the console, which can easily be copied & pasted to an R script and modified as needed.
Functions are also provided for visually assessing model convergence. In particular, tracedens_jags gives a relatively simple syntax for trace plots of a collection or subset of parameter nodes, and overlays by-chain kernel densities for visual assessment of marginal posterior shapes as well as overlap between MCMC chains. Another function that could be particularly useful to users is plotRhats, which gives a visual representation of the values of the Gelman-Rubin convergence diagnostic Rhat
(or alternately effective sample size n.eff
) for all saved parameters. This may be particularly useful in the case where a model has many saved parameters. Additionally, function traceworstRhat is a wrapper for tracedens_jags, but only produces trace plots for the parameter nodes with the worst (largest) values of Rhat
or n.eff
. Functions qq_postpred, ts_postpred, and plot_postpred provide some posterior predictive checks of a vector of data and corresponding vector (matrix, in output form) of posterior predictive samples. Function kfold provides automated k-fold or leave-one-out cross validation, giving a quick means of comparison of predictive power between candidate models.
Functions are also provided for visualizing posterior densities; in particular, the case of a vector of parameter nodes (one-dimensional in the JAGS model, giving a two-dimensional matrix of MCMC iterations). Notably, the envelope function is intended for a sequence of nodes (as in a time series), and the caterpillar function is intended for cases in which order may not matter (as in a collection of random effects). The crossplot function provides methods for bivariate plotting of two parameters, or for overlaying paired nodes of two parameter vectors.
Wrapper functions are also given for overlay of multiple such plots, as overlayenvelope and comparecat, and comparedens giving plots as vertically-oriented left- and right-facing kernel densities.
Matt Tyers
Maintainer: Matt Tyers <matttyersstat@gmail.com>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.