4.2 Filtering Time Series

In the model

yt=j=βjxtj

the collection of {βj} is called a linear filter. Clearly, yt is a linear function of xt and it is a filtered version of xt. Linear filtering, where βj is a known collection of numbers, is often used to identify patterns and signals in a noisy time series (in this case xt).

Filtering involves a convolution between two series xt and βj. The convolved series is then called yt. At time t, the convolution (in words) is the sum of the product between the the βj series going forward and the xt series going backwards.

xt+3,xt+2,xt+1,xt,xt1,xt2,xt3×××××××β3,β2,β1,β0,β1,β2,β3

We will assume throughout that the βjs satisfy the condition

j=|βj|<

4.2.1 Fourier Transforms of Convolutions

Given the filtered time seres yt specified as yt=j=βjxtj

what is its Fourier transform?

yω=t=j=βjxtjexp(2πiωt)=t=j=βjxtjexp(2πiω(tj+j))=t=j=βjexp(2πiωj)xtjexp(2πiω(tj))=j=βjexp(2πiωj)t=xtjexp(2πiω(tj))=j=βjexp(2πiωj)t=xtexp(2πiωt)=βωxω

Here, the collection βω as a function of ω is called the transfer function and it is the Fourier transform of the impulse response function βj.

Why is this useful? For starters, this result provides an efficient way to compute the convolution between two series, which is exactly what is required with linear filtering. If we want to compute the filtered values y1,y2,,yn, the naive formula requires us to compute the convolution formula n times, which has O(n2) complexity. But instead, we can

  1. Compute the Fourier transform xω via the FFT for frequencies ω=0/n,1/n,,1/2.

  2. Compute the FFT βω for frequencies ω=0/n,1/n,,1/2.

  3. Compute yω=βωxω for frequencies ω=0/n,1/n,,1/2.

  4. Compute the inverse FFT for all yω to get the filtered values yt.

4.2.2 Low-Pass Filter

Consider the following simple (simulated) time series, which is a simple linear trend plus some Gaussian noise.

What will the output series look like if we convolve the original data with the following linear filter?

The answer is in the plot below in blue. The blue line shows the filtered series, which we can see is a smoother version of the original data. The filter shown above is a low-pass filter, which dampens higher frequencies in the data and allows lower frequencies to “pass” through.

We can see the low-pass nature of the filter by examining the transfer function below. Here, we can see that the lower frequencies (near f=0) are given greater weight than the higher frequencies.

4.2.3 High-Pass Filter

The following is an example of a linear filter that dampens low frequencies and allows high frequencies to pass.

Here is the filtered version of the original data, using the high-pass filter. You can see that it looks like a series of residuals with the trend removed.

Below is the transfer function corresponding to the linear filter shown previously. Here, it is clear that the higher frequencies (near f=1/2) are given greater weight than the lower frequencies.

4.2.4 Matching Filter

The simulated series below is an example of a time series that has a clear jump at a specific point in time.

In some applications, it is desired to identify when the jump takes place in the series. We can do that by using a matching filter, which mirrors the jump in the data.

Convolving the matching filter with the data gives us the following output. We can see that the filtered series goes very high at the jump point and similarly goes very negative when the data jump back down.

The transfer function for the matching filter is shown below. We can see that the sines and cosines in the Fourier transform have a difficult time approximating the discontinuous nature of this linear filter. Hence, the oscillation in the transfer function.

4.2.5 Exponential Smoother

yt+1=(1λ)j=0λjxtj=(1λ)xt+λyt