Slides Mme2010 LL FP Revised100706

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Application of empirical

mode decomposition to
analyze simulated financial
time series

Ladislav Lukáš1

1 Introduction
Generally accepted paradigm – financial time series – gerenated by
nonlinear and nonstationary processes.
Simulation generator of FX rate – based upon computer agent tech-
niques and temporal dynamic market equilibrium conditions ~ typical
problem-oriented data generator
S(t) m(t) dC(t) + (1-m(t)) aF,1(EFt [S(t+1)] - S(t)) +
(1)
S(t)dB(t) = 0,
S(t) … instantaneous FX rate,
dC(t), dB(t) … dynamic demand of chartists, prospective influence of
central bank,
EFt [S(t+1)] … expectation of future FX rate made by fundamentalists
at the period t,
m(t) … instantaneous market share of chartists,
aF,1 > 0 … multiplier of relative distance between expected future FX
rate and the spot rate.

1
Univ.of West Bohemia, Faculty of Econ., Dept. of Stat. and OR, Husova 11, 30614 Pilsen, lukasl@kso.zcu.cz.

1
Another possibility – how to get financial time series –
Mathematica 7, Wolfram Research, command FinancialData[,] which
provides a direct access to various world financial databases.

2 Empirical mode decomposition


Empirical mode decomposition (EMD) – a relatively new method, ~
decomposition of signal into a series of functions naturally generated
by a data-driven algorithm.
Each such function represents a certain type of oscillations –>
intrinsic mode function (IMF).

Traditional data analysis methods – based on linear and stationary as-


sumptions.

EMD – (original development) – analysis of nonstationary and nonlin-


ear data collected from observation of complicated water waves ~~~>
motivation for analysis of financial time series, too.

A lot of sources – EMD / Hilbert-Huang transform (HHT)


Present view – EMD is a first step of methods based on HHT.

Main advantage of the EMD –


the method is well-adapted to analyze time series generated by nonlin-
ear and nonstationary processes.

Approximation of data by series of functions ~ formal definition ~


approximation of x(t) on a linear span {φj(t)}
n
x(t) = rn(t) + ∑ a φ (t),
j=1
j j (1)

x(t) … data-dependent function to be approximated,

2
{φj(t)}, j=1,..,n … set of approximating basis functions
(orthonormal, a priori defined),
aj … unknown multiplier of each φj(t),
rn(t) … residue ~ error of approximation.

Traditional approach – a priori defined basis functions


- approximation methods differ in levels of sophistication how the ba-
sis functions φj(t) are constructed ~
• polynomials, trigonometric functions – low-level sophisticated
functions,
• wavelets – higher-level ones.

Novel approach – a posteriori defined basis functions


EMD ~ the first method – the basis functions are defined a posteriori,
i.e. they are exclusively data-dependent ones.
Approximation of data by series of IMF-s ~ EMD
n
x(t) = rn(t) + ∑ φ (t),
j=1
j (2)

φj(t), j=1,..,n … intrinsic mode functions (IMFs) generated by data-


driven algorithms exclusively,
rn(t) … EMD residue.

Note: a posteriori-defined basis is a novel approach totally different


from the established mathematical paradigm for data analysis.

However, perfect data adaptability of IMFs has unfortunately a theo-


retical drawback – a general impossibility to express, unless excep-
tional cases, IMFs in analytic form.

3
HHT technique consists of two parts:
- empirical mode decomposition (EMD),
- Hilbert spectral analysis (HSA).

IMF – an oscillatory mode defined by two simple / intuitive / qualita-


tive properties ~>
IMFs which are oscillations with time dependent frequencies and
amplitudes.
P1. (global property) the number of local extrema and number of
zero-crossings must either equal or differ at most by one in the whole
dataset,
P2. (local property) the mean value of the envelope defined by the
local maxima and the envelope defined by the local minima is zero at
any point of data definition interval.

EMD residue rn(t) – an important notion – it controls convergence


of global decomposition process (2), defined by P3.
P3. rn(t) may either be a constant function or a trend being a
monotone function which does not allow extracting any IMF more.

General assumption on data {x(tk)}, k=1,..,K ~ {xk} in short ~


{xk} should reveal a single-valued function x(t) on the whole defini-
tion interval [t1,tK], where t1< t2< …< tK.
This is acceptable in finance ~ any financial time series is a path, i.e.
single-valued function representing a particular realization of a finan-
cial market process.

EMD process extracts IMFs, φj(t), j=1,..,n, from the given dataset {xk}
~ sifting process.

4
EMD algorithm ~ three main blocks:
1. Initial block – setting data {xk} and function x(t) as well, pro-
vided some initial approximation is given, e.g. x(t) = spline({xk}),
set index j=1,
2. Sifting process – extracting j-th IMF φj(t) from data,
3. Construction block – bulding EMD representation of given data
in form (2).

Sifting process ~ core of any EMD algorithm –


purpose: to sift j-th IMF φj(t), j=1,..,n
2.1 Set function hj,0(t) = rj-1(t), j=1,..,n, where r0(t) = x(t), and set in-
dex i=1,
2.2 Locate all local extrema of function hj,i-1 (t)
{tp} j,i-1 = arg loc max(hj,i-1 (t)),
(3)
{tq} j,i-1 = arg loc min(hj,i-1 (t)),
2.3 Construct upper and lower envelopes of hj,i-1 (t) by spline ap-
proximations
u j,i-1 (t) = spline({tp} j,i-1), v j,i-1 (t) = spline({tq} j,i-1), (4)
2.4 Compute the mean of envelopes
m j,i-1 (t) = (u j,i-1 (t) + v j,i-1 (t))/2, (5)
2.5 Extract residue of hj,i-1 (t)
hj,i(t) = hj,i-1 (t) – m j,i-1 (t), (6)
2.6 Check if hj,i(t) satisfies conditions of IMF required
if {hj,i(t) satisfies (P1 et P2)}
then {φj(t) = hj,i(t), goto 3.1} (7)
else { i:=+1, goto 2.2} ,

