| phmc | R Documentation |
Fits Bayesian models and estimates parameters using the Proximal Hamiltonian Monte Carlo (p-HMC) algorithm for non-differentiable target densities as proposed by Shukla, Vats, and Chi (2025).
phmc(
fn,
grad_f = NULL,
g = NULL,
prox_fn = "l1",
start,
data = NULL,
n_draws = 2000,
burnin = floor(n_draws/2),
thin = 1,
epsilon = 0.01,
L = 10,
lambda_g = 0.01,
M = NULL,
tune_lambda = FALSE,
verbose = FALSE,
...
)
fn |
Function. The smooth potential component |
grad_f |
Function or |
g |
Function or |
prox_fn |
Function or character. Proximal mapping operator for
|
start |
Numeric vector or matrix. Initial parameter values. |
data |
Optional dataset passed as second argument to
|
n_draws |
Integer > 0. Total number of MCMC iterations to run (default 2000). |
burnin |
Integer >= 0. Number of initial draws to discard
as burn-in (default |
thin |
Integer >= 1. Thinning interval (default 1). |
epsilon |
Numeric scalar > 0. Leapfrog step size (default 0.01). |
L |
Integer >= 1. Number of leapfrog steps per proposal (default 10). |
lambda_g |
Numeric scalar > 0. Moreau-Yosida regularization parameter (default 0.01). |
M |
Mass matrix or |
tune_lambda |
Logical. If |
verbose |
Logical. If |
... |
Additional arguments passed to |
An object of class "phmc", which is a list containing:
draws |
A numeric matrix of class |
estimates |
A summary matrix of class |
accept_rate |
A numeric scalar of class |
ess |
A named numeric vector of class |
ess_per_sec |
A named numeric vector of class |
logLik |
A numeric scalar of class |
AIC |
A numeric scalar of class |
BIC |
A numeric scalar of class |
DIC |
A numeric scalar of class |
elapsed_time |
A numeric scalar of class |
lambda_g |
A numeric scalar of class |
call |
An object of class |
Shukla A, Vats D, Chi EC (2025). “Proximal Hamiltonian Monte Carlo.” arXiv preprint, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2510.22252")}.
set.seed(42)
y_data <- rnorm(100, mean = 1, sd = 0.5)
f_smooth <- function(x, y) 0.5 * sum((y - x)^2)
grad_f_smooth <- function(x, y) -sum(y - x)
fit <- phmc(fn = f_smooth, grad_f = grad_f_smooth,
prox_fn = "l1", start = 0.5,
data = y_data, lambda_g = 0.01,
n_draws = 500)
summary(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.