Scott, thank you much. This works brilliantly.
I am still getting a mental handle on all of the syntax, but your code
works and it generally makes sense to me. Incidentally, Nick's 2002
article discussing how -foreach- works is very helpful for the novice
like me:
http://www.cpc.unc.edu/services/computer/presentations/statatutorial/cox
_article.pdf
Jason
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Scott
Merryman
Sent: Thursday, September 14, 2006 5:07 PM
To: [email protected]
Subject: st: RE: test for stationarity that accepts the "by" command?
-levelsof- with -foreach- can be used to cycle through the groups and
test
for a unit-root in each one. You could also use -post- to collect the
results. For example:
webuse grunfeld,clear
tempfile results
tempname hold
postfile `hold' company pvalue test_stat using `results'
levelsof company, local(levels)
foreach l of local levels {
qui dfuller invest if com == `l'
post `hold' (`l') (r(p)) (r(Zt))
}
postclose `hold'
preserve
use `results', clear
l
restore
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Jason Yackee
> Sent: Thursday, September 14, 2006 6:45 PM
> To: [email protected]
> Subject: st: test for stationarity that accepts the "by" command?
>
> Dear Stata seers,
>
> I am trying to test for stationarity of cross-sectional time series
data
> for individual cross-sections (countries). I am aware of xtfisher and
> pescadf as tests that work across unbalanced panels and provide a
single
> statistic for the entire dataset. But these are weak tests, and I'd
like
> to be able to test individual series by country, in order to see if
most
> individual series show signs of stationarity or unit roots.
>
> I've tried -by country: dfuller varname-, -by country: pperron
varname-
> and so on with -kpss- and -dfgls- and -levinlin-, but none of these
> commands allow a -by- (or -bysort-) option.
>
> Might there be another command, of which I am not aware, that is up to
the
> task? If not, am I left to breaking down my 150-country dataset into
150
> single-country datasets, or by using 150 different -if country-
commands?
>
> Jason Webb Yackee
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/