Learn R Programming

hmclearn

We developed the R package hmclearn to provide users with a framework to learn the intricacies of the HMC algorithm with hands-on experience by tuning and fitting their own models, with a focus on statistical modeling in particular. The core functions in this package include the Hamiltonian Monte Carlo (HMC) algorithm itself, including functions for the leapfrog, as well as the Metropolis-Hastings (MH) algorithm.

While the core functions are included for both hmc and mh algorithms, users must provide their own functions for the log posterior and, for HMC, the gradient of the log posterior. Default values are provided for the tuning parameters. However, users will likely need to adjust the parameters for their particular applications.

Installation

The most recent hmclearn package can be installed from CRAN via

install.packages("hmclearn")

Copy Link

Version

Install

install.packages('hmclearn')

Monthly Downloads

160

Version

0.0.5

License

GPL-3

Maintainer

Samuel Thomas

Last Published

October 5th, 2020

Functions in hmclearn (0.0.5)

Drugs

Student Drug Usage Dataset
diagplots.hmclearn

Diagnostic plots for hmclearn
hmclearn-glm-posterior

Sample log posterior and gradient functions for select generalized linear models and mixed effect models
diagplots

Diagnostic plots for hmclearn
hmclearn-plots

Plotting for MCMC visualization and diagnostics provided by bayesplot package
coef.hmclearn

Extract Model Coefficients
hmc.fit

Fitter function for Hamiltonian Monte Carlo (HMC)
Endometrial

Endometrial Cancer Dataset
hmc

Fit a generic model using Hamiltonian Monte Carlo (HMC)
Gdat

Count of Fresh Gopher Tortoise Shells
mh.fit

Fitter function for Metropolis-Hastings (MH)
predict.hmclearn

Model Predictions for HMC or MH
psrf

Calculates Potential Scale Reduction Factor (psrf), also called the Rhat statistic, from models fit via mh or hmc
neff.hmclearn

Effective sample size calculation
plot.hmclearn

Plot Histograms of the Posterior Distribution
neff

Effective sample size calculation
mh

Fit a generic model using Metropolis-Hastings (MH)
summary.hmclearn

Summarizing HMC Model Fits
qprop

Simulate from Multivariate Normal Density for Metropolis Algorithm
leapfrog

Leapfrog Algorithm for Hamiltonian Monte Carlo
psrf.hmclearn

Calculates Potential Scale Reduction Factor (psrf), also called the Rhat statistic, from models fit via mh or hmc
qfun

Multivariate Normal Density of Theta1 | Theta2