14
An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency Domain Francois Belletti Electrical Engineering and Computer Sciences University of California at Berkeley Technical Report No. UCB/EECS-2018-12 http://www2.eecs.berkeley.edu/Pubs/TechRpts/2018/EECS-2018-12.html May 1, 2018

An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

An Early Exploration of Causality Analysis for IrregularlySampled Time Series via the Frequency Domain

Francois Belletti

Electrical Engineering and Computer SciencesUniversity of California at Berkeley

Technical Report No. UCB/EECS-2018-12http://www2.eecs.berkeley.edu/Pubs/TechRpts/2018/EECS-2018-12.html

May 1, 2018

Page 2: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

Copyright © 2018, by the author(s).All rights reserved.

Permission to make digital or hard copies of all or part of this work forpersonal or classroom use is granted without fee provided that copies arenot made or distributed for profit or commercial advantage and that copiesbear this notice and the full citation on the first page. To copy otherwise, torepublish, to post on servers or to redistribute to lists, requires prior specificpermission.

Page 3: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

Temgine: enabling scalable and generic stochastic process analysis for irregularly observed time series with a duality of representations

by Francois Belletti

Research Project

Submitted to the Department of Electrical Engineering and Computer Sciences, University of California at Berkeley, in partial satisfaction of the requirements for the degree of Master of Science, Plan II. Approval for the Report and Comprehensive Examination:

Committee:

Professor Alexandre M. Bayen Research Advisor

05.09.2016

* * * * * * *

Professor Joseph E. Gonzalez Second Reader

05.09.2016

Page 4: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

An Early Exploration of Causality Analysis for Irregularly Sampled TimeSeries via the Frequency Domain

Francois W. BellettiComputer Science Dept.

UC [email protected]

Abstract

Linear causal analysis is central to a wide rangeof important application spanning finance, thephysical sciences, and engineering. Much of theexisting literature in linear causal analysis oper-ates in the time domain. Unfortunately, the directapplication of time domain linear causal analy-sis to many real-world time series presents threecritical challenges: irregular temporal sampling,long range dependencies, and scale. Moreover,real-world data is often collected at irregular timeintervals across vast arrays of decentralized sen-sors and with long range dependencies [1] whichmake naive time domain correlation estimatorsspurious [2]. In this paper we present a frequencydomain based estimation framework which nat-urally handles irregularly sampled data and longrange dependencies while enabled memory andcommunication efficient distributed processingof time series data. By operating in the frequencydomain we eliminate the need to interpolate andhelp mitigate the effects of long range depen-dencies. We implement and evaluate our newwork-flow in the distributed setting using ApacheSpark and demonstrate on both Monte Carlo sim-ulations and high-frequency financial trading thatwe can accurately recover causal structure atscale.

1 Introduction

The analysis of time series is central to applications rangingfrom statistical finance [3,4] to climate studies [5] or cyber-physical systems such as the transportation network [6]. Inmany of these applications one is interested in estimatingthe mutual linear predictive properties of events from timeseries data corresponding to a collection of data streamseach of which is a series of pairs (timestamp, observation).

Figure 1: Frequency domain causal analysis work flow for twoirregularly sampled correlated and lagged Brownian motion incre-ments and the derived cross-correlogram of incremements whichhighlights their causal structure. Dotted lines represent 5th, 50thand 95th percentiles respectively. Frequency domain estimationis treated in Section 2 and LRD erasure in Section 3. Once thecross-correlogram has been estimated, practitioners read out thedirection of linear causality in the asymmetry of the curve. Thelag value for which cross-correlation reaches a maximum can beinterpreted as the characteristic delay of causation of the two pro-cesses.

In most applications, observations occur at random, un-evenly spaced and unaligned time stamps. In such a settingwe therefore consider two underlying processes (Xt)t2Rand (Yt)t2R that are only observed at discrete and finitetimestamps in the form of two collections of data points:(xtx)tx2Ix

,�yty�ty2Iy

. We adapt our definition of causal-ity to this different theoretical framework. Let � be acausal convolution kernel with delay ⌧ (i.e. �⌧ (t) = 0

whenever t < ⌧ ), (X) and (Y ) two continuous timestochastic processes, for instance, two Wiener processes.A popular instance of a causation kernel is for instancethe exponential kernel: �(t)⌧,⇥=(↵,�) = ↵ exp(��(t �⌧)) if t > ⌧, 0 otherwise. We assume for instance that (Xt)

is an Ornstein-Uhlenbeck process or a Brownian motion(Wiener process) [7] and

dYt = dWYt +

ˆs2R

�(s)⌧,⇥dX(t�s) (1)

where WY and WX are two independent Brownian mo-

Page 5: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

tions whose increments are classically referred to as the in-novation process. In the following, the parameter ⌧ will bereferred to as lag. We will consider that (Y ) is lagging withcharacteristic delay ⌧ behind (X) which is causing it.

We adopt the cross-correlogram based causality estimationapproach developed in [8], in order to be consistent withGranger’s definition of causality as linear predictive abilityof (dXs<t) and (dYs<t) for the random variable dXt [9].

Let (X) and (Y ) be two Wiener processes. We considerthat (X) has a causal effect on (Y ) if (dXs<t) is a moreaccurate linear predictor of dYt in square norm error than(dYs<t) is an accurate linear predictor of dXt. In otherwords (X) causes (Y ) if and only if

