thames | R Documentation |
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
)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.