Announcement

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

  • -dfuller- of 69 variables between 27 cross-section units

    Hello statalisters,
    I have to perform a -dfuller- in 69 variables in 27 cross-section units, and if I do one by one it will take forever, -esttab- and -esttout- didn't work for me so I tried: Code:

    levelsof id forval num = 1/69 { gen dfnotrend`num'=. } forval num = 1/69 { foreach a in `r(levels)' { dfuller y`num' if id==`a', lags(2) replace dfnotrend`num' = r(Zt) if id==`a' } }
    Stata is only storing the dfnotrend1 ( for variable y1) , can someone shed some light on this matter, please? Thanks a lot.

  • #2
    Your code is hard to read, please post it using the code tags.

    Jorge Eduardo Pérez Pérez
    www.jorgeperezperez.com

    Comment


    • #3
      Sorry,


      Code:
      levelsof id
      forval num = 1/69 {
      gen dfnotrend`num'=.
      }
      forval num = 1/69 {
      foreach a in `r(levels)' {
      dfuller y`num' if id==`a', lags(2)
      replace dfnotrend`num' = r(Zt) if id==`a'
      }
      }

      Comment


      • #4
        The local r(levels) is not being carried across iterations of the first loop, because it gets replaced by each run of dfuller. Store your ids from levelsof in another local

        Code:
        webuse pennxrate, clear
        
        keep if id<=5
        
        * Generate 69 xrate variables and the dfnotrend to store
        forval num = 1/69 {
        gen dfnotrend`num'=.
        gen y`num'=lnrxrate+uniform()
        }
        
        * Run tests
        levelsof id, local(ids)
        forval num = 1(1)69 {
            foreach a in `ids' {
                qui dfuller y`num' if id==`a', lags(2)
                qui replace dfnotrend`num' = r(Zt) if id==`a'
            }
        }
        Jorge Eduardo Pérez Pérez
        www.jorgeperezperez.com

        Comment


        • #5
          Thanks a lot

          Comment

          Working...
          X