Eh(dXt � E(dXt|dYs, s < t))2

i>

Eh(dYt � E(dYt|dXs, s < t))2

i. (2)

In order to quantify the magnitude of this statistical cau-sation, Huth and Abergel introduced in [8] the Lead-LagRatio (LLR) between (X) and (Y ) as

LLRX)Y =

Ph>0 ⇢

2XY (h)P

h<0 ⇢2XY (h)

(3)

where ⇢XY (·) is the cross-correlation between the secondorder stationary processes (X) and (Y ). The analysis con-ducted in [8] proved (X) causes (Y ) is equivalent to

LLRX)Y < 1

thereby yielding an indicator of causation intensity be-tween processes which depends �⌧,⇥ through (1).

1.1 Challenges with real world data:

Unfortunately, in practical applications, time series datasets often present three main challenges that hinder the es-timation of even linear causal dependencies:

• Irregular Sampling: Observations are collected atirregular intervals both within and across processescomplicating the application of standard causal infer-ence techniques that rely on evenly spaced timestampsthat align across processes.

• Long Range Dependencies (LRD): Long range de-pendencies can result in increased and non vanishingvariance in correlation estimates.

• Scale: Real-world time series are often very large andhigh dimensional and are therefore often stored in dis-tributed fashion and require communication over lim-ited channels to process.

In the following we show as in [8] that naive interpolationof irregularly sampled data may yields spurious causality

inference measurements. We also prove that eliminatingLRD is crucial in order to obtain consistent correlation es-timates. Unfortunately, standard time domain LRD erasurerequires sorting the data chronologically and is thereforecostly in the distributed setting. These costs are further ex-acerbated by time domain fractional differentiation whichscales quadratically with the numbers of samples.

To address these three critical challenge we propose aFourier transform based approach to causal inference. Pro-jecting on a Fourier basis can be done with a simple sumoperator for irregularly sampled data as described in [10].A novel and salient byproduct of our estimation techniqueis that there is no need to sort the data chronologically orgather the data of different sensors on the same computingnode. We use Fourier transforms as a signal compressingrepresentation where cross-correlations and causal depen-dencies can be estimated with sound statistical methods allwhile minimizing memory and communication overhead.In contrast to sub-sampling in which aliasing obscuresshort-range interactions, our methods does not introducealiasing enabling the study of sort-range interactions. Anexciting aspect of compressing by Fourier transforms is thatit only affects the variance of the cross-correlogram with-out destroying the opportunity to study inter-dependenciesat a small time scale.

In section 2 we show that leveraging the frequency domainrepresentation we present communication avoiding consis-tent spectral estimators [11] for cross-dependencies. Wefirst compress the time series by projecting without interpo-lation or reordering directly onto a reduced Fourier basis,thereby locally compressing the data. Spectral estimationthen occurs in the frequency domain prior to being trans-lated back into the time domain with an inverse Fouriertransform. The resulting output can be used to computeunbiased Lead-Lag Ratios and thereby identify statisticalcausation.

In section 3, we provide a method to approximately eraseLRD in the frequency domain, which has tremendous com-putational advantages as opposed to time domain basedmethods. Our analysis of LRD erasure as fractional poleelimination in frequency domain guarantees the causal es-timates we obtain are not spurious unlike those calculatednaively on LRD processes [1, 2]. Finally, we apply thesemethods to synthetic data and several terabytes of real fi-nancial market trade tables.

In section 4, we present a novel analysis of the trade-offbetween estimator variance and communication bandwidthwhich precisely assesses the cost of compressing time se-ries prior to analyzing them. A three-fold analysis estab-lishes the statistical soundness of the contributions that ad-dress the three issues mentioned above. Studying data oncompressed representations comes at an expected cost. Inour setting this supplementary variance can be decreased

Page 6: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

in an iterative manner and with bounded memory cost on asingle machine. These properties cannot be replicated to thebest of our knowledge by time domain based sub-sampling.

2 Interpolation and spurious lead-lag

In this section, we first review existing techniques for in-terpolated time-domain estimation of second-order statis-tics in the context of sparse and random sampling along thetime axis. Interpolating data is a usual solution in order tobe able to use classic time series analysis [10, 12–14]. Un-fortunately it is not always suitable, as it can create spuriouscausality estimates and implies a supplementary memoryburden.

2.1 Second order statistics and interpolated data

In order to infer a linear model from cross-correlogram es-timates by solving the Yule-Walker equations [15] or tocompute a LLR (Eq. (3)) one needs to estimate the cross-correlation structure of two time series. Let (X) and (Y ) betwo centered stochastic processes whose cross-covariancestructure is stationary:

�XY (h) = E (Xt�hYt) . (4)

If data is sampled regularly (xn�t, yn�t)n=0...N�1 a con-sistent estimator for �XY (h) is:

\�xy (h) =1

N � h� 1

N�1X

n=h

x(n�h)�tyn�t (5)

(we use bA to denote an estimator for A). Classically, cross-correlation estimates can subsequently be computed as

\⇢XY (h) =\�XY (h)q

\�XX (0)

\�Y Y (0)

(6)

using any consistent cross-covariance estimator.

Interpolating irregular records:

The standard consistent estimator Eq. (5) cannot be com-puted when (x) and (y) do not share common timestamps.A classical way to circumvent the irregular sampling is-sue is therefore to interpolate the records (xtx)tx2Ix

