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 A. Hartwell" <[email protected]>
To   <[email protected]>
Subject   RE: st: Hodrick-Prescott Filter issues
Date   Mon, 28 May 2012 22:59:10 -0400

Kit,

Thanks for the example and how to make a single variable of the smooth and
residual series. You're correct, I'm using the hprescott routine instead of
the other one (I'm running Stata 11 IC). Unfortunately, I still can't get to
that point, and I know the problem is, as you correctly note, in the tsset,
but I don't know how to get it where it needs to be.

I open my data file, and then get this - 

. tsset
       panel variable:  country1 (unbalanced)
        time variable:  year, 1989 to 2010, but with gaps
                delta:  1 year

The data I have is contiguous, though, from 1989-2010

but when I try to HP, this is what I get

. by country1: hprescott bankcred1, stub(smoothcred) smooth(6.25)

Number of gaps in sample:  1   (gap count includes panel changes)
sample may not contain gaps
r(198);

Using tsreport, I get

. tsreport, report panel list

Number of gaps in sample:  8

Observations with preceding time gaps
------------------------------------
   Record |    country1         year
----------+-------------------------
       90 |     Austria         1999
      190 |     Belgium         1999
      568 |      France         1999
      996 |  Luxembourg         1994
     1000 |  Luxembourg         2000
     1188 | Netherlands         1999
     1479 |     SAfrica         1992
     1809 |      Zambia         1993

HOWEVER, looking at the data, there are no gaps in the data. Austria goes
1998 1999 2000... all the way through. Same with Belgium, France, and all
the others. Could you help me to identify what these gaps are and how to
close them?

Cheers,
Chris

Christopher A. Hartwell, PhD
Economic Growth and Business Environment Consultant
+1 202-415-6030 (m)
+1 773-724-2310 (t/f)
e-mail: [email protected]
alternate emails: [email protected], [email protected] 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Christopher Baum
Sent: Sunday, May 27, 2012 4:23 AM
To: [email protected]
Subject: Re: st: Hodrick-Prescott Filter issues

<>
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/

*
*   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