Learn R Programming

NHMSAR (version 1.4)

fit.MSAR.VM:

Description

Fit von Mises (non) homogeneous Markov switching autoregressive models by EM algorithm. Non homogeneity may be introduce at the intercept level or in the probability transitions. The link functions are defined in the initialisation step (running init.theta.MSAR.VM.R).

Usage

fit.MSAR.VM(data, theta, 
           MaxIter = 100, eps = 1e-05, verbose = FALSE, 
           covar.emis = NULL, covar.trans = NULL, 
           method = NULL, constr = 0, ...)

Arguments

data
array of univariate or multivariate series with dimension T*N.samples*d. T: number of time steps of each sample, N.samples: number of realisations of the same stationary process, d: dimension.
theta
initial parameter obtained running function init.theta.MSAR.R; object of class MSAR.
MaxIter
maximum number of iteration for EM algorithm (default : 100)
eps
Tolerance for likelihood.
verbose
if verbose=TRUE, the value of log-likelihood is printed at each EM-algorithm's iteration
covar.emis
array of univariate or multivariate series of covariate to take into account in the intercept of the autoregressive models. The link function is defined in the initialisation step (running init.theta.MSAR.R).
covar.trans
array of univariate or multivariate series of covariate to take into account in the transition probabilities. The link function is defined in the initialisation step (running init.theta.MSAR.R).
method
permits to choice the optimization algorithm if numerical optimisation is required in M step. Default : "ucminf". Other choices : "L-BFGS-B", "BFGS"
constr
if constr = 1 constraints are added to theta
...
other arguments

Value

For fit.MSAR and its methods a list of class "MSAR" with the following elements:

Returns a list including:

..$theta
object of class MSAR containing the estimated values of the parameter and some descriptors of the fitted model. See init.theta.MSAR.VM for a detailled description.
..$ll_history
log-likelihood for each iterations of the EM algorithm.
..$Iter
number of iterations run before EM converged
..$Npar
number of parameters in the model
..$BIC
Bayes Information Criterion
..$smoothedprob
smoothing probabilities \(P(X_t|y_0,\cdots,y_T)\)

Details

The homogeneous MSAR model is labeled "HH" and it is written $$ P(X_t|X_{t-1}=x_{t-1}) = Q_{x_{t-1},x_t}$$ with \(X_t\) the hidden univariate process defined on \(\{1,\cdots,M \}\) $$ Y_t|X_t=x_t,y_{t-1},...,y_{t-p}$$ has a von Mises distribution with density $$ p_2(y_t|x_t,y_{t-s}^{t-1}) = \frac {1}{b(x_t,y_{t-s}^{t-1})} \exp\left(\kappa_0^{(x_t)} \cos(y_t-\phi_0^{(x_t)})+ \sum_{\ell=1}^s\kappa_\ell^{(x_t)} \cos(y_t-y_{t-\ell}-\phi_\ell^{(x)})\right)$$ which is equivalent to $$ p_2(y_t|x_t,y_{t-s}^{t-1}) =\frac{1}{b(x_t,y_{t-s}^{t-1})} \left|\exp\left([\gamma_0^{(x_t)} + \sum_{\ell=1}^s\gamma_\ell^{(x_t)} e^{iy_{t-\ell}}]e^{-iy_t}\right)\right|$$ \(b(x_t,y_{t-s}^{t-1})\) is a normalization constant.

Both the real and the complex formulation are implemented. In practice, the complex version is used if the initial \(\kappa\) is complex.

The model with non homogeneous transitions is labeled "NH" and it is written $$P(X_t|X_{t-1}=x_{t-1}) = q(z_t,\theta_{z_t})$$ with \(X_t\) the hidden process and \(q\) von Mises link function such that $$p_1(x_t|x_{t-1},z_{t}) =\frac{ q_{x_{t-1},x_t}\left|\exp \left(\tilde\lambda_{x_{t-1},x_t} e^{-iz_{t}} \right)\right|} {\sum_{x'=1}^M q_{x_{t-1},x'}\left|\exp \left(\tilde\lambda_{x_{t-1},x'} e^{-iz_{t}} \right)\right|}, $$ with \(\tilde\lambda_{x,x'}\) a complex parameter (by taking \(\tilde\lambda_{x,x'}=\lambda_{x,x'} e^{i\psi_{x,x'}}\)).

References

Ailliot P., Bessac J., Monbet V., Pene F., (2014) Non-homogeneous hidden Markov-switching models for wind time series. JSPI.

See Also

init.theta.MSAR.VM, regimes.plot.MSAR

Examples

Run this code
	## Not run
# data(WindDir)
# T = dim(WindDir)[1]
# N.samples = dim(WindDir)[2]
# Y = array(WindDir,c(T,N.samples,1))
# von Mises homogeneous MSAR
# M = 2
# order = 2
# theta.init = init.theta.MSAR.VM(Y,M=M,order=order,label="HH")
# res.hh = fit.MSAR.VM(Y,theta.init,MaxIter=3,verbose=TRUE,eps=1e-8)
## von Mises non homogeneous MSA
# theta.init = init.theta.MSAR.VM(Y,M=M,order=order,label="NH",ncov=1,nh.transitions="VM")
#theta.init$mu = res.hh$theta$mu
#theta.init$kappa = res.hh$theta$kappa
#theta.init$prior = res.hh$theta$prior
#theta.init$transmat = res.hh$theta$transmat
#theta.init$par.trans = matrix(c(res.hh[[M]][[order+1]]$theta$mu,.1*matrix(1,M,1)),2,2)
#Y.tmp = array(Y[2:T,,],c(T-1,N.samples,1))
#Z = array(Y[1:(T-1),,],c(T-1,N.samples,1))
#res.nh = fit.MSAR.VM(Y.tmp,theta.init,MaxIter=10,verbose=T,eps=1e-8,covar.trans=Z)

Run the code above in your browser using DataLab