and�yty�ty2Iy

onto the set of timestamps (n�t)n=0...N�1

therefore yielding two approximations�]xn�t

�n=0...N�1

and (gyn�t)n=0...N�1 that can be studied as a synchronousmultivariate time series. An adapted cross-covariance es-

timate is then\̂�xy (h) =

1N�h�1

PN�1n=h ^x(n�h)�t gyn�t.

While there are many interpolation techniques, a com-monly used method is last observation carried forward(LOCF). Note that interpolation may require substantial ad-ditional memory to render each time series at the resolu-tion of interactions which can be millisecond scale in many

crucial applications such as studying stock market interac-tions.

We now consider the causality inference framework intro-duced in [8] and show how the LOCF interpolation tech-nique creates spurious causality estimates.

Bias in LLR with irregularly sampled data: The LLRcan be computed by several methods. Cross-correlationmeasurements on a symmetric centered interval are suffi-cient statistics for this estimator. Therefore one can use syn-chronous cross-correlation estimates on interpolated data inorder to compute the LLR. Carrying the last observationforward (LOCF) has been proven to create a bias in lag es-timation in [8]. The LOCF interpolation method introducesa causality estimation bias in which a process sampled ata higher frequency will be seen as causing another processwhich is sampled less frequently although these correspondto Brownian motions with simultaneously correlated incre-ments.

2.2 Interpolation-free causality assessment

The Hayashi-Yoshida (HY) estimator was introduced in[16] to address this spurious causality estimation issue. TheHY estimator of cross-correlation does not require data in-terpolation and has been proven to be consistent with pro-cesses sampled on a quantized grid of values [17] in thecontext of High Frequency statistics in finance.

Correlation of Brownian motions: HY is adapted tomeasuring cross-correlations between irregularly sampledBrownian motions. Considering the successor operators for the series of timestamps of a given process, let[t, s(t)]t2Ix

and [t, s(t)]t2Iybe the set of intervals delim-

ited by consecutive observations of x and y respectively.The Hayashi-Yoshida covariance estimator over the covari-ation of (X) and (Y ) [7] is defined as

HY[0,t](x, y) =X

t2Ix,t02Iy :ov(t,t0)

(xs(t) � xt) · (ys(t0) � yt0)

(7)where ov(t, t0) is true if and only if [t, s(t)] and [t0, s(t0)]overlap. The estimator can be trivially normalized so as toyield a correlation estimate.

HY and fractional Brownian motions: No interpolationis required with HY but unfortunately this estimator is onlydesigned to handle full differentiation of standard Brow-nian motions. Figure 2 shows how HY fails to estimatecross-correlation of increments on a fractional Brownianmotion whereas the technique we present succeeds. In thefollowing, we show how our frequency domain based anal-ysis naturally handles irregular observations and is ableto fractionally differentiate the underlying continuous timeprocess. This is in particular necessary when one studiesfactional Brownian motions with correlated increments. Inthe interest of concision, we refer the reader to [18] for the

Page 7: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

Figure 2: LRD Erasure: Monte Carlo simulation (100 samples)of two fractional Brownian motions with Hurst exponent 0.8 andsimultaneously correlated increments. Spurious slowly vanishingcross-correlation hinders the HY estimation but does not affectour estimation with LRD erasure (see Section 3) as evident bynearly zero cross-correlation for non-zero lag.

definition of a fractional Brownian motion.

2.3 Fourier transforms for irregularly sampled data

Our alternative approach to estimating cross-correlogramsis based on the definition of the Fourier transform of astochastic process. Considering a continuous time stochas-tic process (Xt)t2[0...T ] and a frequency f 2 [0 . . . 2⇡], theFourier projection of (X) for the frequency f is defined as

Pf (X) =

ˆ T

t=0Xte

�iftdt (8)

where i is the imaginary number. Much attention hasbeen focused on the benefits of the FFT algorithm whichhas been designed for the very particular base of orderedand regularly sampled observations. Our key insight is togo back to the very definition of the Fourier transformas an integral and express it empirically in summationform [10, 11]. Moreover, if the process (X) is observed attimes (t1, . . . , tN ), one can estimate the Fourier projectionby

cPf (x) =NX

n=1

xtne�iftn . (9)

Therefore we propose the following simple framework forfrequency domain based linear causal inference:

1. Project (x) and (y) on to a reduced Fourier basis.2. Estimate the cross-spectrum of (X) and (Y ) in the

frequency domain.3. Apply the inverse Fourier transform to the cross-

spectrum to recover the cross-correlogram and inferthe linear causal structure.

The intuition behind this estimation method is a change ofbasis that allows us to compute cross-covariance estimateswithout needing to address the irregularity of timestamps.Indeed the power spectrum f(·) is the element-wise Fouriertransform of

� (·) =

�XX (·) �Y X (·)�XY (·) �Y Y (·)

�.

Therefore, in order to estimate this function one may inferwhat corresponds to its frequency domain representationand then compute the inverse Fourier transform of the re-sult.

Projecting onto Reduced Fourier Basis: We first project(X) and (Y ) onto the elements of the Fourier basis of fre-quencies (l�f)l=0...P , namely the pair (Pl�f (X))l=0...Pand (Pl�f (Y ))l=0...P . By projecting onto a single rela-tively small set of orthonormal functions, we are able tocompress and effectively re-align the observations (x) and(y). In practice using only a few thousand basis functionswe are able to accurately recover the cross-correlogram. Fi-nally, this computation is sufficiently fast to execute inter-actively on a single laptop and can be easily expressed us-ing the map-reduce framework.

