Dev Vencappa
> I have a data set that looks like the following
>
> 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?
I imagine that you are separately considering quite what
interpretation P-values have in this exercise.
A Stata solution for what I think you desire might resemble
foreach v of var var? {
forvalues x = 1/20 {
su optlag`v' if company == `x', meanonly
dfuller `v' if company == `x', lags(`r(min)')
}
}
This hinges on the fact that the optimum lag is constant
within each company and each variable, so -summarize-
should return the same value as minimum, maximum and mean.
Which you pick up to use as your value is thus immaterial.
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/