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]

st: Error using -tsfilter hp-


From   Faraz Usmani <faraz.u@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Error using -tsfilter hp-
Date   Mon, 7 Apr 2014 15:10:59 -0400

I have panel data covering 48 countries over 30 years. I am attempting
to use -tsfilter hp- to detrend private-sector borrowing ('aha') but
am running into an error because of completely missing observations
for some countries.

For countries where it is not fully missing, the series does not
contain gaps, so I calculated the sum of observations by country, and
attempted to use -tsfilter hp- on only those countries that had more
than two observations using the code below but ran into the same
issue:

gen y = 1 if !mi(aha)
egen sum_y = sum(y), by(countrycode)
tsfilter hp hp_aha = aha if sum_y>2, trend(trend_*)

J():  3300  argument out of range
_TSFILTER_getQ():     -  function returned error
_TSFILTER_hpFilter():     -  function returned error
<istmt>:     -  function returned error

Specifically, the generated detrended series ('hp_aha') cuts off at
the first country that is missing all observations and does not
contain values for the remaining countries, regardless of whether the
observations are missing or not. (Strangely, -tsfilter hp- works fine
if I run -keep if sum_y>2- first instead.)

Here is an example of what is happening using grunfeld:

webuse grunfeld, clear
tsset company year
replace kstock=. if company==3
tsfilter hp hp_kstock = kstock, trend(trend_*)

Is there a way to use -tsfilter hp- with my data without dropping
missing observations?

Thanks for your consideration,
Faraz
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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