filter
- quantecon.filter.hamilton_filter(data, h, p=None)[source]
This function applies “Hamilton filter” to the data
http://econweb.ucsd.edu/~jhamilto/hp.pdf
- Parameters:
- dataarray or dataframe
- hinteger
Time horizon that we are likely to predict incorrectly. Original paper recommends 2 for annual data, 8 for quarterly data, 24 for monthly data.
- pinteger (optional)
If supplied, it is p in the paper. Number of lags in regression. If not supplied, random walk process is assumed.
- Returns:
- cyclearray of cyclical component
- trendtrend component
Notes
For seasonal data, it’s desirable for p and h to be integer multiples of the number of obsevations in a year. E.g. for quarterly data, h = 8 and p = 4 are recommended.