Estimating the Cross-spectra: Computing projectionsonto a reduce Fourier basis enables exploratory data anal-ysis through the study of the cross-spectrum of (X) and(Y )

(IXY (l�f))l=0...P =

⇣Pl�f (X)⇥ Pl�f (Y )

l=0...P.

(10)An inconsistent estimator for the cross-spectrum is:⇣

\IXY (l�f)⌘

l=0...P=

✓\Pl�f (x)⇥ \Pl�f (y)

l=0...P

.

(11)Local averaging of Eq. (11) with respect to frequenciesis widely used [10, 11, 15] in cross-spectral analysis toidentify the characteristic frequencies at which stochasticprocesses interact although they are observed at irregulartimes. Unfortunately, to compute characteristics delays orLLR (crucial steps in linear causal inference) we still needto estimate the cross-correlogram.

Estimating the Cross-correlogram: To estimate thecross-correlogram we can take the inverse Fourier trans-form of the cross-spectrum (IXY (l�f))l=0...P whichtranslates frequency analysis back into the time domain:

�PXY (h) =

1

P

PX

l=0

IXY (l�f) eil�fh. (12)

Using the following consistent estimator:

d�PXY (h) =

1

P

PX

l=0

cIxy (l�f) eil�fh (13)

of the cross-covariance we can directly compute a con-sistent estimator of the cross-correlation using equationEq. (6). The cross-correlation between (X) and (Y ) cannow be estimated in the time domain with a discrete gridGh of lag values ranging from �L�h to L�h with a reso-lution �h. As expected, aliasing will occur if the user spec-ifies a resolution in the cross-correlation estimate that is

Page 8: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

much higher than the average sampling frequency of thetime series [10].

In contrast to more cumbersome time domain synchroniza-tion relying on interpolation based methods (LOCF) or in-terval matching based estimations (HY), our method ele-gantly addresses time synchronization in the frequency do-main. While earlier work [10, 11] has considered the ap-plication of frequency domain analytics to irregularly sam-pled data, our method is the first to translate back to thetime domain to recover a consistent estimator of the linearcausal structure. Alternatively, Lomb-Scargle periodogram[19, 20] also enables the frequency domain analysis of ir-regularly observed data but suffers from the supplementarycost of a least square regression. To the best of our knowl-edge we are the first to use frequency domain projectionsin order to compute the cross-correlogram in order to inferlinear causal structure.

2.4 The statistical cost of compression

Central to the communication and memory performance ofour technique is the ability to use a small number of Fourierprojections relative to the number of observations and stillaccurately recover the cross-correlogram.

Cross-correlogram Estimator Consistency: We can char-acterize the statistical properties of the cross-spectral esti-mator [10, 11, 15]. In particular, it is well known that fortwo distinct non-zero frequencies f1 and f2 the estima-tors \IXY (f1) and \IXY (f2) are asymptotically independent.Consequently, to obtain an estimator with variance O(V )

the user will need to project on 1V frequencies. We con-

firm this result numerically in Figure 6. The element-wiseproduct of Fourier transforms is converted into the timedomain by the inverse Fourier transform to yield a cross-correlogram. With very large datasets in which N >> 1

Vwe obtain the suitable compression property of our algo-rithm.

Issues with Non-smooth Cross-correlograms: As ex-pected, deterministic lags or seasonal components can re-sult in Fourier compression artifacts in the inverse Fouriertransform. However, statistical estimation and removal ofthese deterministic components is standard in time seriesanalysis [11, 15]. In the context of estimating non-trivialstochastic causal relationships (e.g., social networks, pairsof stock prices the financial markets, cyberphysical sys-tems) random perturbations affect the causation delay. Inthese settings, the theoretical cross-correlation function issmooth. As a consequence, a few Fourier projections suf-fice to accurately represent the cross-correlogram in fre-quency domain.

2.5 Example of time domain exploratory dataanalysis through the frequency domain

The time domain exploratory analysis we enable makeslead-lag relationships self-explanatory as shown in Fig-ure 1. We show in the following that it is not hindered bybiases related to the fact that one process is sampled moreseldom than the other.

Numerical assessment of frequency domain based cor-relation measurements: We demonstrate, through simu-lation, that the spurious causation issue that plagues theLOCF interpolation [8] does not appear in our proposedmethod. We consider two synthetic correlated Brownianmotions that do not feature any lead-lag and compare theestimation of LLR provided by two time domain interpola-tion methods and our approach. After having sampled theseat random timestamps, in Table 1 and Figure 3 we comparethe cross-correlation and LLR estimates obtained by LOCFinterpolation and our proposed frequency domain analysistechnique confirming that our method does not introducespurious causal estimation bias.

N1N2

LOCF interpolation LLR Fourier transform LLRAvg +- std Avg +- std

1 0.998 +�0.135 1.021 +�0.1664.5 6.863 +�1.678 1.053 +�0.32010 7.277 +�1.854, 1.107 +�0.391

Table 1: Comparison of LLR ratios with LOCF and Fouriertransforms (1000 projections) for simultaneously correlatedBrownian motions with different sampling frequencies. The LLRratios should all be 1, one can observe the bias in the LOCFmethod.

