NxBK - Baxter-King Filter

Computes the trend and cyclical component of a macroeconomic time series using the Baxter-King fixed length symmetric filter.



NxBK(X, Order, P, Q, K, Drift, Unit-Root, RetType)

X is the univariate time series data (a one dimensional array of cells (e.g. rows or columns)).

Order is the time order in the data series (i.e. the first data point's corresponding date (earliest date = 1 (default), latest date = 0)).

Order Description
1 ascending (the first data point corresponds to the earliest date) (default)
0 descending (the first data point corresponds to the latest date)

P is the number of periods for the high pass filter (e.g. 6 for quarterly data, 18 for monthly data).

Q is the number of periods for the low pass filter (e.g. 32 for quarterly data, 96 for monthly data).

K is the number of points to use in the approximate optimal filter. If missing, a default value of 12 is assumed.

Drift is a logical value: FALSE if there is no drift in the time series (default), TRUE if a drift exists in the time series.

Unit-Root is a logical value: FALSE if there is no unit-root in the time series (default), TRUE if a unit-root exists in the time series.

RetType is the integer enumeration for the filter output: (1 = trend component (default), 2 = cyclical component, 3 = noise component).



  1. The time series is homogeneous or equally spaced.
  2. The time series may include missing values (e.g. #N/A) at either end.
  3. The first and last K data points will not be filtered and are hence replaced by #N/A in the output time series as their values are not reliable.
  4. The recommended values of P and Q are 6 and 32/40 for quarterly data, or 18 and 96/120 for monthly data.
  5. Setting Q=P produces a single bandpass filter and the cyclical component will be 0.
  6. The noise component is simply the original data minus the trend and cyclical component.
  7. Proper seasonal adjustment should be carried out prior to BK filtering.

Files Examples


  • Marianne Baxter, Robert G. King (1999). "Measuring Business Cycles: Approximate Band-Pass Filters for Economic Time Series". The Review of Economics and Statistics 81 (4): 575–593.
  • Hodrick, R., Prescott, E. (1997): "Postwar U.S. Business Cycles: An Empirical Investigation", Journal of Money, Credit, and Banking, 29(1), pp. 1-16.
  • Beveridge, S., Nelson, C. R. (1981): "A New Approach to Decomposition of Economic Time Series into Permanent and Transitory Components with Particular Attention to Measurement of the Business Cycle", Journal of Monetary Economics, No. 7, pp. 151-174
Have more questions? Submit a request