| Gretl Manual: Gnu Regression, Econometrics and Time-series Library | ||
|---|---|---|
| Prev | Chapter 5. Special functions in genr | Next |
One sort of specialized function in genr is the time-series filter. Two such filters are currently available, the Hodrick–Prescott filter and the Baxter–King bandpass filter. These are accessed using hpfilt() and bkfilt() respectively: in each case the function takes one argument, the name of the variable to be processed.
To be written.
Consider the spectral representation of a time series yt:
if we wanted to extract only that component of yt that lies between the frequencies
and
one could apply a bandpass filter:
where
for
and 0 elsewhere. This would imply, in the time domain,
applying to the series a filter with an infinite number of coefficients,
which is undesirable. The Baxter and King bandpass filter applies to
yt a finite polynomial in the
lag operator A(L):
where A(L) is
defined as
The coefficients
ai are chosen such that
is the best approximation to
for a given k. Clearly, the higher
k the better the approximation is, but since
2k observations have to be discarded, a compromise is
usually sought. Moreover, the filter has also other appealing theoretical
properties, among which the property that A(1) = 0, so
a series with a single unit root is made stationary by application of the
filter.In practice, the filter is normally used with monthly or quarterly data to extract the "business cycle" component, namely the component between 6 and 36 quarters. Usual choices for k are 8 or 12 (maybe higher for monthly series).
The default values for the frequency bounds are 8 and 32, and the default value for the approximation order, k, is 8. You can adjust these values using the set command. The keyword for setting the frequency limits is bkbp_limits and the keyword for k is bkbp_k. Thus for example if you were using monthly data and wanted to adjust the frequency bounds to 18 and 96, and k to 24, you could do
set bkbp_limits 18 96 set bkbp_k 24
These values would then remain in force for calls to the bkfilt function until changed by a further use of set.