From | Ernest Berkhout <[email protected]> |
To | [email protected], <[email protected]> |
Subject | Re: st: looping with augmented dickey fuller test |
Date | Wed, 15 Oct 2003 13:59:20 +0200 |
At 13:19 15-10-2003, Dev Vencappa wrote:
I have a data set that looks like the followingYou need to parrallel loops, one over company and one over optlag`k', and that block within a loop over your k variables. So your first two lines are OK, although they might be telescoped into one line, check if there are no other variables starting with "var": (foreach k of varlist var*) or (foreach k of varlist var1-var4) or (foreach k of varlist var?).
company year var1 var2 var3 var4 optlagvar1 optlagvar2 optlagvar3 optlagvar4
1 1980 1
1 1981 1
1 1982 1
.. ..
1 2002 1
2 1980 3
2 1981 3
2 1982 3
.. ..
2 2002
... ...
... ...
20 1980 6
20 1981 6
20 1982 6
.. ..
20 2002
The variable optlagvar1 for instance is the optimal lag value from an Akaike Information criteriaon exercise for each company. My problem is I now want to implement the DF test for each company and each variable, writing something like:
local z "var1 var2 var3 var4"
foreach k of local z{
forvalues x=1/20{
dfuller `k', lags(optlag`k')
}
}
My problem is I cannot get stata to read the optimal lags value for the option lags, as this has to be specified as a numeric variable. Is there a way I can ask stata to do this loop and correctly specify the values in the lags option for the dfuller test?
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |