MargLik: Marginal Likelihood calculation using Importance Sampling and...

Description Usage Arguments Details Value See Also Examples

View source: R/MargLik.R

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

1
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

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.

Value

list containing:

ML.mean

Marginal likelihood (posterior mean) x 10^{scale}

ML.NSE

Numerical Standard Error for mean Marginal likelihood x 10^{scale}

scale

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

See Also

isMit,PredLik,MitISEM,SeqMitISEM

Examples

1
2
3
4
5
6
7
8
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)

MitISEM documentation built on May 2, 2019, 1:57 p.m.