regimes.plot.MSAR: Plot MSAR time series with regimes

Description Usage Arguments Value Author(s) Examples

View source: R/regimes.plot.MSAR.R

Description

Plot MSAR time series with regimes materialized by gray boxes.

Usage

1
2
regimes.plot.MSAR(res, data, ex = 1, col.l = "red", nc = 1, 
ylim = NULL, xlab = "time", ylab = "series", d = NULL, dt = 1, lwd = 1, cex = 1)

Arguments

res

list obtained from fit.MSAR fonction as result of MSAR fitting

data

data to plot

ex

number of sample

nc

component number (useful for multivariate time series)

col.l

color of time series (default is red)

ylim

range for the plotted 'y' values, defaulting to the range of the finite values of 'y'

xlab

a title for the x axis

ylab

a title for the y axis

d

dimension to be plot (for multivariate cases). Default is 1.

dt

time step (default=1)

lwd

width of the line

cex

symbols/text size

Value

Returns a plot and the regimes time series.

Author(s)

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

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
data(lynx)
T = length(lynx)
data = array(log(lynx),c(T,1,1))
theta.init = init.theta.MSAR(data,M=2,order=2,label="HH")
mod.lynx = fit.MSAR(data,theta.init)
regimes.plot.MSAR(mod.lynx,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$theta$A0
theta.init$A = mod.lynx$theta$A
theta.init$sigma = mod.lynx$theta$sigma
theta.init$prior = mod.lynx$theta$prior
theta.init$transmat = mod.lynx$theta$transmat
theta.init$par.trans = matrix(c(1,-1,-.2,.2),2,2)
Y = array(data[2:T,,],c(T-1,1,1))
Z = array(data[2:T,,],c(T-1,1,1))
mod.lynx = fit.MSAR(Y,theta.init,verbose=TRUE,MaxIter=20,covar.trans=Z)
regimes.plot.MSAR(mod.lynx,data,ylab="Captures number")

## Not run
# 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.1 = init.theta.MSAR(Y,M=4,order=1,label="HH")
#res.hh = fit.MSAR(Y,theta.hh.1,verbose=TRUE,MaxIter=200)
#par(mfrow=c(2,1))
#regimes.plot.MSAR(res.hh,Y,ex=30,ylab="GDP")
#regimes.plot.MSAR(res.hh,Y,ex=30,nc=2,ylab="Debt")

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