sampZpi {mixAR} | R Documentation |
Sampling functions for Bayesian analysis of mixture autoregressive models
Description
Sampling functions for Bayesian analysis of mixture autoregressive
models. Draws observations from posterior distributions of the latent
variables Z_t
s and the parameters of mixture autoregressive
models.
Usage
sampZpi(y, pk, prob, mu, AR, sigma, nsim, d)
sampMuShift(y, pk, prec, nk, shift, z, AR, nsim)
sampSigmaTau(y, pk, prec, nk, AR, mu, z, a, c, nsim)
Arguments
y |
a time series (currently a |
pk |
|
prob |
|
mu |
|
shift |
|
AR |
|
sigma |
|
nsim |
dessired sample size. |
d |
|
prec |
|
nk |
output from |
z |
output |
a , c |
hyperparameters. |
Details
sampZpi
draws observations from posterior distributions of the
latent variables Z_t
s and mixing weights of a Mixture
autoregressive model.
sampSigmaTau
draws observations from posterior distributions of
the precisions tau_k
of a Mixture autoregressive model, and
obtains scales sigma_k
by transformation.
sampMuShift
Draws observations from posterior distributions of
the means mu_k
of a Mixture autoregressive model, and obtains
shifts phi_k0
by transformation.
Value
for sampZpi
, a list containing the following elements:
mix_weights |
|
latentZ |
|
nk |
Vector of length |
for sampMuShift
, a list containing the following elements:
shift |
|
mu |
|
for sampSigmaTau
, a list containing the following elements:
scale |
|
precision |
|
lambda |
|
Author(s)
Davide Ravagli
Examples
model <- new("MixARGaussian",
prob = exampleModels$WL_At@prob, # c(0.5, 0.5)
scale = exampleModels$WL_At@scale, # c(1, 2)
arcoef = exampleModels$WL_At@arcoef@a ) # list(-0.5, 1.1)
prob <- model@prob
sigma <- model@scale
prec <- 1 / sigma ^ 2
g <- length(model@prob)
d <- rep(1, g)
pk <- model@arcoef@p
p <- max(pk)
shift <- mu <- model@shift
AR <- model@arcoef@a
model
set.seed(1234)
n <- 50 # 500
nsim <- 50
y <- mixAR_sim(model, n = n, init = 0)
x <- sampZpi(y, pk, prob, shift, AR, sigma, nsim = nsim, d)
x1 <- sampMuShift(y, pk, prec, nk = x$nk, shift, z = x$latentZ, AR, nsim = nsim)
x2 <- sampSigmaTau(y, pk, prec, nk = x$nk, AR, mu = x1$mu, z = x$latentZ,
a = 0.2, c = 2, nsim = nsim)