Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Hodrick-Prescott Filter issues


From   Christopher Baum <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Hodrick-Prescott Filter issues
Date   Sun, 27 May 2012 04:23:02 -0400

<>
On May 27, 2012, at 8:33 AM, Christopher wrote:

> I have a time-series pooled dataset, 91 countries from 1989-2010, with several financial variables. In particular, I want to run the series on bank credit through the HP filter to get a sense of trend deviation in bank credit over this time frame. However, I keep running into several problems:
> 
> 1.      I originally had an issue with missing data. I created a new variable called bankcred1 and then dropped all missing variables.
> 2.      Once I did that, I sorted by country and attempted by country: hprescott bankcred1, stub (smooth) lambda (6.25). I received an error message telling me that my data had gaps and thus it wouldn't work.
> 
> However, I can't figure out where the gaps are. I've tsset-ed my data by country year, yearly...
> 
> I ran tsreport bankcred1 and got an unbroken list of observations but it claimed that every panel change was a gap (and every country was a different panel).
> 
> How can I
> a) identify the "gap"
> b) close it so stata knows that it's continuous (such as making the dataset one panel?)
> c) get all of the HP filters into one variable?
> 
> I've never used HP on stata, I've done it on eViews because I found it more intuitive but for a database of this size that I need serious time-series computing power on, I need stata but am stymied on where the problems are.

Chris is apparently using my -hprescott- routine from SSC rather than the official, more recently developed  -tsfilter- routine. My routine works fine with panel data as long as the data are appropriately tsset:

webuse grunfeld,clear
tsset
drop if company==2 & year<1940
drop if company==8 & year>1950
by company: hprescott invest, stub(I)
egen invsmooth = rowtotal(I_invest_sm_*)
drop I_invest_sm_*
egen invresid = rowtotal(I_invest_*)
tabstat invest invsmooth, by(company) 

generates two new variables per company.  The egen rowtotal() can be used to make a single variable of the smooth and residual series.
As you can see, it also deals with gaps at the beginning or end of each firm's series.

My guess is that you do not have the data properly -tsset- or -xtset-. -hprescott-, like most Stata time-series commands, picks up information
from -quietly tsset- or -tsreport-, so if the data are not properly identified as a panel, many commands will fail.

Kit


Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
                             An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
  An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index