Statistics and Algorithms / Spectral Analysis / Frequency Domain Filtering |
Many applications of spectral analysis use some form of frequency domain filtering:
•Fractional differencing and integration uses a filter which is exactly represented in the frequency domain, but only can be approximated in the time domain.
•Maximum likelihood in the frequency domain (for instance, FRACTINT.RPF) relies upon frequency domain filtering to estimate time domain models.
•Sims’ seasonal adjustment procedure uses a “filter” which can only be represented in the frequency domain. See the example file FREQDESEASON.RPF.
•Hannan’s efficient estimator (HANNAN.RPF) does GLS for arbitrary (stationary) serial correlation structures by computing in the frequency domain a filter to whiten the regression residuals.
•The spectral forecasting procedure uses a transfer function computed in the frequency domain.
Technical Information
Filtering is a convolution operation, which can be represented easily in the frequency domain. If
\begin{equation} y_t = \sum\limits_{s = - \infty }^\infty {a_s x_{t - s} }\text{ then} \label{eq:spectral_convolution} \end{equation}
\begin{equation} \tilde y\left( \omega \right) = \tilde a\left( \omega \right){\kern 1pt} {\kern 1pt} {\kern 1pt} \tilde x\left( \omega \right) \end{equation}
that is, the complicated convolution operation \eqref{eq:spectral_convolution} is converted into simple multiplication in the frequency domain. The filtering procedure is thus:
1.Apply FFT to \(x\) to get \(\tilde x\).
2.Compute \(\tilde a\). You can use the instruction TRFUNC if it is a standard finite filter, CMASK for a filter to shut out frequency bands, and CSET or some other combination of instructions for other filter types.
3.Multiply the two Fourier transforms. Remember that RATS conjugates the second item in a CMULTIPLY or * operation.
4.Inverse transform the product using IFT.
Frequency domain filtering is most useful when the filter \(a\) is theoretically infinite but has a relatively simple Fourier transform. If \(a\) has a small number of coefficients, direct calculation with FILTER or SET is quite a bit faster.
Consider the output obtained by passing a series \(y(t)\) through the filter \(A(L)\). If you do this in the time domain using FILTER, there are entries on one or both ends which cannot be computed for lack of lags or leads of \(y\). If you filter in the frequency domain, the effect is as if three copies of \(y\) were laid end to end. The filter \(A\) is applied to this new series, with the middle section extracted as the output:
\(\left| {{\rm{ 1, 2, }} \ldots {\rm{, }}N - 1{\rm{, }}N{\rm{ }}} \right.\left| {{\rm{ 1, 2,}}} \right.\underbrace {\, \ldots {\rm{, }}N - 1{\rm{, }}N{\rm{ }}\left| {{\rm{ 1, 2, }} \ldots {\rm{ }}} \right.}_{A\left( L \right)y\left( N \right)}{\rm{, }}N - 1{\rm{, }}N\)
If we look at the entries which we cannot compute with FILTER, we see that they get computed in the frequency domain, but use data from both ends of the series. For instance, a filter which lags back to the non-existent entry 0 will take entry \(N\) in its place. This wraparound effect hits only those entries which we could not compute anyway. The other entries are unaffected.
However, the time domain filter equivalent to most important frequency domain filters is an infinite lag polynomial. Thus all entries will be affected by wraparound to some extent. To reduce the seriousness of this, the series should:
•have mean zero
•have no trend
•be well-padded
That way, the wrapping will be picked up by the zero padding at the ends of the data. With a mean zero trendless series, these zeros will not create the magnitude of bias that would be created if, for instance, there were a decided trend in the data. (In some cases, a fixed non-zero mean can be used with the data padded with that value).
Our recommendation is that you pad to at least double the length of the data.
Frequency domain filtering is usually much more efficient than time domain filtering if you need the entire transformed series (not just a single) entry, and the filter is more than a few terms in the time domain. A particularly important example of this is fractional differencing, which can be done in RATS using the DIFFERENCE instruction with the FRACTION option. The time domain lag polynomial for this is (theoretically) infinite. Most applications which do the calculations in the time domain truncate the filter at some large length (500 or 1000 terms). The calculation done in the frequency domain is many times faster and is more accurate.
Copyright © 2025 Thomas A. Doan