# NDK_BaxterKingFilter

 int __stdcall NDK_BaxterKingFilter ( double * X, size_t N, BOOL bAscending, size_t freq_min, size_t freq_max, size_t K, BOOL drift, BOOL unitroot, WORD retTYpe )

Computes trend and cyclical component of a macroeconomic time series using Baxter-King Fixed Length Symmetric Filter.

Returns
status code of the operation
Return values
 NDK_SUCCESS Operation successful NDK_FAILED Operation unsuccessful. See Macros for full list.
Parameters
 [in,out] X is the univariate time series data (a one dimensional array). [in] N is the number of observations in X. [in] bAscending is the time order in the data series (i.e. the first data point's corresponding date (earliest date=1 (default), latest date=0)). [in] freq_min is the number of periods for the high pass filter (e.g. 6 for quarterly data, 18 for monthly data). [in] freq_max is the number of periods for the low passfilter (e.g. 32 for quarterly data, 96 for montly data). [in] K is the number of points(aka terms) to use in the approximate optimal filter. If missing, a default value of 12 is assumed [in] drift is a logical value: FALSE if no drift in time series (default), TRUE if drift in time series. [in] unitroot is a logical value: FALSE if no unit-root is in time series (default), TRUE if unit-root is in time series. [in] retTYpe is the integer enumeration for the filter output: (1= trend component (default), 2=cyclical component, 3=noise component)
Remarks
1. The time series is homogeneous or equally spaced.
2. The time series may include missing values (NaN) at either end.
3. The first and last K data points will not be filtered, hence replaced by NaN in the output time series as their values are not reliable
4. The recommended values of P and Q are 6 and 32 or 40 for quarterly data, or 18 and 96 or 120 for monthly data.
5. Setting Q=P produces a single band-pass filer and the cyclic component will be 0.
6. The noise component is simply the original data minus the trend and cyclic component
7. Proper seasonal adjustment should be carried out prior to BK filtering.
Requirements