HP filter and Band Pass filter

Hi, im using GAUSS 17. I'm wondering if there is any HP filter command and Band Pass filter command. I couldn't find them in the Manual.

Thank your very much,

Marcos

2 Answers



0



Hi Marcos,

GAUSS does not currently have a pre-built HP Filter or Band Pass Filter command. However, you can find third-party code online for implementing both the HP Filter and general Band Pass Filters.

You may wish to start with the program hpfilter by Ron Vigfusson at https://dge.repec.org/codes/vannorden/hpfilter.prg or the bandpass filter provided by the Federal Reserve Bank of Atlanta at https://www.frbatlanta.org/cqer/research/bpf.aspx.

Please note that I have not verified the results of either program. I have, however, included an example using the hpfilter program below.

/*
** This demonstrates the use of the 1995 hpfilter GAUSS program 
** by Ron Vigfusson. It filters the ln of quarterly GDP 1952 - 2010.
**
**
** As suggested in the original program code, it uses a bandwidth of
** 1600.
**
*/

y = loadd("lnGDP_Q");
w = 1600;

y_hpfilter = hpfilter(y,w);

//Plot series
struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

//Start date for tsplot
dtstart = 19520101;

//Axis Labels
plotSetYLabel(&myPlot, "Natural Log of Real GDP", "Arial", 16);
plotSetXLabel(&myPlot, "Date", "Arial", 16);

//Set Legend
series_names = "Original"$|"Filtered";
plotSetLegend(&myPlot, series_names, "top left", 1);

//Time Series Plot
plotTS(myPlot, dtstart, 4, y~y_hpfilter);

/*  HPFILTER    First Draft : December 21, 1989 by Ken Matheny (hodpres())
        Second Draft: August 3, 1994 by Simon van Norden (hpfilter())
        Third Draft : April 27, 1995 by Robert Vigfusson (hpfilter())

    This program is designed to smooth the stochastic series  y  by use
    of the Hodrick-Prescott method mentioned in footnotes of the Kydland
    & Prescott "Time to Build" paper, and Hansen's "Indivisible Labor"
    paper.

    The method involves minimizing an expression containing the squared
    differences between the actual and smoothed series, and terms involving
    the differences between successive elements of the smoothed series.
    This leads to a linear filter for the original data.

    "w" is a smoothness parameter.  The larger w, the smoother the resulting
    series, shp.  Kydland and Prescott suggest a "w" of 1600 for quarterly data.

FORMAT : {s} = hpfilter(y,w);

INPUTS : y  : The series to be filtered;
         w  : The smoothness parameter (suggest 1600).

OUTPUT : shp: The smoothed series.  The deviations can be calculated simply
              as (y-shp).

SOURCE : hpfilter.arc
*/

proc(1) = hpfilter(y,w);

    local t,a,b,c,d,m,i,j,shp;

    t       = rows(y);
    a       = 6*w+1;
    b       = -4*w;
    c       = w;
    d       = c~b~a;

    d       = ones(t,1)*d;

    d[1,1]=0;
    d[2,1]=0;
    d[1,2]=0;

    d[2,2] = -2*w;
    d[t,2] = -2*w;

    d[1,3] = 1+w;
    d[t,3] = 1+w;

    d[2,3]=5*w+1;
    d[t-1,3]=5*w+1;

    @ The Smoothed Series @

    shp = bandsolpd(eye(t),d)*y;

    retp(shp);
endp;

Eric

105


0



Thank you a lot.

 

Marcos

Your Answer

2 Answers

0

Hi Marcos,

GAUSS does not currently have a pre-built HP Filter or Band Pass Filter command. However, you can find third-party code online for implementing both the HP Filter and general Band Pass Filters.

You may wish to start with the program hpfilter by Ron Vigfusson at https://dge.repec.org/codes/vannorden/hpfilter.prg or the bandpass filter provided by the Federal Reserve Bank of Atlanta at https://www.frbatlanta.org/cqer/research/bpf.aspx.

Please note that I have not verified the results of either program. I have, however, included an example using the hpfilter program below.

/*
** This demonstrates the use of the 1995 hpfilter GAUSS program 
** by Ron Vigfusson. It filters the ln of quarterly GDP 1952 - 2010.
**
**
** As suggested in the original program code, it uses a bandwidth of
** 1600.
**
*/

y = loadd("lnGDP_Q");
w = 1600;

y_hpfilter = hpfilter(y,w);

//Plot series
struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

//Start date for tsplot
dtstart = 19520101;

//Axis Labels
plotSetYLabel(&myPlot, "Natural Log of Real GDP", "Arial", 16);
plotSetXLabel(&myPlot, "Date", "Arial", 16);

//Set Legend
series_names = "Original"$|"Filtered";
plotSetLegend(&myPlot, series_names, "top left", 1);

//Time Series Plot
plotTS(myPlot, dtstart, 4, y~y_hpfilter);

/*  HPFILTER    First Draft : December 21, 1989 by Ken Matheny (hodpres())
        Second Draft: August 3, 1994 by Simon van Norden (hpfilter())
        Third Draft : April 27, 1995 by Robert Vigfusson (hpfilter())

    This program is designed to smooth the stochastic series  y  by use
    of the Hodrick-Prescott method mentioned in footnotes of the Kydland
    & Prescott "Time to Build" paper, and Hansen's "Indivisible Labor"
    paper.

    The method involves minimizing an expression containing the squared
    differences between the actual and smoothed series, and terms involving
    the differences between successive elements of the smoothed series.
    This leads to a linear filter for the original data.

    "w" is a smoothness parameter.  The larger w, the smoother the resulting
    series, shp.  Kydland and Prescott suggest a "w" of 1600 for quarterly data.

FORMAT : {s} = hpfilter(y,w);

INPUTS : y  : The series to be filtered;
         w  : The smoothness parameter (suggest 1600).

OUTPUT : shp: The smoothed series.  The deviations can be calculated simply
              as (y-shp).

SOURCE : hpfilter.arc
*/

proc(1) = hpfilter(y,w);

    local t,a,b,c,d,m,i,j,shp;

    t       = rows(y);
    a       = 6*w+1;
    b       = -4*w;
    c       = w;
    d       = c~b~a;

    d       = ones(t,1)*d;

    d[1,1]=0;
    d[2,1]=0;
    d[1,2]=0;

    d[2,2] = -2*w;
    d[t,2] = -2*w;

    d[1,3] = 1+w;
    d[t,3] = 1+w;

    d[2,3]=5*w+1;
    d[t-1,3]=5*w+1;

    @ The Smoothed Series @

    shp = bandsolpd(eye(t),d)*y;

    retp(shp);
endp;

0

Thank you a lot.

 

Marcos


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy