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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: AW: Storing test statistics from dfuller output


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Storing test statistics from dfuller output
Date   Sun, 4 Jul 2010 22:10:57 +0200

<> 

BTW, surprisingly, your -quietly levelsof(country)- does not induce Stata to
scream "Syntax error"! Turns out you can use this syntax in many other
cases:


*************
sysuse auto, clear
reg(price) weight length
su(weight)
su(weight length)
*************


For the calculation of the mean of the results, which you said you wanted,
you should amend my approach to include the # of cases for a weighted
calculation:

*************
webuse air2, clear
gen byte myranges=irecode(time, 1948, 1953, 1957, 1961)
statsby r(Zt) r(N), by(myranges) clear : dfuller air, lags(3)
summ _stat_1 [fweight = _stat_2], mean
di in r "Mean: " r(mean)
*************


I am not quite sure what was wrong with your code, btw, it seems to work
with my example:

*************
webuse air2, clear
gen byte myranges=irecode(time, 1948, 1953, 1957, 1961)

quietly levelsof(myranges)
gen pm=.
foreach a in `r(levels)' { 
	dfuller air if myranges==`a', lags(3)
	replace pm = r(Zt) if myranges==`a'
}

//compute the mean
su pm, mean
di in r "Mean: " r(mean)

*************

You may want to note the subtle difference that for -myranges==1-, you have
49 observations, while -dfuller- uses only 45, and my -statsby- approach
faithfully records that number, hence the slight difference in the means
calculated at the end of each code.


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Dani Tilley
Gesendet: Sonntag, 4. Juli 2010 19:33
An: statalist@hsphsun2.harvard.edu
Betreff: st: Storing test statistics from dfuller output

Hi,

I need to run -dfuller- tests on several countries and collect the test
statistic from each, store it, and compute its mean (or possibly divide by a
scalar). I tried the following but didn't get what I was looking for. 


quietly levelsof(country)
gen pm=.
foreach a in `r(levels)' { 
quietly dfuller cpi if country==`a', lags(3)
replace pm = r(Zt) if country==`a'
}

Any help would be appreciated.

Thanks,
DF Tilley


      
*
*   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/


*
*   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