3 The Long Range Dependence (LRD) Issue

A stochastic process is said to be long range dependentif it features cross-correlation magnitudes whose sum isinfinite [1]. Many issues arise in that case with correla-tion estimates becoming spurious. This phenomenon wasfirst discover when Granger studied the concept of cointe-gration between Brownian motions (integrated time series)[2]. On sorted Brownian motion data, this effect can be ad-dressed by differentiating the time series, namely comput-ing (�Xt)t2Z = (Xt �Xt�1)t2Z. For fractional Brown-ian motion and LRD time series, the fractional differentia-tion operator needs to be computed. It is defined as

(�

↵Xt)t2Z =

1X

h=0

Qh�1j=0 (↵� j) (�Xt�h)

h

h!

!

t2Z.

(14)Therefore, to study the cross-correlation structure of twointegrated or fractionally integrated time series, one wouldhave to compute (�Xt)t2Z or (�↵Xt)t2Z. The latter re-quires chronologically sorted data and synchronous times-

Page 9: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

LOCF cross-correlation Fourier cross-correlation

Figure 3: Cross-correlograms of LOCF interpolated data versusestimation via compression in frequency domain. The latter esti-mate does not present any spurious asymmetry due to the unevensampling frequencies

tamps and has a quadratic time complexity with respect tothe number of samples.

3.1 Erasing memory in the frequency domain

Erasing memory is of prime importance, in the case of thestudy of Brownian motions and fractional Brownian mo-tions alike. As pointed out in [1], LRD arises in many sys-tems, in particular those managed by humans, because oftheir ability to learn from previous events and thereforekeep of memory of these in their future actions. From acomputational and statistical point of view, it is challeng-ing to erase.

Equivalence between differentiation in time domainand element-wise multiplication in frequency domain:Let (Xt)t2[0,T ] be a continuous process whose fractionaldifferentiate of degree ↵, d↵X is Lebesgue-integrable withprobability 1. If Xt vanishes at the boundaries of the inter-val, classically, almost surely,

Pf (d↵X) =

ˆ T

t=0e�iftd↵Xt = (if)↵

ˆ T

t=0e�iftXtdt

by a stochastic integration by part. Therefore, an estimatefor Pf (d↵x) is

\Pf (d↵X) = (if)↵ \Pf (X).

Erasing memory through fractional pole elimination:The power spectrum of a fractional Brownian motion [18]with Hurst exponent H is asymptotically 1

f2H+1 for f <<1. This is the characteristic spectral signature of a longrange dependent time series. H can therefore be estimatedby the classical periodogram method for an individual timeseries by conducting a linear regression on the magnitudeof the power spectrum about 0 in a log/log scale [21].Wavelets are another family of orthogonal basis enablinga similar estimation [22]. One can therefore see the frac-tional differentiation operator of order H +

1/2 as a meansto compensate for a pole of order 2H + 1 in square mag-nitude in 0. Multiplying the Fourier transform of the signalby (if)H+1/2 eliminates the issue. It does not require anypreprocessing of the data, no interpolation or re-orderingand we will show below that it has tremendous computa-tional advantages in the context of distributed computingin terms of communication avoidance.

An approximation of differentiation in the case ofdiscrete observations: It is noteworthy though that thismethod is intrinsically approximate in the practical contextof discrete sampling. Indeed the multiplication rule for dif-ferentiation in frequency domain we proved in the contextof stochastic processes does not directly apply in the con-text of discrete observations. In order to ensure the sound-ness of the novel technique we designed, we conduct sev-eral numerical experiments.

3.2 Testing frequency domain LRD erasure

The example below considers two fractional Brownian mo-tions (X) and (Y ) Brownian motions with Hurst expo-nent H = 0.4 [1]. We compare the empirical distribu-tions of cross-correlation estimates obtained over 100 tri-als with and without LRD erasure in frequency domain. InFigure 4 we showcase an experiment with 9998 uniformlyrandom observations for (X) and 6000 uniformly randomobservations for (Y ). While naive cross-correlation esti-mations lead to many spurious cross-correlation estimateswith significantly high magnitudes of estimated correlationvalues for processes that are in fact independent, (90% ofthe empirical distribution between �0.9 and 0.9) the confi-dence interval we obtain with our novel frequency domainerasure method by fractional pole elimination is narrower(90% of the empirical distribution between �0.05 and0.05) and enables reliable analysis. The next section willexpose the computational advantages of such a frequencydomain based estimation as a communication avoidancemechanism.

4 Distribution

Scalable computation is essential to practical causal in-ference in real-world big data sets. Our proposed fre-quency domain approach provides a parallel communi-

Page 10: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

Figure 4: Spurious cross-correlation is erased by pole elimi-nation in frequency domain. The empirical cross-correlation dis-tribution on the left is affected by high magnitude spurious es-timates. On the right, frequency domain fractional pole erasureeliminated the issue, considerably narrowing down the intervalbetween the 5th and 95th percentiles.

cation avoiding mechanism to efficiently compress largetime-series data sets while still enabling the estimation ofcross-correlograms.

4.1 Computational setting

Cluster computing presents the opportunity to enable fasteranalysis by leveraging the scale-out compute resources inmodern data-centers. However to leverage scale-out clus-ter computing it is essential to minimize communicationacross the network as network latency and bandwidth canbe orders of magnitude slower than RAM [23, 24].

