IDEAS home Printed from

Matlab code for one-sided HP-filters


  • Alexander Meyer-Gohde

    (Humboldt University Berlin)


This file contains two different Matlab implementations of one-sided HP-filters. The first is the Kalman implementation laid out by Stock, J.H. and M.W. Watson (1999, p. 301) ["Forecasting inflation," Journal of Monetary Economics, vol. 44(2), pages 293-335, October.] for the optimal one-sided analogue to the standard HP-filter. The second is a serial implementation explained, for example, by Mehra, Y.P. (2004, p. 7) ["The Output Gap, Expected Future Inflation and Inflation Dynamics: Another Look," The B.E. Journal of Macroeconomics, Berkeley Electronic Press.] that runs the standard HP-filter serially through time using only the data available at a particular point in time for calculating a trend value for that point in time. As a byproduct, a fast sparse-matrix implementation of the standard HP-Filter is included.

Suggested Citation

  • Alexander Meyer-Gohde, 2010. "Matlab code for one-sided HP-filters," QM&RBC Codes 181, Quantitative Macroeconomics & Real Business Cycles.
  • Handle: RePEc:dge:qmrbcd:181

    Download full text from publisher

    File URL:
    File Function: program code
    Download Restriction: none

    More about this item


    Access and download statistics


    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:dge:qmrbcd:181. See general information about how to correct material in RePEc.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: (Christian Zimmermann). General contact details of provider: .

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    If CitEc recognized a reference but did not link an item in RePEc to it, you can help with this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service hosted by the Research Division of the Federal Reserve Bank of St. Louis . RePEc uses bibliographic data supplied by the respective publishers.