Authors and guest post by Eren Ocakverdi
This blog piece intends to introduce a new addin (i.e. SSPACEGARCH) that extends the current capability of EViews’ available features for the estimation of univariate state space models.
Table of Contents
 Introduction
 A workaround to control for the changing variance problem
 Application to a CAPMtype specification
 Code
 Discretion
Introduction
Linear State Space Models (LSSM) assume that the error variance of the measurement/signal equation is constant. In practice, however, there are situations where this may not be the case and the variance of errors is timevarying. Ignoring this fact may bias parameter estimates.
A workaround to control for the changing variance problem
Suppose that we have a full timevarying parameter model:
\begin{align*}
y_t &= b_{0t} + b_{1t}x_t + e_t\\
b_{it} &= b_{it1} + \epsilon_{it}, \quad \text{where} \quad \epsilon_{it} \sim IID(0, \theta_i)\\
e_t &= \eta_t \sigma_t\\
\sigma^2_t &= \omega + \alpha_1 e^2_{t  1} + \beta_1 \sigma^2_{t  1}, \quad \text{where} \quad \eta_t \sim IID(0,1)
\end{align*}
Although the dynamic system above can be put into state space from, it cannot be solved via default algorithms since the variance equation is not linear in the state variable.
Kalman filter and smoother can be applied iteratively to obtain a new smoothed estimate of state variables, $b_{it}$. New values for the signal estimate $\tilde{e}_t$ are modelled as a GARCH process and are used to compute new values for $\sigma^2_t$ until convergence to $\hat{e}_t$, $\hat{b}_{it}$ or the loglikelihood.
Application to a CAPMtype specification
MSCI Emerging Markets Currency Index® is a useful benchmark to understand whether a given EM currency is performing above or below relative to its peers. In this exercise, we will try to identify the relationship between TRY and MSCI (see Figure 1).

Figure 1: MSCI Emerging Markets Currency Index® vs Indexed and rebased TRY (in USD)

The divergence of two indices is clear even by visual inspection, but we are interested in how the relationship between returns has changed over time. First, using the timevarying parameter model above we estimate the parameters assuming fixed variance (see Figure 2).


Figure 2a: Smoothed estimates: Alpha

Figure 2b: Smoothed estimates: Beta

The alpha coefficient has significantly diverged from zero to negative territory since the global financial crisis of 2008. Beta coefficient hovered around 1 during 2008 and 2021, but declined afterwards and has become statistically insignificant over the course of 2022. Also note the spike around August 2018, which leads us to suspect idiosyncratic factors/developments.
To estimate the parameters along with a changing variance model, we can use the addin (see Figure 3).

Figure 3: SSMGARCH GUI

Since we are dealing with financial data in daily frequency, assuming a GARCH(1,1) structure for the errors would be a reasonable choice to approach the changing variance problem. We can then compare the results to see the difference with respect to the outcome of fixed variance model (see Figure 4).


Figure 4a: Smoothed vs Fixed and Changed Variance Models: Alpha

Figure 4b: Smoothed vs Fixed and Changed Variance Models: Beta

The alpha coefficient becomes constant over the full sample. Although the level of smoothed beta coefficient changes over the full sample visàvis fixed variance model, the dynamics of both estimates remain more or less the same except for certain periods. A closer look at such periods along with the behavior of volatility might shed light on some of the differences we observe (Figure 5).

Figure 5: Difference in estimates visàvis conditional standard deviation

Not surprisingly, many of the large discrepancies in parameter estimates overlap with the periods that have experienced jumps in volatility, most of which were due to specific events took place in Turkish financial markets at the time.
Code
'create a daily workfile
wfcreate d5 2005 2022
'retrieve data from Bloomberg
fetch(d=none) "tryusd curncy" 'TRY currency in USD
fetch(d=none) "mxef0cx0 index" 'MSCI Emerging Markets Currency Index in USD
'rename msci currency index
rename mxef0cx0 msci_curncy
'drop missing values in data
group data.add tryusd msci_curncy
pagecontract @all if @rnas(data)=0
'generate an index from tryusd for comparison purposes
smpl @first @first
series try_curncy = msci_curncy
smpl @first+1 @last
try_curncy = try_curncy(1)*tryusd/tryusd(1)
smpl @all
'draw charts
graph figure1.line try_curncy msci_curncy
'build a timevarying parameter CAPM model in state space
sspace ssmodel
ssmodel.append @signal dlog(tryusd)*100 = alpha + beta*dlog(msci_curncy)*100 + [var=exp(c(1))]
ssmodel.append @state alpha = alpha(1) + [var=exp(c(2))]
ssmodel.append @state beta = beta(1) + [var=exp(c(3))]
ssmodel.append @param c(1) .0 c(2) .0 c(3) .0
'estimate the model
ssmodel.ml
'display and save the smoothed estimates of time varying coefficients
freeze(mode=overwrite,figure2) ssmodel.stategraphs(t=smooth) *f
figure2.align(2,1,1)
ssmodel.makestates(t=smooth) sm_*
'estimate the model assuming GARCH(1,1) errors
ssmodel.sspacegarch(type=1,ref=1,iters=15,tol=1e02,adjsave,garchsave)
'save the smoothed estimates of time varying coefficients
ssmodel_new.makestates(t=smooth) sm_*_new
'compare the smoothed estimates of beta coefficients
group gr_alpha.add sm_alpha*
freeze(mode=overwrite,figure4a) gr_alpha.line
group gr_beta.add sm_beta*
freeze(mode=overwrite,figure4b) gr_beta.line
graph figure4.merge figure4a figure4b
figure4.align(2,1,1)
'compare the absolute difference in estimates to GARCH errors
group gr_diff.add @abs((sm_betasm_beta_new)) @sqrt(garchvar)
freeze(mode=overwrite,figure5) gr_diff.line
figure5.axis overlap
figure5.setelem(2) axis(r)
Discretion
Please note that the method implemented in the addin is not particularly suggested by any peerreviewed study to the best of author’s knowledge, as it is not a preferable way of handling the problem from the econometric point of view. This is simply an iterative process that involves repeated estimation of model assuming a proper GARCH structure for the errors to correct for changing variance problem, if any. It can be helpful only for practical purposes, but you should use it with discretion and at your own risk.
No comments:
Post a Comment