Learn R Programming

MitISEM (version 1.2)

MargLik: Marginal Likelihood calculation using Importance Sampling and mixture of Student-\(t\) densities as candidate

Description

Calculation of marginal likelihoods using Importance Sampling, with a Mixture of Student-\(t\) candidate density. Calculated marginal likelihoods from two data samples can be used to get predictive likelihoods using PredLik.

Usage

MargLik(N=1e4,mit,KERNEL,...)

Arguments

N

integer \(> 100\) number of draws for Importance Sampling

mit

Mixture of Student-\(t\) density for the full sample, list describing the mixture of Student-t. See isMit. The mixture density can be obtained from MitISEM or SeqMitISEM

KERNEL

Posterior kernel to be approximated. See *Details*. A log argument must exist. The function must return log-density if log=TRUE.

other arguments to be passed to KERNEL

Value

list containing:

ML.mean

Marginal likelihood (posterior mean) \(\times 10^{scale}\)

ML.NSE

Numerical Standard Error for mean Marginal likelihood \(\times 10^{scale}\)

scale

integer \(> 0\) providing the scaling for predictive likelihood. (scaling may be necessary for numerical accuracy)

Details

If MargLik is used to get the Marginal Likelihood of a single model, KERNEL must be the exact posterior density (including the scaling constant) of parameters.

If MargLik is used as an intermediate step, for instance for calculating predictive likelihoods, KERNEL can be a posterior kernel or the exact posterior density of parameters. See PredLik.

See Also

isMit,PredLik,MitISEM,SeqMitISEM

Examples

Run this code
# NOT RUN {
mit  <- list(p=1,mu=matrix(1),Sigma=matrix(0.1),df=5)
data <- rnorm(100,1)
KERNEL <- function(theta,data,log=TRUE){
  if(is.vector(theta))
    theta = matrix(theta,nrow=1)
  r <- apply(theta,1,function(x,data)(sum(dnorm(data,x,log=log))),data=data)
}
MargLik(N=1000,mit=mit,KERNEL=KERNEL,data=data)
# }

Run the code above in your browser using DataLab