MS_Regress_Simul: Function to Simulate a Time Series based on Markov Switching...

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

Description

This function simulates a time series based on the Markov Switching Model specified by the user

Usage

1
MS_Regress_Simul(nr, Coeff, k, distrib = "Normal")

Arguments

nr

Number of time periods to simulate (nr=number of rows)

Coeff

A list with all coefficients (see example for details)

k

Number of states in the model (positive integer) (e.g. k=2

distrib

Assumed distribution for residue ("Normal" or "t") e.g distrib<-"Normal"

Value

Returns a S4 Object of Class ""MS_Simul" with the following slots:

@nr

Number of time periods (same as input)

@dep

The simulated dependent Variable (a vector of size nr)

@Coeff

A structure with all coefficients of the simulated series (same as input)

@trueStates

A matrix with the time varying states of the simulated series (which state at each time t)

@indep

A matrix with the independed variables (simulated normal random numbers)

@k

Number of states in Model (the dimension of Coeff$P matrix)

@S

The input argument that controls which variable switches (see example)

Author(s)

Marcelo Perlin - ICMA/UK

References

ALEXANDER, C. (2008) 'Market Risk Analysis: Practical Financial Econometrics' Wiley
HAMILTON, J., D. (1994) 'Time Series Analysis' Princeton University Press
HAMILTON, J., D. (2005) <91>Regime Switching Models<92> Palgrave Dictionary of Economic
KIM, C., J., NELSON, C., R. (1999) <91>State Space Model with Regime Switching: Classical and Gibbs-Sampling Approaches with Applications<92> The MIT press

See Also

MS_Regress_Fit,MS_Regress_For,MS_Regress_Lik

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
nr=500
distrib<-"Normal"
k<-2

PVec<-c(.8 ,.2,
        .1 ,.9)
        
P<-matrix(PVec,k,k)
S<-c(1,0,0)

nS_param<-matrix(c(.5,-.2),2,1)    # Setting up the coefficients at non switching parameters
S_param<-matrix(0,sum(S),k)
S_param[,1]= .2             # Setting up the coefficients at switching parameters
S_param[,2]=-.3

sigma<-matrix(0,1,k)
sigma[1,1]=.05               # Setting up the standard deviavion of the model at State 1
sigma[1,2]=.01               # Setting up the standard deviavion of the model at State 2

Coeff<-list(P=P               , # Build Coeff as a list
            S=S               ,
            nS_param=nS_param ,
            S_param=S_param   ,
            sigma=sigma       )

mySimul<-MS_Regress_Simul(nr,Coeff,k,distrib)

print(mySimul)
plot(mySimul)

fMarkovSwitching documentation built on May 2, 2019, 5:58 p.m.