Category Archives: Time Series

Weird behavior in high frequency markets

Algorithmic trading gone wild!


Continue reading

Tagged , ,

Using a variety of identification methods and samples, I find that in most cases private spending falls significantly in response to an increase in government spending. These results imply that the average GDP multiplier lies below unity.

Continue reading

Fiscal stimulus

Tagged , , ,

Alan V. Oppenheim’s lectures on Digital Signal Processing (1975)

The MIT has just uploaded Alan V. Oppenheim‘s DSP lectures on youtube.

See more here (and enjoy!)

Tagged , ,

Early time series

The graph (part of a commentary of Macrobius on Cicero’s In Somnium Scipionis) which dates from the tenth, possible eleventh century  was meant to represent a plot of the inclinations of the planetary orbits as a function of the time. The zone of the zodiac is given on a plane with the horizontal (time) axis divided into thirty parts and the ordinate representing the width of the zodiacal belt.


Source: “Time-Series”, Sir Maurice Kendall

Tagged ,

Trend extraction and Detrending

Filters may be applied to a time series for a variety of reasons. Suppose that a time series consists of a long-term movement, a trend, upon which is superimposed an irregular component. A moving average filter will smooth the series revealing the trend more clearly.

Assume that m_{t} is the filtered version of the y_{t} series. Then

m_{t} = M_{n}(L)y_{t} =\sum_{j=-r}^{j=r} w_{j}y_{t-j}


The weights of a moving average filters add up to one i.e.  M_{n}(L)=1. The simplest such filter is the uniform moving average for which:

w_{j} = \frac{1}{n} \; \; \; \; j=-r,...,r


The gain of such filter is

M_{n}(e^{-i \lambda}) = \left| \sum_{j=-r}^{r} \frac{1}{n} e^{-ij\lambda} \right| = \left| \frac{1}{n} \left( 1+2 \sum_{j=1}^{r} cos \lambda_{j} \right) \right| = \left| \frac{sin (n \lambda /2)}{n sin (\lambda /2)} \right|




Gain of uniform moving average filter

The uniform moving average filter (applied on artificial data)

The Moving Average filter removes a cycle of period n together with its harmonics.

Continue reading

Tagged , , ,

Nonlinearities and Thresholds

Jökulsá á Fjöllum nonlinearities


The infamous nonlinearity first observed by  Tong et al. (1985).  This nonlinearity is the effect of the melting of glaciers in the catchment area of Jökulsá á Fjöllum (Jokulsa River) on the latter’s flow.


Continue reading

Tagged , ,

Why is the Hodrick-Prescott filter often inappropriate?

The Hodrick-Prescott (HP) filter is the optimal estimator of the trend component in a smooth trend model with signal-to-noise ratio parameter fixed at 1/1600. It gives the detrended observations, X_{t},  for large samples and t not near the beginning or end of the series


\displaystyle X_{t}= \left[ \frac{(1-L)^{2}(1-L^{-1})^{2}}{\bar{q}_{\zeta}+ (1-L)^{2}(1-L^{-1})^{2}}\right] Y_{t}


where \bar{q}_{\zeta}= \sigma_{\zeta}^{2} / \sigma_{\epsilon}^{2} .


Bear in mind that if the  smooth trend model was believed to be the true model there would be no reason to apply the HP filter. The filtered data of a smooth trend model contain nothing more than white noise. The belief here is clearly different.


We can easily show that the gain from the detrending filter is given by:

G(\lambda) = \frac{4(1-cos \lambda)^{2}}{\bar{q}_{\zeta}+4(1-cos \lambda)^{2}} = \frac{16sin^{4}( \lambda /2)}{\bar{q}_{\zeta}+16sin^{4}( \lambda /2)}

Note that the smaller the {\bar{q}_{\zeta}} the more the filter concentrates on removing low frequencies.


Gain for HP filter

Continue reading

Tagged , , , , ,

Some notes on Linear Filters

Let \{ X_t \} and  \{ Y_t \} be two stationary time series related by:


X_{t} = M_{n}(L)Y_{t} =\sum_{j=- \infty}^{j=\infty} g_{j}Y_{t-j}


\sum_{j=- \infty}^{j=\infty}|g_{j}| < \infty and  \sum_{j=- \infty}^{j=\infty}|g_{j}|^2 < \infty


\{ X_t \} is the filtered version of  \{ Y_t \} and M_{n}(L) is the filter. The effect of a linear filter is to change the importance of various cyclical components of the series and/or induce a shift with regard to the position in time.


Continue reading

Tagged , , ,

ARIMA spectrum

It is ofter useful to examine time-series from a frequency perspective. Note that  the power spectrum is defined as

f_{y}(\lambda)=\underbrace{|M(e^{-i\lambda})|^{2}}_{| \Gamma ( \omega) |^{2}}f_{x}(\lambda)



is the spectral generating function. For ARIMA

f_{y}(\lambda)= \frac{\sigma}{2 \pi}\frac{|\theta(e^{-i\lambda})|^{2}}{|\phi(e^{-i\lambda})|^{2}}

The following simple R code generates spectra for ARMA class time series.

spectrums<- function (AR,MA, sigma)
n<- length(AR)
m<- length(MA)
AR<- matrix(AR)
AR[-1]<- -AR[-1]
MA<- matrix(MA)
flp<- c()
for (i in 1:100){
TAR<- matrix(exp(0:(n-1)*i*pi/100*1i))
TMA<- matrix(exp(0:(m-1)*i*pi/100*1i))
ARs<- (t(AR)%*%TAR)*Conj(t(AR)%*%TAR)
MAs<- (t(MA)%*%TMA)*Conj(t(MA)%*%TMA)
fl<- 1/(2*pi)*MAs/ARs


#instruction: spectrums(AR parameters, MA parameters, Variance)

# For AR1 AR=c(1,phi1) MA=c(1), for ARMA(2,2) AR=c(1,phi1,phi2), MA=c(1,theta1, theta2) par(mfrow=c(2,2))

#example ARMA(1,1) phi=0.4, theta=-0.6

plot(spectrums(AR<- c(1,.4),MA<- c(1,-0.6), sigma<-1),ylab="ARMA(0.4,-0.6)", type="l")

#example AR(1) phi=0.5

plot(spectrums(AR<- c(1,.5),MA<- c(1), sigma<-1),ylab="AR1(0.5)", type="l")

#example AR(1) phi=0.8

plot(spectrums(AR<- c(1,.8),MA<- c(1), sigma<-1),ylab="AR1(0.8)", type="l")

#example MA(2) theta1=-0.6, theta2=-0.4

plot(spectrums(AR<- c(1),MA<- c(1,-0.6,-0.4),sigma<-1),ylab="MA2(-0.6,-0.4)", type="l")

Note that it is also very  easy to apply a linear filter (or a series of them) to a given time series (or to generate its spectral density function). For example a moving average filter could be applied to a given AR(1) process by executing the following command

2*pi*spectrums(AR<- c(1),MA<- c(1/3,1/3,1/3),sigma<-1)*spectrums(AR<- c(1,-0.8,MA<- c(1),sigma<-1)

and a second difference filter

2*pi*spectrums(AR<- c(1),MA<- c(1,0,-1),sigma<-1)*spectrums(AR<- c(1,-0.8,MA<- c(1),sigma<-1)

Tagged , ,