simule.nh.MSAR: Simulation of (non) homogeneous Markov Stiwtching...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/simule.nh.MSAR.R

Description

simule.nh.MSAR simulates realisations of (non) homogeneous Markov Switching autoregressive models with Gaussian innovations

Usage

1
2
simule.nh.MSAR(theta, Y0, T, N.samples = 1, covar.emis = NULL, covar.trans = NULL,
link.ct = NULL,nc = 1,S0 = NULL)

Arguments

theta

list of class MSAR including model parameters and a description of the model. See init.theta.MSAR for more details.

Y0

Initial value. Array of dimension order*N.samples*d with order the AR order, N.samples the number of samples to be simulated and d the dimension of the considered data.

T

Length of each realisation to be simulated

N.samples

number of samples to be simulated

covar.emis

emission covariate or lag for non homogeneous models. Lag is used if the covariate is the lagged time series.

covar.trans

transition covariate or lag for non homogeneous models. Lag is used if the covariate is the lagged time series.

link.ct

allows to specify a link function for non homogeneous transitions.

nc

allows to specify the components of the vector to be considered as covariates in the non homogeneous transitions (default is the first component).

S0

initial state of the Markov chain if not null

Value

List including

..$Y

simulated observation time series

..$S

simulated Markov chain

Author(s)

Val\'erie Monbet, valerie.monbet@univ-rennes1.fr

See Also

fit.MSAR, init.theta.MSAR,valid_all

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
data(meteo.data)
data = array(meteo.data$temperature,c(31,41,1)) 
k = 40
plot(data[,k,1],typ="l",xlab=("time (days)"),ylab=("temperature (Celsius degrees)"))
T = dim(data)[1]
N.samples = dim(data)[2]
d = dim(data)[3]
# Fit Homogeneous MS-AR models
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)
# Simulation
yT = 31
Bsim = 1
Ksim = Bsim*N.samples
Y0 = array(data[1:2,sample(1:dim(data)[2],Ksim,replace=T),],c(2,Ksim,1))
Y.sim = simule.nh.MSAR(mod.hh$theta,Y0 = Y0,T,N.samples = Ksim) 
# Validation
# valid_all(data,Y.sim$Y,id=1,alpha=.05)

## Not run
#data(lynx)
#lyt <- log10(lynx)
#T = length(lynx)
#Y = array(lyt,c(T,1,1))
#theta = init.theta.MSAR(Y,M=2,order=2,label='NH',nh.transitions="logistic",ncov.trans=1)
#Z = array(lyt[1:(T-2)],c(T-2,1,1))
#res=fit.MSAR(lyt[3:T],theta,covar.trans=Z,verbose=TRUE)
#Y0 = lyt[1:2]
#Bsim = 20
#Y0 = array(data[1:2,sample(1:dim(data)[2],Bsim,replace=TRUE),],c(2,Bsim,1))
#Y.sim = simule.nh.MSAR(res$theta,Y0 = Y0,T,N.samples = Bsim,covar.trans=2)

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