Python version
In [38]: timeit c,t = hpfilter(dta)
100 loops, best of 3: 2.17 ms per loop
Wrapped Ed Prescott's Fortran 90 version
In [39]: timeit c2,t2 = hpfilt(dta, np.empty((len(dta),3)),len(dta),1600,0)
10000 loops, best of 3: 26 us per loop
Usage
import scikits.statsmodels.api as sm
dta = sm.datasets.macrodata.load()
X = dta.data['realgdp']
c,t = sm.tsa.filters.hpfilter(X)
import matplotlib.pyplot as plt
plt.plot(t)
plt.plot(X)
plt.show()
Skipper
How is the smoothing parameter chosen?
Is an implicit choice a good idea?
Right. Should've mentioned this. There's a keyword `lamb` set to 1600
by default for quarterly data with suggestions in the docs for annual
and monthly from Ravn and Uhlig (2002).
Patches for data-driven selection of lambda are welcome ;)
Not today, but
http://ideas.repec.org/p/lmu/muenec/304.html
fwiw,
Alan