Announcement

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

  • Store the outcome from xttest0

    Hi Guys

    I meet the problem when I am trying to store the result from xttest0.
    I learned how to store the results from estimation as like xtreg, but I cannot find out the reference for taking the result from this command.
    I want "Prob > chibar2 = 0.0000" but it's ok if anyone is willing to teach me how to calculate it manually.


    Breusch and Pagan Lagrangian multiplier test for random effects

    ebasq[rssd9001,t] = Xb + u[rssd9001] + e[rssd9001,t]

    Estimated results:
    | Var sd = sqrt(Var)
    ---------+-----------------------------
    ebasq | .0376543 .194047
    e | .0069079 .0831138
    u | .007011 .0837318

    Test: Var(u) = 0
    chibar2(01) = 97427.78
    Prob > chibar2 = 0.0000



    Thank you very much.

  • #2
    Wei-Wei:
    welcome to this forum.
    You may want to try:
    Code:
    . use "https://www.stata-press.com/data/r16/nlswork.dta"
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    . xtreg ln_wage age, re
    
    Random-effects GLS regression                   Number of obs     =     28,510
    Group variable: idcode                          Number of groups  =      4,710
    
    R-sq:                                           Obs per group:
         within  = 0.1026                                         min =          1
         between = 0.0877                                         avg =        6.1
         overall = 0.0774                                         max =         15
    
                                                    Wald chi2(1)      =    3140.35
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |   .0185667   .0003313    56.04   0.000     .0179174    .0192161
           _cons |   1.120439   .0112038   100.01   0.000      1.09848    1.142398
    -------------+----------------------------------------------------------------
         sigma_u |  .36972456
         sigma_e |  .30349389
             rho |  .59743613   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . xttest0
    
    Breusch and Pagan Lagrangian multiplier test for random effects
    
            ln_wage[idcode,t] = Xb + u[idcode] + e[idcode,t]
    
            Estimated results:
                             |       Var     sd = sqrt(Var)
                    ---------+-----------------------------
                     ln_wage |   .2285836       .4781042
                           e |   .0921085       .3034939
                           u |   .1366963       .3697246
    
            Test:   Var(u) = 0
                                 chibar2(01) = 28235.40
                              Prob > chibar2 =   0.0000
    
    . return list
    
    scalars:
                      r(p) =  0
                     r(df) =  1
                     r(lm) =  28235.39703475597
    
    . g A=r(p)
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you very much.
      Getting a new useful skill

      Comment


      • #4
        Dear all,

        may someone clarify, how I can export the results from xttest0 to word?

        If I write:
        xtreg dep indep, re
        xttest0
        outreg2 using new, word dec(3) replace ctitle(new)

        I'll just get the random effects regression but not the results of xttest0.

        If I write:
        asdoc xtreg dep indep, re , save(new) replace
        asdoc xttest0, save(new) append

        I get the error:
        invalid syntax
        r(198);

        I face the same problem when I do tests with xttest3.

        Thank you
        BR Eduard

        Comment


        • #5
          No need to create a variable to store these scalars, Just ssc install estout

          Code:
          . webuse grunfeld,clear
          
          . eststo clear
          
          . eststo:qui xtreg invest mvalue kstock,re
          (est1 stored)
          
          . xttest0
          
          Breusch and Pagan Lagrangian multiplier test for random effects
          
                  invest[company,t] = Xb + u[company] + e[company,t]
          
                  Estimated results:
                                   |       Var     SD = sqrt(Var)
                          ---------+-----------------------------
                            invest |   47034.89       216.8753
                                 e |   2784.458       52.76796
                                 u |     7089.8       84.20095
          
                  Test: Var(u) = 0
                                       chibar2(01) =   798.16
                                    Prob > chibar2 =   0.0000
          
          . qui estadd scalar LM=r(lm)
          
          . qui estadd scalar LM_pval=r(p)
          
          . esttab, stat(N LM LM_pval) star(* 0.1 ** 0.05 *** 0.01)
          
          ----------------------------
                                (1)   
                             invest   
          ----------------------------
          mvalue              0.110***
                            (10.46)   
          
          kstock              0.308***
                            (17.93)   
          
          _cons              -57.83** 
                            (-2.00)   
          ----------------------------
          N                     200   
          LM                  798.2   
          LM_pval         6.77e-176   
          ----------------------------
          t statistics in parentheses
          * p<0.1, ** p<0.05, *** p<0.01
          
          . 
          end of do-file
          
          .

          Comment


          • #6
            Awesome, thanks a lot!

            Comment


            • #7
              Dear all,

              ​​​​​​​I applied the code of KitBaum, which works well for xttest3. However, it doesn't work for the results of .collin:
              Code used:
              PHP Code:
              eststo clear
              eststo
              :qui xtreg dep indepfe 
              collin indep 
              qui estadd scalar VIF
              =r(vif)
              qui estadd scalar TOL=r(tolerance)
              esttab using new.docstat(N VIF TOLstar(* 0.1 ** 0.05 *** 0.01append 
              So my question is, how can I export results from .collin smoothly? That said I am only interested in VIF and Tolerance values of the collin command, but I don't know how to suppress the other outcomes.

              Thank you and best regards
              Eduard

              Comment

              Working...
              X