Statalist


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

st: AW: drop variables based on results of Dickey-Fuller test


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: drop variables based on results of Dickey-Fuller test
Date   Thu, 5 Nov 2009 16:55:29 +0100

<> 



*************
webuse air2, clear

gen newair=air*runiform()
gen newair2=air*runiform()
gen newair3=air+1

foreach var of varlist *air*{
		di in r "Now at: `var'"
		dfuller `var'
		capt assert r(p)<.1
		if _rc local drops `drops' `var'
}

drop `drops'

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



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Joshua A.
Shindell
Gesendet: Donnerstag, 5. November 2009 16:49
An: [email protected]
Betreff: st: drop variables based on results of Dickey-Fuller test

I am using the following code to run a dickey-fuller test on each of the
following three variables.  I am looking to only keep the variables for
which I get a test statistic that indicates a unit root in each process.


foreach z in var1 var2 var3{
dfuller `z'
}

I have tried making the condition based on the p-values stored in r(p),
this code below is where some help would be greatly appreciated.  I am
able to display a list of all the variables that meet the condition, but
how can I tell stata to drop the variables for the case in which the
condition below does not hold?

foreach z in var1 var2 var3{
dfuller `z'
gen `z'df = r(p)  
replace `z'df=. if Date!=10/31/2009
}

ds *df
foreach z in `r(varlist)'{
summarize `z', meanonly
if r(mean)>=.10{
 display as text "pvalue `z' = " as result r(mean) 
 }
}

Thank you very much for any suggestions.

Best,

Joshua A. Shindell

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index