Statalist


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

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


From   "Joshua A. Shindell" <[email protected]>
To   <[email protected]>
Subject   st: drop variables based on results of Dickey-Fuller test
Date   Thu, 5 Nov 2009 10:49:16 -0500

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index