marg_loglik: Calculate marginal loglikelihood at high density points of a...

View source: R/marg_loglik.R

marg_loglikR Documentation

Calculate marginal loglikelihood at high density points of a MAR model.

Description

The function implements the method by \insertCiteChib1995;textualmixAR and \insertCiteChibJeliazkov2001;textualmixAR for calculation of the marginal loglikelihood of a mixture autoregressive model. It automatically finds high density values for model parameters, and evaluates the likelihood at such points.

Usage

marg_loglik(y, model, tau, nsim, prob_mod)

Arguments

y

a time series (currently a numeric vector).

model

object of formal class MixAR, containing initial values for the parameters. Currently available for MixARGaussian objects only.

tau

tuning parameter for Metropolis-Hasting move to update autoregressive parameters.

nsim

sample size on which to evaluate highest density values.

prob_mod

this is currently the output from Choose_pk: the proportion of times the "best model" was chosen.

Details

nsim is the sample size on which to evaluate highest density values for each set of parameters. For example, choosing nsim=1000 results in 1000*(g+3) (1000 iterations for each autoregressive component, plus 1000 for mean and scale parameters and mixing weights).

Value

A list containing the following elements:

marg_loglik

value of the marginal loglikelihood.

phi_hd

set of highest density autoregressive parameters.

prec_hd

set of highest density precision parameters.

mu_hd

set of highest density mean parameters.

weig_hd

set of highest density mixing weights.

Author(s)

Davide Ravagli

References

\insertRef

Chib1995mixAR

\insertRef

ChibJeliazkov2001mixAR

Examples

prob <- c(0.5, 0.5)
sigma <- c(1, 2)
arco <- list(-0.5, 1)

model <- new("MixARGaussian", prob = prob, scale = sigma, arcoef = arco)

set.seed(1234)
y <- mixAR_sim(model, 250, rep(0, max(model@order)), nskip = 100)  # data

nsim <- 10 # 50
marg_loglik(y, model, tau = c(.15, .25), nsim = nsim, 0.5)

mixAR documentation built on May 3, 2022, 5:08 p.m.