Algorithmic trading gone wild!

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.

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

See more here (and enjoy!)

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

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 is the filtered version of the series. Then

The weights of a moving average filters add up to one i.e. . The simplest such filter is the **uniform moving average **for which**:**

The **gain** of such filter is

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

**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.

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, , for large samples and t not near the beginning or end of the series

where .

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:

Note that the smaller the the more the filter concentrates on removing low frequencies.

Let and be two stationary time series related by:

where

and

is the filtered version of and 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.

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

where

is the** spectral generating function**. For ARIMA

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 flp<-c(flp,fl) } Re(c(flp)) }

example:

</pre> #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") <pre>

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)