Hamiltonian Monte Carlo (HMC)

Functions and helpers for fitting models using the MCMC algorithm HMC. Also exported is the leapfrog function, largely for pedagogical purposes.

hmc()

Fit a generic model using Hamiltonian Monte Carlo (HMC)

hmc.fit()

Fitter function for Hamiltonian Monte Carlo (HMC)

leapfrog()

Leapfrog Algorithm for Hamiltonian Monte Carlo

Metropolis-Hastings (MH)

Functions and helpers for fitting models using the MCMC algorithm MH. Also includes functions to facilitate the random walk Metropolis algorithm using a multivariate normal proposal.

mh()

Fit a generic model using Metropolis-Hastings (MH)

mh.fit()

Fitter function for Metropolis-Hastings (MH)

qfun()

Multivariate Normal Density of Theta1 | Theta2

qprop()

Simulate from Multivariate Normal Density for Metropolis Algorithm

Plotting functions from the bayesplot package

Use bayesplot to assess fit explore the posterior distributions of HMC and MH models. Includes functions for plotting Rhat statistics, effective sample sizes, histograms, density plots, trace plots, and autocorrelation, among other functions.

mcmc_intervals() mcmc_areas() mcmc_hist() mcmc_hist_by_chain() mcmc_dens() mcmc_scatter() mcmc_hex() mcmc_pairs() mcmc_acf() mcmc_acf_bar() mcmc_trace() mcmc_rhat() mcmc_rhat_hist() mcmc_neff() mcmc_neff_hist() mcmc_neff_data() mcmc_violin()

Plotting for MCMC visualization and diagnostics provided by bayesplot package

plot(<hmclearn>)

Plot Histograms of the Posterior Distribution

Summary Statistics from MCMC Simulations

Functions to summarize and predict using the simulated posterior distribution

summary(<hmclearn>)

Summarizing HMC Model Fits

coef(<hmclearn>)

Extract Model Coefficients

predict(<hmclearn>)

Model Predictions for HMC or MH

MCMC diagnostics

Functions for some standard MCMC diagnostics. Includes effective sample size, potential scale reduction factor (or Rhat), , and diagnostic plots that can be used to compare results from this package to fitting models using other techniques.

neff()

Effective sample size calculation

neff(<hmclearn>)

Effective sample size calculation

psrf()

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

psrf(<hmclearn>)

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

diagplots()

Diagnostic plots for hmclearn

diagplots(<hmclearn>)

Diagnostic plots for hmclearn

Sample Linear Regression Functions for Use in hmclearn

Includes log posterior and gradient functions for Linear, Logistic, and Poisson regression models, as well as Mixed Effect models. Functions starting g_ are gradient functions.

linear_posterior() g_linear_posterior() logistic_posterior() g_logistic_posterior() poisson_posterior() g_poisson_posterior() lmm_posterior() g_lmm_posterior() glmm_bin_posterior() g_glmm_bin_posterior() glmm_poisson_posterior() g_glmm_poisson_posterior()

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

Sample Data

Included data sets to practice fitting models using HMC

Drugs

Student Drug Usage Dataset

Endometrial

Endometrial Cancer Dataset

Gdat

Count of Fresh Gopher Tortoise Shells