I have run into a strange problem with this code. It works with one
dependent variable, but not others. Let me past code first, then
explain, then post results.
Here is my modification of Scott's -foreach- loop:
tempfile results
tempname hold
postfile `hold' aa_cow_code pvalue test_stat using `results'
levelsof aa_cow_code, local(levels)
foreach l of local levels {
qui dfuller fdi_inflow_real_combined if aa_cow_code == `l'
post `hold' (`l') (r(p)) (r(Zt))
}
postclose `hold'
preserve
use `results', clear
l
restore
"aa_cow_code" is my panel id variable; "fdi_inflow~" is the DV upon
which I want to perform the -dfuller- routine. When I run the -foreach-
loop using my DV "fdi_inflow_real_combined" (which is simply a
continuous, constant-dollar measure of FDI inflows) the output is as I
would expect -- a chart with predicted probabilities and z-statistics
for each panel id comes up, just as Scott intended.
But when I try to run the -foreach- program with a different dependent
variable -- take here "fdi_inflow_pct_gdp_UN", the -foreach- loop begins
to run, but stops with a message that there are no observations. In
fact I know there are observations from inspecting and working with the
data, and the second "fdi_inflow~" variable is simply the first variable
expressed as a percent of a country's GDP. The code also doesn't work
with other versions of the the "fdi_inflow~" variable that I have
constructed.
I've pasted the problematic output below, followed by summaries of the
"good" DV and the troublesome DV. Any advice is appreciated. I suppose
the answer is probably obvious, but I should note that I am NOT
mistyping the variable names -- just pasting them directly from another
Stata window.
. tempfile results
. tempname hold
. postfile `hold' aa_cow_code pvalue test_stat using `results'
. levelsof aa_cow_code, local(levels)
31 40 41 42 51 52 53 70 80 90 91 92 93 94 95 100 101 110 115 130 135 140
145 150 155 160 165 205
> 235 290 310 316 317 338 339 343 344 345 346 349 350 352 355 359 360
365 366 367 368 369 370 371
> 372 373 395 402 404 411 420 432 433 434 435 436 437 438 439 450 451
452 461 471 475 481 482 48
> 3 484 490 500 501 510 516 517 520 522 530 531 540 541 551 552 553 560
565 570 571 572 580 581 5
> 90 600 615 616 620 625 630 640 645 651 652 660 663 666 670 679 690 692
694 696 698 700 701 702
> 703 704 705 710 712 732 750 760 770 771 775 780 781 790 800 811 812
816 820 830 835 840 850 910
> 920 940 950
. foreach l of local levels {
2. qui dfuller fdi_inflow_pct_gdp_UN if aa_cow_code == `l'
3. post `hold' (`l') (r(p)) (r(Zt))
4. }
no observations
r(2000);
end of do-file
r(2000);
. sum fdi_inflow_real_combined
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
fdi_inflow.. | 4664 5.97e+08 2.85e+09 -4.55e+09 5.05e+10
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
fdi_inflow.. | 3975 2.00564 5.148409 -82.89212 89.08587
-----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/