help for fdfilter

Apply frequency domain filter to time series


fdfilter varlist [if exp] [in range] , s(#) e(#) stub(abbrev)

fdfilter is for use with time-series data. You must tsset your data before using fdfilter; see help tsset. fdfilter supports the by prefix, which may be used to operate on each time series in a panel.

varlist may contain time-series operators; see help varlist.


fdfilter applies the frequency domain filter of Corbae, Ouliaris and Phillips (2002) and Corbae and Ouliaris (2006) to one or more time series in varlist. Series can be stationary, or can have a unit root. It tends to produce output similar to the Baxter-King (1999) filter, though without the end-point issue (it estimates end-points directly). The filtered series and smoothed series are placed in new variables, specified with the stub() option. The smoothed variables are identified by "_sm" in their names. The s() and e() arguments can either specify the minimum period of oscillation and maximum period of oscillation of the desired component of the time series, with 2 < s < e < infinity, or the desired frequencies, with 0 < s < e <= 1. fdfilter does not allow gaps within the observations of the time series.


s(#) and e(#) specify the minimum and maximum period of oscillation to be retained in the time series, either as the number of periods or as the frequencies expressed as fractions of pi. s(#) and e(#) are required. For quarterly data, common values are 6 and 32 periods (frequencies 1/16 and 1/3) , which preserve the components of the data with period between 1.5 and 8.0 years. For monthly data, common values are 18 and 96 periods (frequencies 1/48 and 1/9), which preserves the component of the data with period between 1.5 and 8.0 years. For annual data, common values are 2 and 8 (frequencies 1/4 and 1).

stub(abbrev), which must be provided, specifies the "stub" from which new variable names will be created. Variables created by stub must be new variables. If the varlist contains time-series operators, the dots in their names are replaced by underscores so that the resulting new variables' names are legal.


. webuse lutkepohl,clear

. fdfilter investment, s(6) e(32) stub(FD)

Same as above, expressing s() and e() as fractions of pi

. fdfilter investment, s(1/6) e(1/3) stub(FDpi)

Several variables

. fdfilter investment income consumption, s(6) e(32) stub(filt)

Time series operators

. fdfilter D.investment, s(4) e(12) stub(fl)

Application in a panel:

. use http://fmwww.bc.edu/ec-p/data/hayashi/sheston91.dta,clear

. drop if country>4

. tsset

. by country:fdfilter rgdppc, s(2) e(8) stub(fd) k(3)

. egen double fd_sm = rowtotal(fd_rgdppc_sm_*)

. drop fd_rgdppc_sm_*

. egen double fd_res = rowtotal(fd_rgpdpc_*)

. drop fd_rgdppc_*


Jorge Pérez, Inter-American Development Bank jperezperez@iadb.org


Baxter, Marianne and Robert G. King (1999). "Measuring Business Cycles: Approximate Band-Pass Filters for Economic Time Series", Review of Economics and Statistics 81(4), pp. 575-593.

Corbae, Dean, Sam Ouliaris and Peter C.B Phillips (2002). "Band Spectral Regression with Trending-Data", Econometrica 70 (3), pp. 1067-1109.

Corbae, Dean and Sam Ouliaris (2006). "Extracting Cycles from Non stationary Data", Econometric Theory and Practice: Frontiers of Analysis and Applied Research Cambridge Cambridge and New York.

Ouliaris, Sam (2009) "Ideal Band Pass Filter For Stationary/Non-Stationary Series" http://forums.eviews.com/viewtopic.php?f=15&t=1513


This command was translated from Eviews code in Ouliaris(2009). The stata syntax was drawn from the commands bking and hprescott by Christopher F. Baum and Martha Lopez.


This program is provided without warranty of any kind. The author is not responsible for any cost derived by the usage of this program.

Also see