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/