4.2 Computational advantages

One mechanism to distribute time domain analysis oftime series is to construct overlapping blocks as describedin [25]. However, this technique only works if there isno LRD. The need to specify the appropriate replica-tion padding duration at preprocessing time makes it dif-ficult to switch between the time scales at which cross-dependencies are computed.

The novel frequency domain based methods we proposecan entirely be expressed as trivial map-reduce aggregationoperations and do not require sorting or interpolating thedata. Indeed, the use of projections on a subset of a Fourierbasis only requires element-wise multiplication and then anaggregated sum to construct a unique concise signature infrequency domain for each time series that was observed.The amount of compression can be chosen by the user.This yields a flexible frequency domain probing method.Projecting on a few elements of the Fourier basis substan-tially reduces communication and memory complexity as-sociated with the estimation of cross-correlograms. As aconsequence, the user can dynamically adjust the numberof projections in order to progressively reduce the varianceof the estimator.

4.3 Fourier compression as a communicationavoidance algorithm

The computation of Fourier projections is communicationefficient in the distributed setting. The Fourier projectioncan be calculated by locally computing the sum of the map-ping of multiplications by complex exponentials. Then,only the local partial sums need to be transmitted acrossthe network to compute the projections of the entire dataset. In this section, we study d distinct processes with Ndata points each. Let V denote the desired variance for thecross-correlation estimator via the frequency domain.

Communication cost of aggregation with indi-rect frequency domain covariance estimates:Now consider the set of Fourier projections⇣cPf (x) =

PNn=1 xtne

�iftn⌘

f=0,�f,...,P�fwhich

we aggregate on each single machine separately prior tosending them over the network. The number of projectionsneeded to have an estimator for cross-correlation withvariance V is O(

1V ). Therefore, the size of the message

sent out by each machine over the communication mediumis now O(d 1

V ) and representative of O(dN) data points.If the user chooses 1

V ⌧ N , our method effectively com-presses the data prior to transmitting it over the network.It is noteworthy that the gain offered by this algorithm issystem independent as long as communication betweencomputing cores is the main bottleneck.

Distributed LRD erasure: The computational complex-ity of fractional differentiation (Eq. (14)) is O(N2d) inthe time domain. Furthermore, due to LRD, time domainfractional differentiation cannot be accomplished using theoverlapping partitioning strategy proposed in [25]. More-over, in distributed system, computing the fractional differ-entiation of a signal would require transmitting the entiredata set across the network. As a consequence the band-width needed is O(Nd).

Alternatively, fractional differentiation in the frequency do-main is both computationally efficient and easily paralleliz-able. Once the Fourier transforms have been computed thenow substantially compressed frequency domain represen-tation can be collected on a single machine for further anal-ysis. We then proceed with the elimination of fractionalpoles by a simple element-wise multiplication. No supple-mentary communication is needed to erase LRD and there-fore the size of the data transmitted across the network isjust O(

1V d) as opposed to O (Nd). This remarkable im-

provement in communication requires only a modest com-putational cost of O(

1V ) projections per data point on slave

machines.

The compute time therefore allows an interactive experi-ence for the user and becomes even shorter with a dis-tributed implementation on several machines. For example,on a single processor with a 2013 MacbookPro Retina we

Page 11: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

were able to compute 3000 projections on 10

5 samples inroughly a minute.

Method Time complexity Communicationon slave size

Time domain O(Nd2) O(Nd+ d2)Fourier projection O(Nd 1

V ) O(d 1V )

Memory: A potential concern with the frequency domainapproach is that the aggregation of the Fourier projectionsto a single device could exceed the device’s memory. Thedevice will have to store projections of size O(

1V d), com-

pute element-wise products with time complexity O(d2 1V ),

and store the cross-correlation estimates in a memory con-tainer of size O(d2). In particular, the maximum size of thememory needed by the algorithm on the master is O(

1V d2)

which is small relative to the size of the data set in our cur-rent setting. Indeed, we assume that N is large enough andtherefore 1

V << N .

5 Causality estimation on actual data

Identifying leading components on the stock market is in-sightful in terms of assessing which stocks move the mar-ket and highlights the characteristic latency of trading re-actions. Consider two stocks, for instance AAPL and IBM(shares of Apple Inc. and IBM traded in the New York stockexchange). The trade and quote table of Thomson Reutersrecords all bids, asks, trades in volume and price. It is there-fore interesting to check if there is a causation link betweenthe price at which AAPL is traded as compared to that ofIBM. In particular, if we see an increase in the price ofthe former can we expect an increase shortly after in thelater? With which delay? Weak causation or short delay in-dicates an efficient market with few arbitrage opportunities.Significant causation and longer delays would enable highfrequency actors to take advantage of the causal empiricalrelationship in order to conduct statistical arbitrage [3].

5.1 Causal pairs of stocks

One critical application of the generic method we presentis identifying which characteristic delays the NYSE stockmarket features as well as Lead-Lag ratios between pairsof stocks. Lead-Lag ratios that are significantly differentfrom 1.0 indicate that changes in the price of one stocktrigger changes in the price of another. This indicates pairarbitrageurs are most likely using high frequency arbitragestrategies on this pair of stocks.

5.2 Using Full Tick data

