Announcement

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

  • Table for unit root tests

    Hi everyone!

    I'd like to create one table in Stata that summarizes the results of the following unit root tests for 12 variables (LCO2, LP, LA, LR, LN, LIND, LS, LU, LPD, LA2, LU2, LEI).
    For each test, the test on the variables' first differences is also performed and should be included in the table:

    //Fisher test
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot fisher `var', dfuller lags(0)
    }

    //First difference
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot fisher D.`var', dfuller lags(0)
    }

    ///Philips–Perron test
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot fisher `var', pperron lags(0)
    }

    //First difference
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot fisher D.`var', pperron lags(0)
    }


    ///Breutung test
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot breitung `var' if Year>1999
    }

    //First difference
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot breitung D.`var' if Year>2000
    }

    ///Levin-Lin-Chiu test
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot llc `var' if Year>1999
    }

    //First difference
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot llc D.`var' if Year>2000
    }

    ///Im-Pesaran-Shin test
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot ips `var'
    }

    //First difference
    local vars LCO2 LP LA LR LN LIND LS LU LPD LA2 LU2 LEI
    foreach var of local vars {
    xtunitroot ips D.`var'
    }

    Is it possible to create a single table that summarizes the values of each test and their respective p-values in Stata?

    Thank you in advance.





  • #2
    You can create a frame or frames and then post the resulting results there. These threads may help in terms of how to extract the statistics.

    https://www.statalist.org/forums/for...-of-xtunitroot
    https://www.statalist.org/forums/for...sults-to-excel

    If you are unable to make progress, post a data example that generates results.

    Comment


    • #3
      Code:
      webuse pennxrate , clear
      
      capture program drop dounitroot
      program dounitroot
          foreach var in lnrxrate realxrate xrate {
          quietly {
          xtunitroot fisher `var', dfuller lags(0)
          local t1 = r(L)
          local p1 = r(p_L)
          xtunitroot fisher D.`var', dfuller lags(0)
          local t2 = r(L)
          local p2 = r(p_L)
          xtunitroot fisher `var', pperron lags(0)
          local t3 = r(L)
          local p3 = r(p_L)
          xtunitroot fisher D.`var', pperron lags(0)
          local t4 = r(L)
          local p4 = r(p_L)
          xtunitroot breitung `var' 
          local t5 = r(lambda)
          local p5 = r(p)
          xtunitroot breitung D.`var'
          local t6 = r(lambda)
          local p6 = r(p)
          xtunitroot llc `var' 
          local t7 = r(tds)
          local p7 = r(p_tds)
          xtunitroot llc D.`var' 
          local t8 = r(tds)
          local p8 = r(p_tds)
          xtunitroot ips `var'
          local t9 = r(zttildebar)
          local p9 = r(p_zttildebar)
          xtunitroot ips D.`var'
          local t10 = r(zttildebar)
          local p10 = r(p_zttildebar)
          }
          di `"{hline 60}"'
          di "Variable = `var'"
          di `"{hline 60}"'
          di  _col(25) "Level" _col(45) "Difference"
          di `"{hline 60}"'
          di "Fisher/Dfuller" _col(20) %5.3f `t1' " (" %5.3f `p1' ")" _col(40) %5.3f `t2' " (" %5.3f `p2' ")"
          di "Fisher/PPerron" _col(20) %5.3f `t3' " (" %5.3f `p3' ")" _col(40) %5.3f `t4' " (" %5.3f `p4' ")"
          di "Beitlung" _col(20) %5.3f `t5' " (" %5.3f `p5' ")" _col(40) %5.3f `t6' " (" %5.3f `p6' ")"
          di "LLC" _col(20) %5.3f `t7' " (" %5.3f `p7' ")" _col(40) %5.3f `t8' " (" %5.3f `p8' ")"
          di "IPS" _col(20) %5.3f `t9' " (" %5.3f `p9' ")" _col(40) %5.3f `t10' " (" %5.3f `p10' ")"
          di `"{hline 60}"'
          }
          end
      dounitroot

      Comment


      • #4
        I suspect collect might work, but I never use it.

        Comment

        Working...
        X