bayes_mixAR: Bayesian sampling of mixture autoregressive models

View source: R/bayes_mixAR.R

bayes_mixARR Documentation

Bayesian sampling of mixture autoregressive models

Description

Samples parameters of a mixture autoregressive model from respective posterior distributions.

Usage

bayes_mixAR(y, model, fix_shift = FALSE, a = .2, c = 2, tau, nsim, burnin)

Arguments

y

a time series (currently a numeric vector).

model

an object of class MixAR. Currently only handles MixARGaussian objects.

fix_shift

should shift be kept fixed? If FALSE (default) shift is sampled.

a, c

numeric hyperparameters, default values are from \insertCiteRichardsonGreen1997;textualmixAR.

tau

numeric vector of length g, the number of components in the mixture. Tuning parameter for M-H move in updating AR parameters. If length(tau) is 1, same tuning parameter is taken for all components.

nsim

numeric, the number of iterations.

burnin

numeric, the number of iterations taken as burn-in period.

Details

For details see \insertCiteravagli2020bayesian;textualmixAR.

Value

a list with following elements:

mix_weights

a g columns matrix with samples from the posterior distributions of the mixing weights.

scale

a g columns matrix with samples from posterior distributions of scale parameters.

precision

a g columns matrix with samples from posterior distributions of precision parameters, defined as 1 / (scale ^ 2).

shift

a g columns matrix with samples from posterior distributions of shift parameters, namely phi_k0.

mu

a g columns matrix with samples from posterior distributions of component means, calculated as phi_k0 / (1 - phi_k1 - phi_k2 - ...).

ARcoeff

a list which elements are matrices, one for each AR component in the mixture.

acc_rate

numeric vector, the acceptance rate for M-H moves.

n_samp

the sample size, calculated as nsim - burnin.

LatentZ

the latest Z variables drawn (for utility only).

n_comp

the number of components in the mixture.

fix_shift

same as input, whether the shift parameter was kept fixed or not.

Author(s)

Davide Ravagli

References

\insertRef

RichardsonGreen1997mixAR

\insertRef

ravagli2020bayesianmixAR

Examples

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

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

## MAR(1,1) model
y <- mixAR_sim(model, 300, rep(0, max(model@order)))

bayes_mixAR(y, model, fix_shift = FALSE, tau = c(.15,.25), nsim = 20, burnin = 10)

GeoBosh/mixAR documentation built on May 9, 2022, 7:36 a.m.