In order to highlight significant cross-correlation betweenpairs of stocks, one needs to consider high frequency dy-namics. As we will show in the following, cross-correlationvanishes after a few milliseconds on most stocks and fu-

tures. In these settings it is then necessary to use full res-olution data which in this instance comes in the form ofFull Tick quote and trade tables (TAQ). These TAQ ta-bles record bids, asks and exchanges on the stock marketas they happen. The timestamps are therefore irregular andnot common to different pairs of stocks. Also, stock pricesare Brownian motions and therefore feature long memory.This context is therefore in the very scope of data intensivetasks we consider. We show our novel Fourier compressionbased cross-correlation estimator provides consistent esti-mates in this setting.

5.3 Checking the consistency of the estimator

Consider ask and bid quotes during one month worthof data. We create a surrogate noisy lagged version ofAAPL with a 13ms delay and 91% correlation whichis named AAPL-LAG. We study fours pairs of timeseries: APPL/APPL-LAG, AAPL/IBM, AAPL/MSFT,MSFT/IBM. We study the changes in quoted prices (moreexactly, volume averaged bid and ask prices). We ob-tained quote data for these stocks at millisecond time res-olution representing several months of trading. We re-moved observations with redundant timestamps. The cross-correlograms obtained below are computed between 10AM and 2PM for 61 days in January, February and March2012. For each process, 3000 frequencies were used inthe Fourier basis which is several orders-of-magnitude lessthan the number of observations that we get per day whichranges from 5 ⇥ 10

4 to 1 ⇥ 10

5. The estimate cross-correlograms in Figure 5 and their empirical significanceintervals show that our estimator is consistent and does notsuffer from non-vanishing variance as a result of LRD. Weobserve an 89% average peak cross-correlation with an 8msdelay for the surrogate pair of AAPL stocks which confirmsour estimator is reliable with empirical data. While we ob-serve the Fourier compression artifacts, these only occurbecause our surrogate data features a deterministic delay.They do not affect pairs of actual observed processes. InFigures 5 and 6 we highlight a taxonomy of causal rela-tionships and show in particular that with our definitionof causality anchored in linear predictions, a process maycause another one without any significant delay. This mayalso be symptomatic of a delay shorter than the millisecondresolution of our timestamps.

5.4 Choosing the number of projections

In order to guide practitioners in their choice of the num-ber of Fourier basis elements to project onto, we conduct anumerical experiment on actual data. We compute an em-pirical standard deviation of the daily cross-correlogramobtained in January 2012 (19 days) for JPM (JP MorganChase) and GS (Goldman Sachs) with 10, 100, 1000 and10000 projections. Figures 6 and 8 show that, as expected,the variance decreases linearly with the number of projec-

Page 12: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

Figure 5: Average of daily cross-correlograms pairs of stocktrade and quote data. Compression ratio is < 5%. We retrievelag and correlation accurately on surrogate data. The daily aver-aged cross-correlogram of AAPL and IBM is strongly asymmet-ric, therefore highlight that AAPL causes IBM. The symmetrybetween AAPL and MSFT shows there is no such relationshipbetween them. Finally, symmetric and offset in correlation peakshow that MSFT causes IBM with a millisecond latency.

tions and we can obtain reliable estimates with 1000 pro-jections.

5.5 Studying causality at scale

A primary goal of this work is to enable practical scalablecausal inference for time series analysis. To evaluate scala-bility in a real-world setting in which 1

V << N , we assessthe relation between AAPL and MSFT over the course of3 months. In contrast to our earlier experiments (shown inFigure 5), we no longer average daily cross-correlogramsin and therefore only leverage concentration in the inverseFourier transform step of the procedure. With only 3000

projections for 5 ⇥ 10

6 observations per time series, theresults we obtain on Figure 7 reveals the causal relationbetween AAPL, AAPL-LAG, IBM and MSFT consistentlywith Figure 5.

Scalability: In order to assess the scalability of the algo-rithm in a situation where communication is a major bottle-neck, we run the experiment with Apache Spark on Ama-zon Web Services EC2 machines of type r3.2xlarge. In Fig-ure 8 we show that even with a large number of projections(10000) the communication burden is still low enough toachieve speed-up proportional to the number of machinesused.

6 Conclusion

Time series analysis via the frequency domain presentsseveral presents unique opportunities in terms of provid-ing consistent causal estimates and scaling on distributedsystems. We proposed a communication avoiding method

Figure 6: The empirical variance of cross-correlogram of JPMand GS computed daily over the month of January 2012 decreaseswith the number of projections we choose, a number between 103

and 104 is comfortable. This is to be compared with the 5 ⇥ 104

to 105 samples taken into account each day, or 3⇥106 to 6⇥106

samples over the 60-trading day window of study. The standarddeviation of each cross-correlogram is represented in Figure 8.

Figure 7: Compression ratio is < 1%. On the entire data setwe retrieve results similar to 5 therefore validating the use of ourestimation of cross-correlograms in a scalable manner thanks toFourier domain compression.

to analyze causality which does not require any sorting orjoining of data, works naturally with irregular timestampswithout creating spurious causal estimates and makes theerasure of Long-Range dependencies embarrassingly par-allel. Our approach is based on Fourier transforms as com-pression operators that do not modify the second orderproperties of stochastic processes. Applying an inverseFourier transform to the resulting estimated spectra enablesexploration of dependencies in the time domain. With theresulting consistent cross-correlogram, one can computeLead-Lag ratios and characteristic delays between pro-cesses thereby infer linear causal structure. We show thatprojecting onto 3000 Fourier basis elements is sufficientto study stock market pair causality with tens of millionsof high frequency recordings, thereby providing insightfulanalytics in a generic and scalable manner.

