Fit (non) homogeneous Markov switching autoregressive models

Description

Fit (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.R).

Usage

1
2
3
4
5
fit.MSAR(data, theta, MaxIter = 100, eps = 1e-05, verbose = FALSE, 
   covar.emis = NULL, covar.trans = NULL, method = NULL, 
   constraints = FALSE, reduct=FALSE, K = NULL, d.y = NULL, 
   ARfix = FALSE,penalty=FALSE,sigma.diag=FALSE,
   lambda1=.1,lambda2=.1,a=3.7,...)

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"

constraints

if constraints = TRUE constraints are added to theta in order that matrices A and sigma are diagonal by blocks.

K

number of sites. For instance, if one considers wind at k locations, K=k. Or more generally number of independent groups of components.

d.y

dimension in each sites. For instance, if one considers only wind intensity than d.y = 1; but, if one considers cartesian components of wind, then d.y =2.

ARfix

if TRUE the AR parameters are not estimated, they stay fixed at their initial value.

reduct

if TRUE, autoregressive matrices and innovation covariance matrices are constrained to have the same pattern (zero and non zero coefficients) as the one of initial matrices.

sigma.diag

if TRUE the estimated innovation covariances are diagonal

penalty

choice of the penalty for the autoregressive matrices. Possible values are ridge (available for regression matrices only), lasso or SCAD (default).

lambda1

penalization constant for the precision matrices. It may be a scalar or a vector of length M (with M the number of regimes). If it is equal to 0 no penalization is introduced for the precision matrices.

lambda2

penalization constant for the autoregressive matrices. It may be a scalar or a vector of length M (with M the number of regimes).

a

fixed penalisation constant for SCAD penalty

...

other arguments

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} = α_0^{x_t}+α_1^{x_t}y_{t-1}+...+α_p^{x_t}y_{t-p}+σ ε_t

with Y_t the observed process and ε a Gaussian white noise. Y_t may be mutivariate.

The model with non homogeneous emissions is labeled "HN" and it is written

P(X_t|X_{t-1}=x_{t-1}) = Q_{x_{t-1},x_t}

with X_t the hidden process

Y_t|X_t=x_t,y_{t-1},...,y_{t-p} = f(z_t,θ_z^{x_t})+α_1^{x_t}y_{t-1}+...+α_p^{x_t}y_{t-p}+σ ε_t

with Y_t the observed process, ε a Gaussian white noise and Z_t a covariate.

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,θ_{z_t})

with X_t the hidden process and q a link function which has a Gaussian shape by default.

Y_t|X_t=x_t,y_{t-1},...,y_{t-p} = α_0^{x_t}+α_1^{x_t}y_{t-1}+...+α_p^{x_t}y_{t-p}+σ ε_t

with Y_t the observed process, ε a Gaussian white noise and Z_t a covariate.

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 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)

Penalized likelihood is considered if at least one of the lambdas parameters are non zero. When LASSO penalty is chosen, the LARS algorithm is used. When SCAD is chosen, a Newton-Raphson algorithm is run with a quadratic approximation of the penalized likelihood. For the precision matrices penalization, the package glasso is used. Limit of this function: likelihood penalization only works for VAR(1) models

Author(s)

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

References

Ailliot P., Monbet V., (2012), Markov-switching autoregressive models for wind time series. Environmental Modelling & Software, 30, pp 92-101. Efron, B., Hastie, T., Johnstone, I., Tibshirani, R., et al. (2004). Least angle regression. The Annals of statistics, 32(2):407-499.

Fan, J. and Li, R. (2001). Variable selection via nonconcave penalized likelihood and its oracle properties. Journal of the American statistical Association, 96(456):1348-1360. Hamilton J.D. (1989). A New Approach to the Economic Analysis of Nonstionary Time Series and the Business Cycle. Econometrica 57: 357-384.

See Also