5
Construction block ~
3.1 Build representation (2) and extract residue rj(t)
n
n: = j, rn(t) = x(t) – ∑ φ (t),
j=1
j (8)

3.2 Check if rn(t) already satisfies conditions of EMD residue re-


quired
if {rn(t) satisfies P3}
then {stop} (9)
else { j:=+1, goto 2.1} ,
Note: (8) enables an alternative recurrent definition of the main part
of EMD construction block as
r0(t) = x(t), rj(t) = rj-1(t) – φj(t), j=1,..,n (10)

3 Numerical experiments
Demonstration – the first step of sifting process.
Three examples:
• 1. simulated dataset,
• two downloaded real FX datasets 2. EUR/CZK, 3. EUR/USD ,
period 2010-01-04 till 2010-06-08.
Calculations performed with Mathematica 7.0, Wolfram Research.

Example 1. Simulated dataset


g1(t) = max[exp(2u1sin(u2t)), exp(1+u3cos(u4t))], (11)
g2(t) = min[exp(2u1sin(u2t)), exp(1+u3cos(u4t))], (12)
f (t) = (g1(t) + g2(t))/2, t ∈ [0,2π], ui ∈ U[0,1], i=1,2,3,4, (13)
Discretization – step ∆t = 2π/100 ~> {f (tk)}

6
{f (tk)}, t1 = 0, t2 = π /50, …, t101 = 2π. (14)

Results: Fig. 1 – Fig. 6 ~ the first sifting step.


u1,0(t), v1,0(t) …upper and lower envelopes ~ cubic spline interpola-
tions from local maxima and minima of dataset {f (tk)} (14)

Figure 1 Function f(t) given by (13) Figure 2 f(t) dashed and envelopes u1,0(t), v1,0(t)

Figure 3 Envelope u1,0(t) of f(t) local maxima Figure 4 Envelope v1,0(t) of f(t) local minima

Figure 5 Function h1,1(t)= f(t) – (u1,0(t) + v1,0(t))/2 Figure 6 f(t) dashed line and h1,1(t)

7
. EUR/CZK , period [2010-01-04 , 2010-06-08], source the
Example 2
CNB web page
EurCzk=Import["EURvsCZKimportMma.dat","List"] (15)

Results: Fig. 7 – Fig. 10

Figure 7 FX rate EUR/CZK, 2010-01-04 / 06-08 Figure 8 f(t) dashed and envelopes u1,0(t), v1,0(t)

Figure 9 Function h1,1(t)= f(t) – (u1,0(t) + v1,0(t))/2 Figure 10 f(t) –25.75 dashed line and h1,1(t)

8
Example 3. EUR/USD , period [2010-01-04 , 2010-06-08], source
Mathematica 7.0 implemented function FinacialData[], which
searched international financial databases available
start="4 Jan,2010"; end="8 June,2010";
(16)
FinacialData["EUR/USD",{start,end}]

Figure 11 FX rate EUR/USD, 2010-01-04 / 06-08 Figure 12 f(t) dashed and envelopes u1,0(t), v1,0(t)

Figure 13 Function h1,1(t)= f(t) – (u1,0(t) + v1,0(t))/2 Figure 14 f(t) –1.33 dashed line and h1,1(t)

4 Conclusion
• An implementation of the EMD algorithm for analysis of finan-
cial time series was discussed ~ FX rates EUR/CZK and
EUR/USD, respectively, and one simulated dataset in particular.
• Demonstration of the sifting process – a core of the EMD – re-
lies heavily both on spline interpolations and IMFs detection and
stopping criteria.
• The greatest advantage – a unified and systematic approach for
analysis of nonlinear and nonstationary time series.
• However, further work is still needed both in algorithmic im-
plementation, accummulation of numerical experience and de-
velopment of theoretical background, too.

9
Acknowledgements
This work was supported by grant No. 402/09/1536 of the Grant Agency of
Czech Republic, and funding by the project LC06075 of the Ministry of Educa-
tion of Czech Republic is gratefully acknowledged, too.

References
[1] Flandrin, P., Rilling, G., Gonçalves, P.: Empirical mode decomposition as a filterbank. IEEE Signal Proc
Lett. 11(2003), 112-114.
[2] Guhathakurta, K., Mukherjee, I., Chowdhury, A.R. Empirical mode decomposition analysis of two different
financial time series and their comparison. Chaos, Solitons and Fractals (2008) 37, 1214-1227.
[3] Huang, et al.: The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary
time series analysis. Proc. R. Soc. Lond. A (1998) 454, 903–995. Available online:
http://keck.ucsf.edu/~schenk/Huang_etal98.pdf
[4] Huang, N.E., Samuel Shen, S.P.: Hilbert-Huang transform and its applications, London : World Scientific,
c2005. Chap.1 available online: http://www.worldscibooks.com/etextbook/5862/5862_chap1.pdf
[5] Lukáš, L.: Market clearing conditions used in FX rate simulation models. Proceedings 22-th Int.Conf.
Mathematical Methods in Economics, Masaryk University Brno, 2004, ISBN 80-210-3496-3, 184-188.
[6] Lukáš, L.: Dynamic equilibrium conditions used for building a family of FX rate simulation models. 12-th
Annual Conf. Computing in Economics and Finance, June 22-25, 2006, Limassol, Cyprus.
[7] http://www.cnb.cz/en/financial_markets

10

You might also like