Mstep.nh.MSAR.VM: M step of the EM algorithm for von Mises MSAR models

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/Mstep.nh.MSAR.VM.R

Description

M step of the EM algorithm for fitting von Mises Markov switching auto-regressive models with non homogeneous transitions.

Usage

1
Mstep.nh.MSAR.VM(data, theta, FB, covar.trans = NULL, method = method, 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

model's parameter; object of class MSAR. See also init.theta.MSAR.

FB

Forward-Backward results, obtained by calling Estep.MSAR function

covar.trans

transitions covariates

method

permits to choice the optimization algorithm. default is "ucminf", other possible choices are "BFGS" or "L-BFGS-B"

constr

if constr=1 contraints are added the the kappa parameters

Value

List containing

mu

intercepts

kappa

von Mises AR coefficients

prior

prior probabilities

transmat

transition matrix

..$par.trans

transitions parameters

Author(s)

Valerie Monbet, valerie.monbet@univ-rennes1.fr

References

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

See Also

fit.MSAR.VM, init.theta.MSAR.VM, Mstep.hh.MSAR.VM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (data, theta, FB, covar = covar.trans, method = method, 
    constr = 0) 
{
    order = attributes(theta)$order
    d = dim(data)[3]
    if (is.na(d) | is.null(d)) {
        d = 1
    }
    M = attributes(theta)$NbRegimes
    if (length(covar) == 1) {
        Lag = covar
        covar = array(data[(1):(T - Lag + 1), , ], c(T - Lag + 
            1, N.samples, d))
        data = array(data[Lag:T, , ], c(T - Lag + 1, N.samples, 
            d))
    }
    N.samples = dim(covar)[2]
    ncov.trans = dim(covar)[3]
    par.hh = Mstep.hh.MSAR.VM(data, theta, FB, constr)
    theta$transmat[which(theta$transmat < 1e-15)] = 1e-15
    theta$transmat = mk_stochastic(theta$transmat)
    trans = para_trans(theta$transmat)
    par.trans = theta$par.trans
    nh_transition = attributes(theta)$nh.transitions
    par.init = plie2(trans, par.trans)
    lxi = dim(FB$probSS)[3]
    if (order > 0) {
        deb = order + 1
    }
    else {
        deb = 1
    }
    resopt = ucminf(par.init, fn = loglik_nh_inp.VM, gr = NULL, 
        covar = array(covar[deb + (1:(lxi)), , ], c(lxi, N.samples, 
            ncov.trans)), xi = FB$probSS, nh_transition = nh_transition, 
        hessian = 0, control = list(trace = FALSE))
    res = deplie2(resopt$par)
    trans = res$trans
    par.trans = res$par
    transmat = para_trans_inv(trans)
    list(mu = par.hh$mu, kappa = par.hh$kappa, prior = par.hh$prior, 
        transmat = transmat, par.trans = par.trans)
  }

Example output

function (data, theta, FB, covar = covar.trans, method = method, 
    constr = 0) 
{
    order = attributes(theta)$order
    d = dim(data)[3]
    if (is.na(d) | is.null(d)) {
        d = 1
    }
    M = attributes(theta)$NbRegimes
    if (length(covar) == 1) {
        Lag = covar
        covar = array(data[(1):(T - Lag + 1), , ], c(T - Lag + 
            1, N.samples, d))
        data = array(data[Lag:T, , ], c(T - Lag + 1, N.samples, 
            d))
    }
    N.samples = dim(covar)[2]
    ncov.trans = dim(covar)[3]
    par.hh = Mstep.hh.MSAR.VM(data, theta, FB, constr)
    theta$transmat[which(theta$transmat < 1e-15)] = 1e-15
    theta$transmat = mk_stochastic(theta$transmat)
    trans = para_trans(theta$transmat)
    par.trans = theta$par.trans
    nh_transition = attributes(theta)$nh.transitions
    par.init = plie2(trans, par.trans)
    lxi = dim(FB$probSS)[3]
    if (order > 0) {
        deb = order + 1
    }
    else {
        deb = 1
    }
    resopt = ucminf(par.init, fn = loglik_nh_inp.VM, gr = NULL, 
        covar = array(covar[deb + (1:(lxi)), , ], c(lxi, N.samples, 
            ncov.trans)), xi = FB$probSS, nh_transition = nh_transition, 
        hessian = 0, control = list(trace = FALSE))
    res = deplie2(resopt$par)
    trans = res$trans
    par.trans = res$par
    transmat = para_trans_inv(trans)
    list(mu = par.hh$mu, kappa = par.hh$kappa, prior = par.hh$prior, 
        transmat = transmat, par.trans = par.trans)
}

NHMSAR documentation built on Feb. 9, 2022, 9:06 a.m.