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: Error using -tsfilter hp-
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Error using -tsfilter hp-
Date
Tue, 8 Apr 2014 20:27:40 +0100
Here is a work-around.
webuse grunfeld, clear
save grunfeld
tsset company year
keep if company != 3
tsfilter hp hp_kstock = kstock, trend(trend_*)
merge 1:1 company year using grunfeld
In short, -drop- the missings, do the calculations, and -merge- back.
Nick
[email protected]
On 7 April 2014 20:10, Faraz Usmani <[email protected]> wrote:
> 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/
*
* 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/