Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Hodrick-Prescott Filter


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Hodrick-Prescott Filter
Date   Wed, 28 Sep 2011 20:27:27 +0100

-hprescott- is a user-written command (Kit Baum, SSC). Please remember
the request to explain where user-written commands you refer to come
from.

Looking at the first few lines of the code shows that -hprescott-
follows a standard Stata approach with the early issue of a command

marksample touse

That -marksample- command looks at the `varlist' macro defined by an
earlier -syntax- command which will contain precisely the variables
you specified so long as they are -ts- and defines a temporary
variable `touse' which is 1 for observations selected and 0 otherwise.
Observations are selected only if they are non-missing on all
variables in the `varlist'. (-if- and -in- restrictions might further
narrow the selection, not the issue here.)  Subsequent analysis is
then -if `touse'-  (parse `touse' as a Stata conventional name meaning
"to use").

So, yes, if one beginning later means missing values for that variable
and those years, then only observations with non-missing values on all
variables in varlist are used, with the consequences you describe.

Nick

On Wed, Sep 28, 2011 at 7:53 PM, Matthew Baker
<matthew.baker@hunter.cuny.edu> wrote:

> I have a question about the hprescott command in Stata. I have two
> time series, and one series begins later than the other. When I issue
> the command:
> hprescott series1 series2, stub(hp)
> I get different results from when I give the command:
> hprescott series1, stub(hp):
> Evidently, filtering two series together gives different results from
> filtering them separately when the series have varying lengths.
>
> Does asking the program to filter two series simultaneously, when the
> series have different numbers of observations mean that the command
> throws out the "extra" observations in  one of the series so as to
> ensure that both series have the same number of observations, and is
> this all that is going on?
>
> An example:
>
> clear*
> webuse dfex
> tsset month
> hprescott unemp, stub(hp)
> hprescott unemp income, stub(hp1)
> replace income=. in 1/40
> hprescott unemp income, stub(hp2)
> sum hp_unemp_1 hp1_unemp_1 hp2_unemp_1
>
> The observation is that hp2_unemp_1 is different than the first two,
> and the only change has been that there are fewer observations of the
> income variable.
>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index