Announcement

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

  • preduct residuals for all my panel units

    Hi i have a panel data that contains 30 units. I would like to run the following for all my panel units, and have the result saved as a variable.

    regress y x1 x2 dv dv2 (for all my panelid)
    predict residual, res (for all my panelid)
    dfuller residual (for all my panelid)

    I am guessing i need to create a loop?

  • #2
    Olivia
    the following toy-example stops one step behind -dfuller- (something I'm not familiar with):
    Code:
    use "http://www.stata-press.com/data/r14/nlswork.dta", clear
    forval i = 1/3 {
    reg ln_wage c.age i.grade if idcode==`i'
    predict res`i' if idcode==`i', res
    }
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      what if my panelid isn't ordered incrementally? it's just random country codes

      Comment


      • #4
        http://www.stata.com/support/faqs/da...ach/index.html Method 1

        Comment


        • #5
          Why exactly do you want to do this? If you want to get panel-id specific coefficients, I recommend you use -xtmg- (available on SSC), which produces the panel specific betas for you, as well as the average. If you want to test for the presence of a unit root, you should use a panel unit root test, such as Pesaran's CADF (-pescadf-, -xtcips-) or any of the options in -xtunitroot-. They have considerably more power than any combination of panel-unit-specific tests.

          Comment

          Working...
          X