model_likelihood: Computes the model log likelihood from MCMC posterior samples

Description Usage Arguments Details Value

Description

Computes the so-called model likelihood, that is the probability of the data given the model, P(D | M) = \int P(D | θ, M) P(θ | M) dθ, based on samples from an MCMC run. The ratio between two model likelihoods from different models is the Bayes factor and can be used for model selection.

Usage

1
model_likelihood(samples, burn.in = 0)

Arguments

samples

A data frame with the samples from an MCMC run.

burn.in

The number of samples to discard as burn-in samples.

Details

Computes the so-called model likelihood, that is the probability of the data given the model, P(D | M) = \int P(D | θ, M) P(θ | M) dθ.

Since the samples from the MCMC are from the posterior and not the prior distribution the likelihood cannot be computed simply as the mean of the likelihood – and typically that would be a very inefficient approach to computing the likelihood – so instead the harmonic mean of the likelihood sampled from the posterior is used. This follows from

\int P(θ | D, M) / P(D | θ, M) dθ = \int 1/P(D | M) [P(D | θ, M)P(θ | M)]/P(D | θ, M) dθ = 1/P(D | M)

so 1/P(D | M) = \int 1/P(D | θ, M) P(θ | D, M) dθ which is approximated from samples from the posterior P(θ | D, M).

Value

The model log-likelihood \log P(D | M).


mailund/coalhmm-analysis documentation built on May 21, 2019, 11:06 a.m.