Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Applying -varsoc- command with panel data

    Dear all,
    I have an unbalanced panel (N=32, T=13.5) with variables such as social spending and GDP on which I need to perform the: xtunitroot fisher.
    I am using the dfuller option. I can visualize the trend, however in order to determine the lag length I was using the varsoc command but it seems that is doesn't perform with panel data as I get an error massage:
    varsoc socialspending
    repeated time values in sample

    Do I need to loop the varsoc command over all panels and choose the max lag length over all panels?
    Any hint will be greatly appreciated,
    Anat

  • #2
    Dear all,
    Following my original post on how to apply -varsoc- on a panel data,
    I found the following code by Scott Merryman:
    use http://fmwww.bc.edu/ec-p/data/hayash...on91.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')

    <>

    The code works well on the data provided for example, but when I ran it on my panel data (13 countries with T=11 ) I receive the following error:

    . levinlin rgdp, lags(`opt_lag')
    lags() invalid -- invalid numlist has missing values

    Any idea what could have go wrong?
    Thanks for any piece of advice..
    Anat
    Last edited by Anat Tchetchik; 28 Feb 2015, 10:34.

    Comment


    • #3
      How to determine the optimum lag length in panel data?

      Comment

      Working...
      X