Came across this interesting paper and RATS code by Hamilton. Thought I would post here for others and opinions as whether this is the way to go with output gaps, credit-to-GDP gaps etc.
Working paper http://econweb.ucsd.edu/~jhamilto/hp.pdf
Code and data http://econweb.ucsd.edu/~jhamilto/hp_replicate.zip
Non technical summary http://econbrowser.com/archives/2016/08 ... ott-filter