| Title: | Truncated Harmonic Mean Estimator of the Marginal Likelihood |
|---|---|
| Description: | Implements the truncated harmonic mean estimator (THAMES) of the reciprocal marginal likelihood using posterior samples and unnormalized log posterior values via reciprocal importance sampling. Metodiev, Perrot-Dockès, Ouadah, Irons, Latouche, & Raftery (2024). Bayesian Analysis. <doi:10.1214/24-BA1422>. |
| Authors: | Nicholas J. Irons [aut, cre] (ORCID: <https://orcid.org/0000-0002-9720-8259>), Marie Perrot-Dockès [aut], Martin Metodiev [aut] |
| Maintainer: | Nicholas J. Irons <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.2 |
| Built: | 2026-05-11 07:38:06 UTC |
| Source: | https://github.com/cran/thames |
This function computes the THAMES estimate of the reciprocal log marginal likelihood using posterior samples and unnormalized log posterior values.
thames( lps = NULL, params, n_samples = NULL, d = NULL, radius = NULL, p = 0.025, q = 1 - p, lp_func = NULL, bound = NULL, n_simuls = 1e+05 )thames( lps = NULL, params, n_samples = NULL, d = NULL, radius = NULL, p = 0.025, q = 1 - p, lp_func = NULL, bound = NULL, n_simuls = 1e+05 )
lps |
vector of unnormalized log posterior values of length n_samples (sum of the log prior and the log likelihood) |
params |
matrix of parameter posterior samples of dimension n_samples * d |
n_samples |
integer, number of posterior samples |
d |
integer, dimension of parameter space |
radius |
positive number, radius to use for defining the ellipsoid A |
p |
percentile, used for lower bound of confidence interval |
q |
percentile, used for upper bound of confidence interval |
lp_func |
function to compute unnormalized log posterior values |
bound |
function calculating membership of a point in the posterior support |
n_simuls |
integer, number of Monte Carlo simulations to use in the bounded parameter correction calculation. |
Returns a named list with the following elements:
Metodiev M, Perrot-Dockès M, Ouadah S, Irons N. J., Latouche P., Raftery A. E. (2024) Easily Computed Marginal Likelihoods from Posterior Simulation Using the THAMES Estimator. Bayesian Analysis.
mu_star = 1 n <- 50 Y = rnorm(n, mu_star, 1) sig2 <- 1 sig2_n <- 1/(n+1/sig2) mn <- sum(Y)/(n + 1/sig2) params <- rnorm(20, mean=mn, (sig2_n)) lps <- sapply(params, function(i){ sum(dnorm(Y,i,1,log = TRUE)) + dnorm(i,0,sig2, log = TRUE)}) thames(lps, params)mu_star = 1 n <- 50 Y = rnorm(n, mu_star, 1) sig2 <- 1 sig2_n <- 1/(n+1/sig2) mn <- sum(Y)/(n + 1/sig2) params <- rnorm(20, mean=mn, (sig2_n)) lps <- sapply(params, function(i){ sum(dnorm(Y,i,1,log = TRUE)) + dnorm(i,0,sig2, log = TRUE)}) thames(lps, params)