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: hprescott command with by prefix for panel data
From
Tirthankar Chakravarty <[email protected]>
To
[email protected]
Subject
Re: st: hprescott command with by prefix for panel data
Date
Sat, 8 Jan 2011 01:45:16 -0800
I don't fully understand, but you seem to be trying to extract a trend
from two observations? Because that will what -by- with -hprescott-
(Baum, SSC) will try to do for each day (it will fail because of lack
of observations):
***************************************
// with 10 observations per id
clear*
set obs 200
egen n = seq(), from(1) to(10) block(2)
bys n: g t = _n
g var = runiform()
xtset n t
bys n: hprescott var, stub(hp)
li *sm*
// with 2 observations per id
clear*
set obs 20
egen n = seq(), from(1) to(10) block(2)
bys n: g t = _n
g var = runiform()
xtset n t
bys n: hprescott var, stub(hp) // chokes here
***************************************
I assume when you say that "t=_n", you mean by id: t = _n. Else there
is no panel structure.
You are probably better off filtering the series as is. You might need
to tune the smoothing parameter for bi-daily observations. Or you
could aggregate up to daily frequency by -collapse-ing.
T
On Sat, Jan 8, 2011 at 1:14 AM, Andreas Ferrara
<[email protected]> wrote:
> Dear Statalisters,
>
> I try to use the Hodrick-Prescott filter to smooth a time-series with 2
> observations per day (morning and evening observations). In one of
> Christopher Baum's presentations on filtering techniques he introduces the
> hprescott comand, stating that:
> "It may be applied in a panel context with the by: prefix."
>
> So now I have an id variable for a given day, covering the morning and
> evening obs thus for 3000 obs there are 1500 ids. The data is tsset using
> a time variable where time = _n.
>
> When using the hprescott command with the by prefix (and a smoothing
> paramter of 1600000 for daily data), it displays the following error
> message:
>
> . sort id
>
> . by id: hprescott var, stub(test) smooth(1600000)
> hprescott(): 3301 subscript invalid
> <istmt>: - function returned error
>
> I tried different tsset variables, id vars etc but couldn't figure out
> what went wrong here. For any help on this I'd be most grateful.
>
> Thanks in advance and best wishes,
>
> Andy Ferrara
>
>
> --
> The Sunday Times Scottish University of the Year 2009/2010
> The University of Stirling is a charity registered in Scotland,
> number SC 011159.
>
> *
> * 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/
>
--
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).
*
* 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/