init.theta.MSAR, regimes.plot.MSAR, simule.nh.ex.MSAR, depmixS4, MSBVAR

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Fit Homogeneous MS-AR models - univariate time series
data(meteo.data)
data = array(meteo.data$temperature,c(31,41,1)) 
k = 40
T = dim(data)[1]
N.samples = dim(data)[2]
d = dim(data)[3]
M = 2
order = 2
theta.init = init.theta.MSAR(data,M=M,order=order,label="HH") 
mod.hh = fit.MSAR(data,theta.init,verbose=TRUE,MaxIter=20)
#regimes.plot.MSAR(mod.hh,data,ylab="temperatures") 
#Y0 = array(data[1:2,sample(1:dim(data)[2],1),],c(2,1,1))
#Y.sim = simule.nh.MSAR(mod.hh$theta,Y0 = Y0,T,N.samples = 1)

## Not run
# Fit Non Homogeneous MS-AR models - univariate time series
#data(lynx)
#T = length(lynx)
#data = array(log10(lynx),c(T,1,1))
#theta.init = init.theta.MSAR(data,M=2,order=2,label="HH")
#mod.lynx.hh = fit.MSAR(data,theta.init,verbose=TRUE,MaxIter=200)
#regimes.plot.MSAR(mod.lynx.hh,data,ylab="Captures number")

#theta.init = init.theta.MSAR(data,M=2,order=2,label="NH",nh.transitions="logistic")
attributes(theta.init)
#theta.init$A0 = mod.lynx.hh$theta$A0
#theta.init$A = mod.lynx.hh$theta$A
#theta.init$sigma = mod.lynx.hh$theta$sigma
#theta.init$transmat = mod.lynx.hh$theta$transmat
#theta.init$prior = mod.lynx.hh$theta$prior
#Y = array(data[2:T,,],c(T-1,1,1))
#Z = array(data[1:(T-1),,],c(T-1,1,1))
#mod.lynx = fit.MSAR(Y,theta.init,verbose=TRUE,MaxIter=200,covar.trans=Z)
#regimes.plot.MSAR(mod.lynx,Y),ylab="Captures number")

# Fit Homogeneous MS-AR models - multivariate time series
#data(PibDetteDemoc)
#T = length(unique(PibDetteDemoc$year))-1
#N.samples = length(unique(PibDetteDemoc$country))
#PIB = matrix(PibDetteDemoc$PIB,N.samples,T+1)
#Dette = matrix(PibDetteDemoc$Dette,N.samples,T+1)
#Democratie = matrix(PibDetteDemoc$Democratie,N.samples,T+1)

#d = 2
#Y = array(0,c(T,N.samples,2))
#for (k in 1:N.samples) {
#   Y[,k,1] = diff(log(PIB[k,]))
#   Y[,k,2] = diff(log(Dette[k,]))
#}
#Democ = Democratie[,2:(T+1)] 
#theta.hh = init.theta.MSAR(Y,M=M,order=1,label="HH")
#res.hh = fit.MSAR(Y,theta.hh,verbose=TRUE,MaxIter=200)
#regime.hh = apply(res.hh$smoothedprob,c(1,2),which.max)

## Not run
# Fit Non Homogeneous (emission) MS-AR models - multivariate time series
#theta.hn = init.theta.MSAR(Y,M=M,order=1,label="HN",ncov.emis=1)
#theta.hn$A0 = res.hh$theta$A0
#theta.hn$A = res.hh$theta$A
#theta.hn$sigma = res.hh$theta$sigma
#theta.hn$transmat = res.hh$theta$transmat
#theta.hn$prior = res.hh$theta$prior
#Z = array(t(Democ[,2:T]),c(T,N.samples,1))
#res.hn = fit.MSAR(Y,theta.hn,verbose=TRUE,MaxIter=200,covar.emis=Z)

# Fit Non Homogeneous (transitions) MS-AR models - multivariate time series
#theta.nh = init.theta.MSAR(Y,M=M,order=1,label="NH",nh.transitions="gauss",ncov.trans=1)
#theta.nh$A0 = res.hh$theta$A0
#theta.nh$A = res.hh$theta$A
#theta.nh$sigma = res.hh$theta$sigma
#theta.nh$transmat = res.hh$theta$transmat
#theta.nh$prior = res.hh$theta$prior
#theta.nh$par.trans[1:2,1] = 10
#theta.nh$par.trans[3:4,1] = 0
#theta.nh$par.trans[,2] = 2
#Z = array(t(Democ[,2:T]),c(T,N.samples,1))
#res.nh = fit.MSAR(Y,theta.nh,verbose=TRUE,MaxIter=200,covar.trans=Z)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.