









































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Ch 14 Material Type: Notes; Class: ECONOMETRIC THY II; Subject: Economics; University: University of Washington - Seattle; Term: Unknown 1989;
Typology: Study notes
1 / 49
This page cannot be seen from the preview
Don't miss anything!










































This is page 517 Printer: Opaque this
The state space modeling tools in S+FinMetrics are based on the algo- rithms in SsfPack 3.0 developed by Siem Jan Koopman and described in Koopman, Shephard and Doornik (1999, 2001)^1. SsfPack is a suite of C routines for carrying out computations involving the statistical analysis of univariate and multivariate models in state space form. The routines allow for a variety of state space forms from simple time invariant models to complicated time-varying models. Functions are available to put standard models like ARMA and spline models in state space form. General rou- tines are available for filtering, smoothing, simulation smoothing, likelihood evaluation, forecasting and signal extraction. Full details of the statistical analysis is provided in Durbin and Koopman (2001). This chapter gives an overview of state space modeling and the reader is referred to the papers by Koopman, Shephard and Doornik for technical details on the algorithms used in the S+FinMetrics/SsfPack functions. This chapter is organized as follows. Section 14.2 describes the gen- eral state space model and state space representation required for the S+FinMetrics/SsfPack state space functions. Subsections describe the various S+FinMetrics/SsfPack functions for putting common time series models into state space form. The process of simulating observations from a given state space model is also covered. Section 14.3 summarizes the main
(^1) Information about Ssfpack can be found at http://www.ssfpack.com.
518 14. State Space Models
algorithms used for the analysis of state space models. These include the Kalman filter, Kalman smoother, moment smoothing, disturbance smooth- ing and forecasting. Estimation of the unknown parameters in a state space model is described in Section 14.4. The chapter concludes with a short dis- cussion of simulation smoothing. Textbook treatments of state space models are given in Harvey (1989, 1993), Hamilton (1994), West and Harrison (1997), and Kim and Nelson (1999). Interesting applications of state space models in finance are given in Engle and Watson (1987), Bomhoff (1994), Duan and Simonato (1999), and Harvey, Ruiz and Shephard (1994), Carmona (2001) and Chan (2002).
Many dynamic time series models in economics and finance may be rep- resented in state space form. Some common examples are ARMA mod- els, time-varying regression models, dynamic linear models with unob- served components, discrete versions of continuous time diffusion processes, stochastic volatility models, non-parametric and spline regressions. The lin- ear Gaussian state space model may be represented as the system of equa- tions
αt+ m× 1
= dt m× 1
· αt m× 1
· ηt r× 1
θt N × 1
= ct N× 1
· αt m× 1
yt N × 1
= θt N× 1
· εt N× 1
where t = 1,... , n and
α 1 ∼ N (a, P), (14.4) ηt ∼ iid N (0, Ir) (14.5) εt ∼ iid N ( 0 , IN ) (14.6)
and it is assumed that E[εtη^0 t] = 0
In (14.4), a and P are fixed and known but that can be generalized. The state vector αt contains unobserved stochastic processes and unknown fixed effects and the transition equation (14.1) describes the evolution of the state vector over time using a first order Markov structure. The measure- ment equation (14.3) describes the vector of observations yt in terms of the state vector αt through the signal θt and a vector of disturbances εt. It is assumed that the innovations in the transition equation and the innova- tions in the measurement equation are independent, but this assumption
520 14. State Space Models
amples describe the specification of a state space model for use in the S+FinMetrics/SsfPack state space modeling functions.
Example 92 State space representation of the local level model
Consider the following simple model for the stochastic evolution of the logarithm of an asset price yt
αt+1 = αt + η∗ t , η∗ t ∼ iid N (0, σ^2 η ) (14.12) yt = αt + ε∗ t , ε∗ t ∼ iid N (0, σ^2 ε) (14.13) α 1 ∼ N(a, P ) (14.14)
where it is assumed that E[ε∗ t η∗ t ] = 0. In the above model, the observed asset price yt is the sum of two unobserved components, αt and ε∗ t. The component αt is the state variable and represents the fundamental value (signal) of the asset. The transition equation (14.12) shows that the fun- damental values evolve according to a random walk. The component ε∗ t represents random deviations (noise) from the fundamental value that are assumed to be independent from the innovations to αt. The strength of the signal in the fundamental value relative to the random deviation is measured by the signal-to-noise ratio of variances q = σ^2 η/σ^2 ε. The model (14.12)-(14.14) is called the random walk plus noise model, signal plus noise model or the local level model.^2 The state space form (14.7) of the local level model has time invariant parameters
δ =
μ 0 0
μ 1 1
μ σ^2 η 0 0 σ^2 ε
with errors σηηt = η∗ t and σεεt = ε∗ t. Since the state variable αt is I(1), the unconditional distribution of the initial state α 1 doesn’t have finite variance. In this case, it is customary to set a = E[α 1 ] = 0 and P = var(α 1 ) to some large positive number, e.g. P = 10^7 , in (14.14) to reflect that no prior information is available. Using (14.11), the initial variance is specified with P∗ = 0 and P∞ = 1. Therefore, the initial state matrix (14.10) for the local level model has the form
μ − 1 0
where −1 implies that P∞ = 1. In S+FinMetrics/SsfPack, a state space model is specified by creating either a list variable with components giving the minimum components
(^2) A detailed technical analysis of this model is given in Durbin and Koopman (2001), chapter 2.
14.2 State Space Representation 521
State space parameter List component name δ mDelta Φ mPhi Ω mOmega Σ mSigma TABLE 14.1. State space form list components
necessary for describing a particular state space form or by creating an “ssf” object. To illustrate, consider creating a list variable containing the state space parameters in (14.15)-(14.16), with ση = 0.5 and σε = 1
sigma.e = 1 sigma.n = 0. a1 = 0 P1 = - ssf.ll.list = list(mPhi=as.matrix(c(1,1)),
ssf.ll.list $mPhi: [,1] [1,] 1 [2,] 1
$mOmega: [,1] [,2] [1,] 0.25 0 [2,] 0.00 1
$mSigma: [,1] [1,] - [2,] 0
In the list variable ssf.ll.list, the component names match the state space form parameters in (14.7) and (14.10). This naming convention, sum- marized in Table 14.1, must be used for the specification of any valid state space model. Also, notice the use of the coercion function as.matrix. This ensures that the dimensions of the state space parameters are correctly specified. An “ssf” object may be created from the list variable ssf.ll.list using the S+FinMetrics/SsfPack function CheckSsf:
ssf.ll = CheckSsf(ssf.ll.list) class(ssf.ll) [1] "ssf"
14.2 State Space Representation 523
$cSt: [1] 1
attr(, "class"): [1] "ssf"
The function CheckSsf takes a list variable with a minimum state space form, coerces the components to matrix objects and returns the full param- eterization of a state space model used in many of the S+FinMetrics/SsfPack state space modeling functions. See the online help for CheckSsf for de- scriptions of the components of an “ssf” object.
Example 93 State space representation of a time varying parameter re- gression model
Consider the Capital Asset Pricing Model (CAPM) with time varying intercept and slope
rt = αt + βtrM,t + νt, νt ∼ GW N (0, σ^2 ν ) (14.17) αt+1 = αt + ξt, ξt ∼ GW N (0, σ^2 ξ ) (14.18) βt+1 = βt + ςt, ςt ∼ GW N (0, σ^2 ς ) (14.19)
where rt denotes the return on an asset in excess of the risk free rate, and rM,t denotes the excess return on a market index. In this model, both the abnormal excess return αt and asset risk βt are allowed to vary over time following a random walk specification. Let αt = (αt, βt)^0 , yt = rt, xt = (1, rM,t)^0 , Ht = diag(σξ , σς )^0 and Gt = σν. Then the state space form (14.7) of (14.17) - (14.19) is μ αt+ yt
μ I 2 x^0 t
αt +
μ Hηt Gεt
and has parameters
Φt =
μ I 2 x^0 t
σ^2 ξ 0 0 0 σ^2 ς 0 0 0 σ^2 ν
Since αt is I(1) the initial state vector α 1 doesn’t have finite variance so it is customary to set a = 0 and P = κI 2 where κ is large. Using (14.11), the initial variance is specified with P∗ = 0 and P∞ = I 2. Therefore, the initial state matrix (14.10) for the time varying CAPM has the form
524 14. State Space Models
The state space parameter matrix Φt in (14.20) has a time varying system element Zt= x^0 t. In S+FinMetrics/SsfPack, the specification of this time varying element in Φt requires an index matrix JΦ and a data matrix X to which the indices in JΦ refer. The index matrix JΦ must have the same dimension as Φt. The elements of JΦ are all set to −1 except the elements for which the corresponding elements of Φt are time varying. The non-negative index value indicates the column of the data matrix X which contains the time varying values. The specification of the state space form for the time varying CAPM requires values for the variances σ^2 ξ , σ^2 ς , and σ^2 ν as well as a data ma- trix X whose rows correspond with Zt = x^0 t = (1, rM,t). For example, let σ^2 ξ = (0.01)^2 , σ^2 ς = (0.05)^2 and σ^2 ν = (0.1)^2 and construct the data ma- trix X using the excess return data in the S+FinMetrics “timeSeries” excessReturns.ts
X.mat = cbind(1,
The state space form may be created using
Phi.t = rbind(diag(2),rep(0,2)) Omega = diag(c((.01)^2,(.05)^2,(.1)^2)) J.Phi = matrix(-1,3,2) J.Phi[3,1] = 1 J.Phi[3,2] = 2 Sigma = -Phi.t ssf.tvp.capm = list(mPhi=Phi.t,
ssf.tvp.capm $mPhi:
[,1] [,2] [1,] 1 0 [2,] 0 1 [3,] 0 0
$mOmega: [,1] [,2] [,3] [1,] 0.0001 0.0000 0. [2,] 0.0000 0.0025 0. [3,] 0.0000 0.0000 0.
$mJPhi: [,1] [,2]
526 14. State Space Models
In the S+FinMetrics/SsfPack state space functions, the observation vec- tor yt with missing values will be be reduced to the vector y† t without missing values and the measurement equation will be adjusted accordingly. For example, the measurement equation yt= ct+Ztαt+Gtεt with
yt =
,^ ct^ =
,^ Zt^ =
Z 1 ,t Z 2 ,t Z 3 ,t Z 4 ,t
,^ Gt^ =
G 1 ,t G 2 ,t G 3 ,t G 4 ,t
reduces to the measurement equation y† t = c† t +Z† t αt+G† t εt with
y† t =
μ 5 3
, c† t =
μ 1 3
, Z† t =
μ Z 1 ,t Z 3 ,t
, G† t =
μ G 1 ,t G 3 ,t
The SsfPack algorithms in S+FinMetrics automatically replace the ob- servation vector yt with y t† when missing values are encountered and the system matrices are adjusted accordingly.
S+FinMetrics/SsfPack has functions for the creation of the state space representation of some common time series models. These functions and models are described in the following sub-sections.
ARMA Models
Following Harvey (1993, Section 4.4), the ARMA(p, q) model with zero mean^3
yt = φ 1 yt− 1 + · · · + φpyt−p + ξt + θ 1 ξt− 1 + · · · + θq ξt−q (14.21)
may be put in state space form with transition and measurement equations
αt+1 = Tαt + Hξt, ξt ∼ N (0, σ^2 ε) yt = Zαt
(^3) Note that the MA coefficients are specified with positive signs, which is the opposite of how the MA coefficients are specified for models estimated by the S-PLUS function arima.mle.
14.2 State Space Representation 527
and time invariant system matrices
φ 1 1 0 · · · 0 φ 2 0 1 0 .. .
φm− 1 0 0 1 φm 0 0 · · ·
θ 1 .. . θm− 1 θm
where d, c and G of the state space form (14.1)-(14.3) are all zero and m = max(p, q + 1). The state vector αt has the form
αt =
yt φ 2 yt− 1 + · · · + φpyt−m+1 + θ 1 ξt + · · · + θm− 1 ξt−m+ φ 3 yt− 1 + · · · + φpyt−m+2 + θ 2 ξt + · · · + θm− 1 ξt−m+ .. . φmyt− 1 + θm− 1 ξt
In compact state space form (14.7), the model is μ αt+ yt
μ T Z
αt +
μ H 0
ξt
= Φαt + ut
and
Ω =
μ σ^2 ξ HH^0 0 0
If yt is stationary then αt ∼ N (0, V) is the unconditional distribution of the state vector, and the covariance matrix V satisfies V = TVT^0 +σ^2 ξ HH^0 , which can be solved for the elements of V. The initial value parameters are then
Σ =
μ V 00
The S+FinMetrics/SsfPack function GetSsfArma creates the state space system matrices for any univariate stationary and invertible ARMA model. The arguments expected by GetSsfArma are
args(GetSsfArma) function(ar = NULL, ma = NULL, sigma = 1, model = NULL)
where ar is the vector of p AR coefficients, ma is the vector of q MA coef- ficients, sigma is the innovation standard deviation σξ, and model is a list with components giving the AR, MA and innovation standard deviation. If the arguments ar, ma, and sigma are specified, then model is ignored. The function GetSsfArma returns a list containing the system matrices Φ, Ω and the initial value parameters Σ.
14.2 State Space Representation 529
$mSigma: [,1] [,2] [1,] 1.58571 0. [2,] 0.01286 0. [3,] 0.00000 0.
The unconditional variance of the initial state vector α 1 = (α 11 , α 12 )^0 is in the top 2 × 2 block of mSigma and is
var(α 1 ) =
μ
Structural Time Series Models
The basic univariate unobserved components structural time series model (STSM) for a time series yt has the form
yt = μt + γt + ψt + ξt (14.24)
where μt represents the unobserved trend component, γt represents the unobserved seasonal component, ψt represents the unobserved cycle com- ponent, and ξt represents the unobserved irregular component. The nonstationary trend component μt has the form of a local linear trend:
μt+1 = μt + βt + ηt, ηt ∼ GW N (0, σ^2 η ) (14.25) βt+1 = βt + ςt, ςt ∼ GW N (0, σ^2 ς ) (14.26)
with μ 1 ∼ N(0, κ) and β 1 ∼ N (0, κ) where κ is a large number, e.g. κ = 10^6. If σ^2 ς = 0 then μt follows a random walk with drift β 1. If both σ^2 ς = 0 and σ^2 η = 0 then μt follows a linear deterministic trend. The stochastic seasonal component γt has the form
S(L)γt = ωt, ωt ∼ GW N (0, σ^2 ω ) (14.27) S(L) = 1 + L + · · · + Ls−^1
where s gives the number of seasons. When σ^2 ω = 0, the seasonal component becomes fixed. The stochastic cycle component ψt is specified as μ ψt+ ψ∗ t+
= ρ
μ cos λc sin λc − sin λc cos λc
¶ μ ψt ψ∗ t
μ χt χ∗ t
μ χt χ∗ t
μμ 0 0
, σ^2 ψ(1 − ρ^2 )I 2
where ψ 0 ∼ N (0, σ^2 ψ), ψ∗ 0 ∼ N (0, σ^2 ψ) and cov(ψ 0 , ψ∗ 0 ) = 0. The parameter ρ ∈ (0, 1] is interpreted as a damping factor. The frequency of the cycle
530 14. State Space Models
Argument STSM parameter irregular ση level σξ slope σς seasonalDummy s seasonalTrig σω, s seasonalHS σω, s cycle0 σψ, λc, ρ .. .
cycle9 σψ, λc, ρ TABLE 14.3. Arguments to the S+FinMetrics function GetSsfStsm
is λc = 2π/c and c is the period. When ρ = 1 the cycle reduces to a deterministic sine-cosine wave. The S+FinMetrics/SsfPack function GetSsfStsm creates the state space system matrices for the univariate structural time series model (14.24). The arguments expected by GetSsfStsm are
args(GetSsfStsm) function(irregular = 1, level = 0.1, slope = NULL, seasonalDummy = NULL, seasonalTrig = NULL, seasonalHS = NULL, cycle0 = NULL, cycle1 = NULL, cycle2 = NULL, cycle3 = NULL, cycle4 = NULL, cycle5 = NULL, cycle6 = NULL, cycle7 = NULL, cycle8 = NULL, cycle9 = NULL)
These arguments are explained in Table 14.3.
Example 95 Local level model
The state space for the local level model (14.12)-(14.14) may be con- structed using
ssf.stsm = GetSsfStsm(irregular=1, level=0.5) class(ssf.stsm) [1] "list" ssf.stsm $mPhi: [,1] [1,] 1 [2,] 1
$mOmega: [,1] [,2] [1,] 0.25 0 [2,] 0.00 1
532 14. State Space Models
args(GetSsfReg) function(mX)
where mX is a rectangular data object which represents the regressors in the model. The function GetSsfReg returns a list with components describing the minimal state space representation of the linear regression model.
Example 96 Time trend regression model
Consider the time trend regression model
yt = μ + δt + ξt, ξt ∼ GW N (0, σ^2 ξ )
The state space form for a sample of size n = 10 is computed using
ssf.reg = GetSsfReg(cbind(1,1:10)) class(ssf.reg) [1] "list" names(ssf.reg) [1] "mPhi" "mOmega" "mSigma" "mJPhi" "mX" ssf.reg $mPhi: [,1] [,2] [1,] 1 0 [2,] 0 1 [3,] 0 0
$mOmega: [,1] [,2] [,3] [1,] 0 0 0 [2,] 0 0 0 [3,] 0 0 1
$mSigma: [,1] [,2] [1,] -1 0 [2,] 0 - [3,] 0 0
$mJPhi: [,1] [,2] [1,] -1 - [2,] -1 - [3,] 1 2
$mX: [,1] [,2]
14.2 State Space Representation 533
Since the system matrix Zt= x^0 t, the parameter Φt is time varying and the index matrix JΦ, represented by the component mJPhi, determines the association between the time varying data in Zt and the data supplied in the component mX. To specify a time trend regression with a time varying slope of the form
δt+1 = δt + ζt, ζt ∼ GW N (0, σ^2 ζ ) (14.31)
one needs to specify a non-zero value for σ^2 ζ in Ωt. For example, if σ^2 ζ = 0. 5 then
ssf.reg.tvp = ssf.reg ssf.reg.tvp$mOmega[2,2] = 0. ssf.reg.tvp$mOmega [,1] [,2] [,3] [1,] 0 0.0 0 [2,] 0 0.5 0 [3,] 0 0.0 1
modifies the state space form for the time trend regression to allow a time varying slope of the form (14.31).
Regression Models with ARMA Errors
The ARMA(p, q) models created with GetSsfArma do not have determinis- tic terms (e.g., constant, trend, seasonal dummies) or exogenous regressors and are therefore limited. The general ARMA(p, q) model with exogenous regressors has the form
yt = x^0 tβ + ξt
where ξt follows an ARMA(p, q) process of the form (14.21). Let αt be defined as in (14.23) and let
α∗ t =
μ αt βt
14.2 State Space Representation 535
$mSigma: [,1] [,2] [,3] [,4] [1,] 4.364 -1.818 0 0 [2,] -1.818 1.091 0 0 [3,] 0.000 0.000 -1 0 [4,] 0.000 0.000 0 - [5,] 0.000 0.000 0 0
$mJPhi: [,1] [,2] [,3] [,4] [1,] -1 -1 -1 - [2,] -1 -1 -1 - [3,] -1 -1 -1 - [4,] -1 -1 -1 - [5,] -1 -1 1 2
$mX: [,1] [,2] [1,] 1 1 [2,] 1 2 ... [10,] 1 10
Nonparametric Cubic Spline Model
Suppose the continuous time process y(t) is observed at discrete time points t 1 ,... , tn. Define δi = ti − ti− 1 ≥ 0 as the time duration between obser- vations. The goal of the nonparametric cubic spline model is to estimate a smooth signal μ(t) from y(t) using
y(t) = μ(t) + ε(t)
where ε(t) is a stationary error. The signal μ(t) is extracted by minimizing
X^ n
i=
(y(ti) − μ(ti))^2 + q−^1
Z μ^ ∂^2 μ(t) ∂t^2
dt
536 14. State Space Models
where the second term is a penalty term that forces μ(t) to be “smooth”^4 , and q may be interpreted as a signal-to-noise ratio. The resulting function μ(t) may be expressed as the structural time series model
μ(ti+1) = μ(ti) + δiβ(ti) + η(ti) (14.33) β(ti+1) = β(ti) + ς(ti)
where (^) μ η(ti) ς(ti)
·μ 0 0
, σ^2 ς δi
μ (^1) 3 δ
2 i 1 1 2 δi 2 δi^1
Combining (14.33) with the measurement equation
y(ti) = μ(ti) + ε(ti)
where ε(ti) ∼ N(0, σ^2 ε) and is independent of η(ti) and ς(ti), gives the state space form for the nonparametric cubic spline model. The state space system matrices are
Φt =
1 δi 0 1 1 0
(^) , Ωt =
qδ^2 t 3
qδ^2 t 2 0 qδ^2 t 2 qδt^0 0 0 1
When the observations are equally spaced, δi is constant and the above system matrices are time invariant. The S+FinMetrics/SsfPack function GetSsfSpline creates the state space system matrices for the nonparametric cubic spline model. The ar- guments expected by GetSsfSpline are
args(GetSsfSpline) function(snr = 1, delta = 0)
where snr is the signal-to-noise ratio q, and delta is a numeric vector containing the time durations δi (i = 1,... , n). If delta=0 then δi is as- sumed to be equal to unity and the time invariant form of the model is created. The function GetSsfSpline returns a list with components de- scribing the minimal state space representation of the nonparametric cubic spline model.
Example 98 State space form of non-parametric cubic spline model
The default non-parametric cubic spline model with δt = 1 is created using
(^4) This process can be interpreted as an interpolation technique and is similar to the technique used in the S+FinMetrics functions interpNA and hpfilter. See also the smoothing spline method described in chapter sixteen.