Page 13: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

Figure 8: On the left we plot the empirical standard deviationof daily cross-correlograms (Figure 6) with respect to the num-ber of projections showing that the variability decreases rapidly.On the right we plot the run time performance of our algorithmversus the number of Apache Spark EC2 machines demonstratingapproximately linear speedup. The small number of projections(104) relative to the size of the data set (107 records) avoids com-munication.

7 Future work

Our future work will focus on using the Yule-Walker equa-tions so as to turn the cross-correlation estimates we pre-sented into linear predictive models. Confidence bandsshould also be obtained for the estimators thanks to anasymptotic distribution study akin to the proof of theBartlett formula.

References

[1] P. Doukhan, G. Oppenheim, and M. S. Taqqu,Theory and applications of long-range dependence.Springer Science & Business Media, 2003.

[2] C. W. Granger, “Causality, cointegration, and con-trol,” Journal of Economic Dynamics and Control,vol. 12, no. 2, pp. 551–559, 1988.

[3] F. Abergel, J.-P. Bouchaud, T. Foucault, C.-A.Lehalle, and M. Rosenbaum, Market microstructure:confronting many viewpoints. John Wiley & Sons,2012.

[4] R. S. Tsay, Analysis of financial time series. JohnWiley & Sons, 2005, vol. 543.

[5] M. Mudelsee, Climate time series analysis. Springer,2013.

[6] P. Shang, X. Li, and S. Kamae, “Chaotic analysisof traffic time series,” Chaos, Solitons & Fractals,vol. 25, no. 1, pp. 121–128, 2005.

[7] I. Karatzas and S. Shreve, Brownian motion andstochastic calculus. Springer Science & BusinessMedia, 2012, vol. 113.

[8] N. Huth and F. Abergel, “High frequency lead/lag re-lationships - empirical facts,” Journal of Empirical Fi-nance, vol. 26, pp. 41–58, 2014.

[9] C. W. Granger, “Investigating causal relations byeconometric models and cross-spectral methods,”Econometrica: Journal of the Econometric Society,pp. 424–438, 1969.

[10] E. Parzen, Time Series Analysis of Irregularly Ob-served Data: Proceedings of a Symposium Held atTexas A & M University, College Station, TexasFebruary 10–13, 1983. Springer Science & Busi-ness Media, 2012, vol. 25.

[11] D. R. Brillinger, Time series: data analysis and the-ory. Siam, 1981, vol. 36.

[12] N. Wiener, Extrapolation, interpolation, and smooth-ing of stationary time series. MIT press Cambridge,MA, 1949, vol. 2.

[13] M. Friedman, “The interpolation of time series by re-lated series,” Journal of the American Statistical As-sociation, vol. 57, no. 300, pp. 729–757, 1962.

[14] P. S. Linsay, “An efficient method of forecastingchaotic time series using linear interpolation,” PhysicsLetters A, vol. 153, no. 6, pp. 353–356, 1991.

Page 14: An Early Exploration of Causality Analysis for Irregularly Sampled … · 2020. 6. 11. · An Early Exploration of Causality Analysis for Irregularly Sampled Time Series via the Frequency

[15] P. J. Brockwell and R. A. Davis, Time Series: Theoryand Methods. New York, NY, USA: Springer-VerlagNew York, Inc., 1986.

[16] T. Hayashi, N. Yoshida et al., “On covariance esti-mation of non-synchronously observed diffusion pro-cesses,” Bernoulli, vol. 11, no. 2, pp. 359–379, 2005.

[17] M. Hoffmann, M. Rosenbaum, N. Yoshida et al.,“Estimation of the lead-lag parameter from non-synchronous data,” Bernoulli, vol. 19, no. 2, pp. 426–461, 2013.

[18] P. Flandrin, “On the spectrum of fractional brownianmotions,” Information Theory, IEEE Transactions on,vol. 35, no. 1, pp. 197–199, 1989.

[19] J. D. Scargle, “Studies in astronomical time seriesanalysis. ii-statistical aspects of spectral analysis ofunevenly spaced data,” The Astrophysical Journal,vol. 263, pp. 835–853, 1982.

[20] N. R. Lomb, “Least-squares frequency analysis of un-equally spaced data,” Astrophysics and space science,vol. 39, no. 2, pp. 447–462, 1976.

[21] W. Palma, Long-memory time series: theory andmethods. John Wiley & Sons, 2007, vol. 662.

[22] D. B. Percival and A. T. Walden, Wavelet methods fortime series analysis. Cambridge university press,2006, vol. 4.

[23] D. Peleg, “Distributed computing,” SIAM Mono-graphs on discrete mathematics and applications,vol. 5, 2000.

[24] V. Kumar, A. Grama, A. Gupta, and G. Karypis, In-troduction to parallel computing: design and analysisof algorithms. Benjamin/Cummings Redwood City,CA, 1994, vol. 400.

[25] F. Belletti, E. Sparks, M. Franklin, and A. M. Bayen,“Embarrassingly parallel time series analysis forlarge scale weak memory systems,” arXiv preprintarXiv:1511.06493, 2015.