# Re: st: optimal lag order in dynamic panel

 From "Majah Ravago" To statalist@hsphsun2.harvard.edu Subject Re: st: optimal lag order in dynamic panel Date Sat, 24 Nov 2007 11:17:09 -1000

```i finally figured out what i'm doing wrong. I was able to use the
codes below to get the the optimal lag order to feed levinlin and
ipshin. However, i got the results below. Is it because my time data
variable is too short only 7 survey years occuring every three years.

.         ipshin lpcexp, lag(`opt_lag')

Im-Pesaran-Shin test for cross-sectionally demeaned lpcexp
Deterministics chosen: constant

t-bar test, N,T = (74,7)          Obs = 296
Augmented by 2 lags (average)

t-bar     cv10      cv5       cv1      W[t-bar]    P-value
dot     -1.640    -1.680    -1.750         dot          dot
.
levinlin lpcexp, lag(`opt_lag')

Levin-Lin-Chu test for lpcexp     Deterministics chosen: constant
Reducing Andrews truncation

Pooled ADF test, N,T = (74,7)     Obs = 12
Augmented by 2 lags (average)     Truncation: 4 lags

coefficient    t-value        t-star       P > t
-0.87566       -5.704            dot           dot

On Nov 23, 2007 8:02 PM, Majah Ravago <rmajah@gmail.com> wrote:
> Dear Scott and Sean,
>
> Thank you very much for posting this codes. THis is what i need!
> I just have a few questions 'coz it returns an error to my data.
> i'm a beginner in dynamic panel analysis. i need the optimal lag to
>
> my data is i=77 and T=7 (panel survey of every three  years)
>
> I was trying to adapt the codes below. Why does it only use 12
> countries in the panel?
> I tried removing this line to include my 77 i (province), but i got an
> error "insufficient observation."
> Is 13 in the "keep if country < 13" an arbitrary chosen number because
> countries in the example is more than this.
>
> Please tell me what this means:
>
> forv i = 1(5)60 {
>        local lag = opt[`i']
>        local opt_lag "`opt_lag' `" "' `lag'"
>
> What is the 1(5)60.
>
> I hope somebody can explain. I really need this codes figure out badly.
>
> Thank you so much!!!
>
>
> Majah
>
>
>
>
> use http://fmwww.bc.edu/ec-p/data/hayashi/sheston91.dta,clear
> qui {
> keep if country < 13
> preserve
> levels country, local(levels)
> foreach l of local levels {
>        varsoc rgdp if country == `l'
>        matrix A = r(stats)
>        if `l' > 1 {
>                matrix C = C \ A
>        }
>        else {
>                matrix C = A
>        }
> }
> svmat C, name(col)
> keep if HQ < .
>
> egen id = fill(1 1 1 1 1 2 2 2 2 2)
>
> egen minh = min(H), by(id)
> gen optimal_lag = lag if minh == HQ
>
> sort id opt
> forv i = 1(5)60 {
>        local lag = opt[`i']
>        local opt_lag "`opt_lag' `" "' `lag'"
> }
>
> restore
> }
> levinlin rgdp, lag(`opt_lag')
> *
> *   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/
>
*
*   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/
```