an alternative methodology, the Markovian switching model, whichencountered great success. Although initiated by Quandt (1958) and Goldfeld and Quandt(1973, 1975) to provide a description of markets in disequilibrium, this approach hasnot encountered a great interest until the works of Hamilton (1989) on business cyclesmodelling, and of Engel and Hamilton (1990) on exchange rates. The main feature ofthis approach is that it involves multiple structures and allows returns to be drawn fromdistinct distributions.Applied Quantitative Methods for Trading and Investment. 2003 John Wiley & Sons, Ltd ISBN: 0-470-84885-5
Edited by C.L. Dunis, J. Laws and P. Naı̈m
194
Applied Quantitative Methods for Trading and Investment
The change of regime between the distributions is determined in a Markovian manner.It is driven by an unobservable state variable that follows a ﬁrst-order Markov chain whichcan take values of {0, 1}. The value of that variable is dependent upon its past values.The switching mechanism thus enables complex dynamic structures to be captured andallows for frequent changes at random times. In that way, a structure may persist for aperiod of time and then be replaced by another structure after a switch occurs.This methodology is nowadays very popular in the ﬁeld of nonlinear time series modelsand it has experienced a wide number of applications in the analysis of ﬁnancial timeseries. Although the original Markov switching models focused on the modelling of theﬁrst moment with application to economic and ﬁnancial time series, see e.g. Hamilton(1988, 1989), Engel and Hamilton (1990), Lam (1990), Goodwin (1993), Engel (1994),Kim and Nelson (1998), among others, a growing body of literature is developing withregard to the application of this technique and its variant to volatility modelling. Toquote again a few among others, Hamilton and Lin (1996), Dueker (1997) and Ramchandand Susmel (1998). Gray (1996) models switches in interest rates. Chesnay and Jondeau(2001) model switches of multivariate dependency.In this chapter we present the switching methodology in a pedagogical frameworkand in a way that may be useful for the ﬁnancial empiricist. In Section 6.2 the notations and the switching model are introduced. In Section 6.3 we develop the maximumlikelihood estimation methodology and show how the switching model can be estimated.This methodology is applied in Section 6.4 to the US dollar (USD)/Deutsche Mark (DEM)exchange rate for the period 1 March 1995 to 1 March 1999. In that section it is shown howestimation results are to be interpreted, and how endogenously detected changes betweenstates can improve the performances of simple real life hedging strategies. Section 6.5concludes and hints at further lines of research.
6.2 THE MODELWe assume, in this chapter, that foreign exchange returns1 are a mixture of normal distributions. This means that returns are drawn from a normal distribution where the meanand variance can take different values depending on the “state” a given return belongs to.Since there is pervasive evidence that variance is persistent, yet little is known about itsmean, it is useful to consider the more restrictive mixture model where just the variancecan switch. This leads us to introduce the following model, based on Hamilton (1994):Rt = µ + [σ1 St + σ0 (1 − St )]εtwhere εt are independent and identically distributed normal innovations with mean 0 andvariance 1. St is a Markov chain with values 0 and 1, and with transition probabilitiesp = [p00 , p01 , p10 , p11 ] such that:Pr[St = 1|St−1 = 1] = p11
Pr[St = 0|St−1 = 1] = p01
Pr[St = 1|St−1 = 0] = p10
Pr[St = 0|St−1 = 0] = p00
where p11 + p01 = 1 and p10 + p00 = 1.1Returns are calculated as the difference in the natural logarithm of the exchange rate value St for twoconsecutive observations: Rt = 100[ln(St ) − ln(St−1 )]. This corresponds to continuously compounded returns.
Switching Regime Volatility
Let
195
ρj = Pr[S1 = j ] ∀j
be the unconditional probability of being in a certain state at time 1 and let ρ = [ρ0 , ρ1 ] .If λ designates the vector of all remaining parameters λ = [µ, σ1, σ0 ] then we candeﬁne θ = [λ , p  , ρ  ] the vector of all parameters.2In the following we use the notationR t = [Rt , Rt−1, . . . , R1 ]to designate the vector of realisations of past returns.It is also useful to introduce the density of Rt conditional on regime St : f (Rt |St ). Forthe model considered, in the case where εt is normally distributed, this density can bewritten as:32 111Rt − µexp −(6.1)f (Rt |St ; θ ) = √2 σ1 St + σ0 (1 − St )2π σ1 St + σ0 (1 − St )This illustrates that for a given parameter vector θ and for a given state St , the density of returns can be written in a straightforward manner. Expression (6.1) shows thatthe conditional density depends only on the current regime St and not on past ones. Itshould also be noted that, due to the Markovian character of the regimes, the informationcontained in R t−1 is summarised in St .
6.3 MAXIMUM LIKELIHOOD ESTIMATIONThe likelihood isL = f (R T ; θ ) = f (RT |R T −1 ; θ )f (RT −1 |R T −2 ; θ ) · · · f (R2 |R 1 ; θ )f (R1 ; θ )
(6.2)
and we wish to obtain the maximum likelihood estimateθ ∈ arg max(θ ) ln f (RT ; θ )In order to apply a maximum likelihood procedure on (6.2), it is necessary to introducethe states St so that expression (6.1) can be used. To see how this can be done supposethat θ is given and consider a typical element of the likelihood which can be developedby using obvious probabilistic rules:f (Rt |R t−1 ; θ ) ≡
f (R t ; θ )f (R t−1 ; θ )1
f (Rt |R t−1 ; θ ) =2
f (R t , St ; θ )
St=0
f (R t−1 ; θ )
Notice that there is a link between ρ and p, as we will see later on.Notice that densities (associated with continuous random variables) are written as f (·) and probabilities(associated with discrete random variables) as Pr[·, ·].3
196
Applied Quantitative Methods for Trading and Investment1
f (Rt |R t−1 ; θ ) =
f (Rt |R t−1 , St ; θ )f (R t−1 , St ; θ )
St=0
f (R t−1 ; θ )
Moreover:f (Rt |R t−1 , St ; θ ) =
1
f (Rt |St ; θ ) Pr[St |Rt−1 ; θ ]
(6.3)
St =0
where the last equality follows from (i) the Markovian character of the problem wherebythe knowledge of St summarises the entire history R t−1 so that f (Rt |Rt−1 , St ; θ ) =f (Rt |St ; θ ) and (ii) f (R t−1 , St ; θ )/f (R t−1 ; θ ) = Pr[St |Rt−1 ; θ ].We also have:Pr[St |R t−1 ; θ ] =
1Pr[St , St−1 , R t−1 ; θ ]
f (R t−1 ; θ )
St−1=0
Pr[St |R t−1 ; θ ] =
1Pr[St |St−1 , R t−1 ; θ ] Pr[St−1 , R t−1 ; θ ]
f (R t−1 ; θ )
St−1=0
Pr[St |R t−1 ; θ ] =
1
(6.4)
Pr[St |St−1 ; θ ] Pr[St−1 , R t−1 ; θ ]
St−1=0
The last equality follows from the fact that Pr[St |St−1 , R t−1 ; θ ] = Pr[St |St−1 ; θ ] by theassumption that states evolve according to a ﬁrst-order Markov process.Using Bayes’ formula it follows that:Pr[St−1 |R t−1 ; θ ] =Pr[St−1 |R t−1 ; θ ] =
Pr[St−1 , R t−1 ; θ ]f (R t−1 ; θ )f (Rt−1 , St−1 , R t−2 ; θ )1
f (R t−1 , St−1 ; θ )
St−1 =0
Pr[St−1 |R t−1 ; θ ] =
(6.5)
f (Rt−1 |St−1 ; θ ) Pr[St−1 |R t−2 ; θ ]1
f (Rt−1 |St−1 ; θ ) Pr[St−1 |R t−2 ; θ ]
St−1 =0
Henceforth, at time t − 1, f (Rt−1 |St−1 ; θ ), which is deﬁned in equation (6.1) shows upin natural fashion. If we assume that we know Pr[St−1 |R t−2 ; θ ] then it becomes possibleusing equation (6.5) to compute Pr[St−1 |R t−1 ; θ ] and from equation (6.4) to derive theconditional probability of St given R t−1 . Pr[St |R t−1 ; θ ] can therefore be computed, forall t, in a recursive fashion.The starting value for the probabilities Pr[S1 = j |R0 ; θ ] = Pr[S1 = j ; θ ] = ρj can beeither estimated directly as additional parameters in the maximum likelihood estimation,
Switching Regime Volatility
197
or approximated by the steady state probabilities which have to verifyPr[S1 = i; θ] =
1
Pr[S1 = j ; θ]pij
j =0
⇒ Pr[St = 1; θ ] =
1 − p002 − p11 − p00
and
Pr[St = 0; θ ] =
1 − p112 − p11 − p00
(6.6)
One realises, at this stage, that the likelihood for a given θ can be obtained by iteratingon equation (6.3) which involves the computation of (6.4). As a by-product, the computation of (6.4) involves (6.5) which are the ﬁltered probabilities of being in a given stateconditional on all currently available information Pr[St |Rt ; θ ]. Also forecasts of states canbe easily obtained by iterating on the transition probabilities.Using standard numerical methods, this procedure allows for a fast computation ofthe estimates.
6.4 AN APPLICATION TO FOREIGN EXCHANGE RATESBefore we develop in detail one application of the switching model to the foreign exchangemarkets, we wish to start this section with a brief overview of the functioning of thesemarkets as they offer notable features.6.4.1 Features of the foreign exchange interbank marketIt is interesting to note that, in contrast to other exchange markets, the interbank foreignexchange (also called forex) market has no geographical limitations, since currencies aretraded all over the world, and there is no trading-hours scheme, indeed currencies aretraded around the clock. It is, truly, a 24 hours, 7 days-a-week market.Another notable feature is that, in contrast to other exchange markets too, forex tradersnegotiate deals and agree transactions over the telephone with trading prices and volumes not being known to third parties. The tick quotes are provided by market-makersand conveyed to the data subscribers’ terminal. They are meant to be indicative, providing a general indication of where an exchange rate stands at a given time. Thoughnot necessarily representing the actual rate at which transactions really take place, theseindicative quotes are felt as being fairly accurate and matching the true prices experiencedin the market. Moreover, in order to avoid dealing with the bid–ask bounce, inherent tomost high-frequency data (see, for instance, chapter 3 in Campbell et al. (1997)), use wasmade, for the estimation of the switching model, of the bid series only, generally regardedas a more consistent set of observations.In the following we will use, as an illustration, the USD/DEM exchange rate. The tickby-tick quotes have been supplied by Reuters via Olsen & Associates. We will use dailyquotes which are arbitrarily taken at each working day at 10pm GMT (correspondingapproximately to the closing of Northern American markets). We obviously could haveused a different time of the day and/or different frequencies.It is interesting to note that, in this high-frequency dataset, there are signiﬁcant intraday,intraweek and intrayear seasonal patterns (see Figures 6.1 and 6.2), explained respectivelyby the time zone effect (in the case of the USD/DEM rate, the European and the US time
198
Applied Quantitative Methods for Trading and Investment90080070060050040030020010000
1
2
3
4
5
6
7
8
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23Hour (GMT)
Figure 6.1 Intraday pattern USD/DEM (average number of transactions per hour)800070006000500040003000200010000Sun
Mon
Tue
Wed
Thu
Fri
Figure 6.2 Intraweek pattern USD/DEM (average number of transactions per day of the week)
zones are the most active ones), the low activity exhibited during weekends and someuniversal public holidays (e.g. Christmas, New Year). Some other factors such as therelease of economic indicators by, amongst others, central banks may also induce seasonality in foreign exchange markets. Seasonalities are also investigated by Guillaumeet al. (1997).
Switching Regime Volatility
199
Further descriptions of questions related to intraday data in forex markets can be foundin Baillie and Bollerslev (1989), Goodhart and Figliuoli (1991), Müller et al. (1997) andSchnidrig and Würtz (1995), among others.6.4.2 Descriptive statisticsIn our empirical application of switching models, as previously said, we will use dailyobservations of the USD/DEM exchange rate. We obtain these by sampling from thetick-by-tick data, extracting those recorded at 10pm GMT, from October 1995 to October1998, corresponding to 775 observations overall.Table 6.1 displays the basic descriptive statistics for the USD/DEM foreign exchangereturns, for the tick-by-tick and daily data.There is an enormous difference between the ﬁrst two moments of the series, conﬁrming the dramatic effect of time aggregation (see Ghysels et al. (1998)). As indicated inTable 6.1, daily returns data is negatively skewed, yet in a non-signiﬁcant way. Thissuggests that there exist some strong negative values but not enough to be statistically meaningful.The series exhibits leptokurtosis (which means that the distribution of the data hasthicker tails than a normal one) and heteroskedasticity (or volatility clustering) as shownby the Ljung–Box test on the squared returns. This latter observation is a well knownfeature of ﬁnancial rates of return: large price changes in magnitude, irrespective of sign,are likely to be followed by large price movements; small price changes in magnitude arelikely to be followed by small price movements. Finally, the assumption of normality ofthe data can be rejected at any level of signiﬁcance as indicated by the Jarque–Bera andKolmogorov–Smirnov tests.It is well known from the literature on mixture of distributions that a mixture of normaldistributions can be leptokurtic. This suggests that daily USD/DEM exchange rate returnsare good candidates for being explained by switching among distributions.Table 6.1
Tick-by-tickDaily
Descriptive statistics of the daily and tick-by-tick returns
No. ofobservations
Mean
Variance
Skewness
Kurtosis
Acf(1)
Acf(2)
5 586 417775
2.8E-082.0E-04
4.17E-082.84E-05
−0.09−0.23
13.344.17
−46.3%
0.4%
Ljung–Box (20 lags) critical value at 5% = 31.4Daily returnsSquared daily returns
25.3343.82∗
Normality tests of daily returnsJarque–BeraKolmogorov–Smirnov∗
58.68∗0.0607∗
Denotes parameter estimates statistically signiﬁcant at the 1% level.
200
Applied Quantitative Methods for Trading and Investment
6.4.3 Model empirical resultsWe obtain the estimates for the Markov switching model in a recursive way via maximumlikelihood, under normality for the errors and supposing two volatility regimes.We are using the Gauss software for estimating the model variables. The program ismade up of six parts which are fully described in the Appendix. While the ﬁrst threesections deal with data loading, preparation and the inclusion of the relevant libraries,sections four and ﬁve compute the maximum likelihood estimation of the model’s parameters. The software proposes several optimisation algorithms. We choose the algorithmproposed by Berndt, Hall, Hall and Hausman (BHHH). The last section computes theﬁltered probabilities as described in equation (6.5) and the smoothed probabilities (i.e. theprobabilities of being in a given state conditional on all currently available informationat t − 1: Pr[St |Rt−1 ; θ ]). Full details of the program are given in Appendix A.Table 6.2 shows the estimates for the USD/DEM model. All coefﬁcients are signiﬁcantat the 5% level. The probability of staying in the higher volatility regime (i.e. St = 0) is0.8049, which means that, on average, it lasts for about ﬁve days (1/(1 − 0.8049) = 5.13;see also Hamilton (1989)).6.4.4 Model evaluation strategyModel evaluation is carried out in two ways. Firstly, we test whether the model residualsare normal and non-correlated; we also test if standardised returns follow a normal distribution. This approach provides a common ground for statistically assessing the modelperformance. Our evaluation criterion consists in a thorough analysis of the residuals (i.e.the analysis and testing of the normality assumptions). For the latter, to make things easily reproducible, we have used the two common Jarque–Bera and Kolmogorov–Smirnovtests. Secondly, our evaluation also comprises checking the switching volatility modelthrough its performance in a close to real life hedging strategy.6.4.5 Residuals analysisWe carry out a brief analysis of the residuals of the computed model. Strictly speaking,the term “residuals” is used here for the series of standardised returns (i.e. the returnsseries divided by the forecast volatilities). If the volatility captures well the ﬂuctuationsof the market, and the model’s assumptions are valid, such residuals are expected tobe normal.Table 6.2 Markov switching model: empirical results
µσ0σ1p00p11
Value
Std. error
t-Statistics
Pr(>t)
0.03450.63510.24860.80490.6348
0.01710.02810.03130.06200.0927
2.02322.6037.93412.9766.848
0.02150.00000.00000.00000.0000
Switching Regime Volatility
201
Table 6.3 Model residuals – basic statistics and normality tests
MeanStd. dev.SkewnessExc. kurtosisSample size
Daily returns
Model residuals
0.00430.9944−0.24551.2764775
0.04851.0804−0.13441.2228
Ljung–Box (20 lags) critical value at 5% = 31.4Std. residualsSquared std. residuals
25.3343.82∗
23.616.9
58.68∗0.061∗
49.18∗0.057∗
Normality testsJarque–BeraKolmogorov–Smirnov∗
Denotes parameter estimates statistically signiﬁcant at the 1% level.
4
Switching residuals
2
0
−2
−4−3
−2
−1
0
1
2
3
Quantiles of standard normal
Figure 6.3 Probability plot of the Markov switching model
Table 6.3 presents the basic summary statistics and normality tests for the standardisedlog-returns and the standardised residuals/returns computed from the model. Figure 6.3shows the normal score plot for the standardised returns from the model.Here the normal score plot is used to assess whether the standardised residuals datahave a Gaussian distribution. If that is the case, then the plot will be approximately a
202
Applied Quantitative Methods for Trading and Investment
straight line. The extreme points have more variability than points towards the centre. Aplot that is bent down on the left and bent up on the right means that the data have longertails than the Gaussian.The striking feature is that the model captures fairly well the heteroskedasticity of theunderlying time series (as shown by the Ljung–Box test on the squared residuals) and,therefore, achieves homoskedasticity.Having said that, the switching model residuals do not follow a normal distribution.Both the Jarque–Bera and the Kolmogorov–Smirnov normality tests enable us to rejectthe hypothesis that the residuals follow a normal distribution. Although this does notinvalidate the switching model, this highlights the fact that nonlinearities still exist in theresiduals that the switching model did not manage to capture.6.4.6 Model evaluation with a simple hedging strategyIn this section we show how ﬁltered volatility estimates can be combined with technicaltrend-following systems to improve the performance of these systems.The negative relationship between the performance of trend-following trading systemsand the level of volatility in foreign exchange markets is a well known empirical ﬁnding.In other words, trending periods in the forex markets tend to occur in relatively quiet (i.e.low volatility) periods.We here compare hedging strategies using trend-following systems with similar systemscombined with Markov switching ﬁltered volatility.6.4.6.1 Trend-following moving average modelsAs described by Müller (1995), trend-following systems based on moving average modelsare well known technical solutions, easy to use, and widely applied for actively hedgingforeign exchange rates.The moving average (MA) is a useful tool to summarise the past behaviour of atime series at any given point in time. In the following example, MAs are used inthe form of momenta, that is the difference of the current time series values and anMA. MAs can be deﬁned with different weighting functions of their summation. Thechoice of the weighting function has a key inﬂuence on the success of the MA in itsapplication.Among the MAs, the exponentially weighted moving average (EMA) plays an important role. Its weighting function declines exponentially with the time distance of thepast observations from now. The sequential computation of EMAs along a time seriesis simple as it relies upon a recursion formula. For time series with a strong randomelement, however, the rapidly increasing shape of the exponential function leads to strongweights of the very recent past and hence for short-term noise structures of the timeseries. This is a reason why other MA weighting functions have been found worthy ofinterest in empirical applications. The following subsection presents two families of MAweighting functions. Both families can be developed with repeated applications of theMA/EMA operator.
Switching Regime Volatility
203
6.4.6.2 Moving average deﬁnitionsA moving average of the time series x is a weighted average of the series of elements ofthe past up to now:nwn−j xjMAx,w;n ≡
j =−∞n
(6.7)wn−j
j =−∞
where wk is a series of weights independent of n.A fundamental property of a moving average is its range r (or centre of gravity of theweighted function wk ):∞wk kk=0∞
r≡
(6.8)wk
k=0
The range r of a discrete time series is in units of the time series index, but unlike thisinteger index it can be any positive real number.EMAs have the following declining weights:wk ≡
rr +1
k(6.9)
where r is the centre of gravity. In the case of daily time series, r = (d − 1)/2 (d =number of days in moving average).An EMA can be computed by a recursion formula. If its value EMAx (r, tn−1 ) of theprevious series element xn−1 is known, one can easily compute the value at tn :EMAx (r, tn ) = µEMAx (r, tn−1 ) + (1 − µ)xn
with
µ=
rr +1
(6.10)
or expressed in number of days in the moving average:µ=1−
2d +1
i.e. r =
d −12
(6.11)
The recursion needs an initial value to start with. There is usually no information beforethe ﬁrst series element x1 , which is the natural choice for this initialisation:EMAx (r, t1 ) = x1The error made with this initialisation declines with the factor [r/(r + 1)]n−1 .
(6.12)
204
Applied Quantitative Methods for Trading and Investment
In many applications, the EMA will neither be used at t1 nor in the initial phase aftert1 which is called the built-up time. After the built-up time, when the EMA is used, oneexpects to be (almost) free of initialisation errors.6.4.6.3 Trading rules with EMA trading modelsMA models summarise the past behaviour of a time series at any given point in time.This information is used to identify trends in ﬁnancial markets in order to subsequentlytake positions according to the following rule:If x(tn ) > EMAx (r, tn ) go long (or stay long)If x(tn ) < EMAx (r, tn ) go short (or stay short)with x(tn ) the spot exchange rate at time t. Commission costs of 0.00025 DEM arecharged for each trade. A trade is deﬁned as being long and going short or vice versa.An EMA model is deﬁned by its type (i.e. MA or EMA) and, in the latter case, itscentre of gravity (or number of MA days). There are obviously an inﬁnite number ofdifferent combinations. Our analysis here is arbitrarily limited to one EMA type (i.e. 50days or µ = 0.96).6.4.6.4 Trading rules of EMA trading models with volatility ﬁltersIt is a well known empirical ﬁnding that trend-following systems tend to perform poorlywhen markets become volatile. One possible explanation lies in the fact that, most of thetime, high volatility periods correlate with periods when prices change direction.The previous rules are thus combined with the following new rules:If volatility > volatility threshold T , then reverse position(i.e. go long if current position is short and vice versa)If volatility < volatility threshold T , keep position as indicatedby the underlying MA model6.4.6.5 Trading resultsTable 6.4 shows the numerical results. Strategies based on the EMA model without volatility ﬁltering are leading to approximately zero proﬁt (if commission costs are not included),denoting the inability of the EMA model considered here to detect proﬁtable trends. Thevolatility ﬁlter trading strategy based on ﬁltered probabilities on the other hand is improving considerably the performance of the model. It is interesting to note that, despite thehigher frequency of the trades (253 vs. 65), the performance after transaction costs is stillsigniﬁcantly higher. Lastly, in terms of the risk/reward ratio, the latter model achieves aremarkable performance, although the average proﬁt per annum is average.The ﬁle “Hedging System Simulation.xls” on the CD-Rom contains the raw forex dataas well as the Markovian switching volatility and the moving average computations. Theﬁle is split into three worksheets.
Switching Regime VolatilityTable 6.4
205
Summary results of trading strategies (including transaction costs)
Total proﬁt (%)Average proﬁt per annumMaximum drawdownaNumber of tradesRisk/reward ratiob
Without volatility ﬁlter
With volatility ﬁlter
−4.9%−1.6%19.4%65−0.08
15.4%5.1%10.4%2530.49
aDrawdowns are deﬁned as the difference between the maximum proﬁt potentially realisedto date and the proﬁt (or loss) realised to date. The maximum drawdown is therefore themaximum value of the drawdowns observed in history. It is an estimate of the maximumloss the strategy would have incurred.bDeﬁned as the ratio maximum drawdown/average proﬁt per annum.
The ﬁrst worksheet (“USDDEM EMA System”) contains the basic computation of theEMA model and the trading model simulation. Columns A and B contain the date andthe mid forex rate respectively. Column C contains the EMA computation. The EMAcentre of gravity is input in cell C3. Column E contains the switching volatility ﬁgures.The computation of these ﬁgures is given in the third worksheet (“Backup”, column N);the formula is based on the ﬁltered probabilities, i.e. Pr[St = 0|Rt ]σ0 + Pr[St = 1|Rt ]σ1 .Column F computes the trading signal as described in Sections 6.4.6.3 and 6.4.6.4 above.The volatility threshold is input in cell C4. Columns G to N contain the trading simulationformulas; in particular, columns I, J, K and L contain the proﬁt and loss calculations, whilecolumns M and N compute the drawdowns. The proﬁt and loss ﬁgures are computed“open” in column I (i.e. how much proﬁt/loss is potentially realised by the strategyeach day) and “closed” in column J (i.e. how much proﬁt/loss is effectively realisedat the close of each trade). Columns K and L are merely cumulative computations ofcolumn J and I and give the cumulative proﬁt