Announcement

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

  • xtrc + outreg2

    Dear All, I ran the following regression:
    Code:
    webuse grunfeld, clear
    
    xtset company year
    
    xtrc invest mvalue kstock, beta
    outreg2 using "xtrc", excel dec(3) replace
    with outcomes
    Code:
    . xtrc invest mvalue kstock, beta
    
    Random-coefficients regression                  Number of obs     =        200
    Group variable: company                         Number of groups  =         10
    
                                                    Obs per group:
                                                                  min =         20
                                                                  avg =       20.0
                                                                  max =         20
    
                                                    Wald chi2(2)      =      38.84
                                                    Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
          invest |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .0845873   .0199559     4.24   0.000     .0454745    .1237002
          kstock |   .1994184   .0526534     3.79   0.000     .0962197    .3026171
           _cons |  -9.629282   17.03503    -0.57   0.572    -43.01734    23.75877
    ------------------------------------------------------------------------------
    Test of parameter constancy:    chi2(27) =   901.43       Prob > chi2 = 0.0000
    
                            Group-specific coefficients
    ------------------------------------------------------------------------------
                        Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ------------------------------------------------------------------------------
         Group 1 | 
    -------------+----------------------------------------------------------------
          mvalue |   .0981462   .0087433    11.23   0.000     .0810097    .1152828
          kstock |   .3722458   .0375976     9.90   0.000     .2985559    .4459356
           _cons |  -55.44177   19.94628    -2.78   0.005    -94.53576   -16.34779
    -------------+----------------------------------------------------------------
         Group 2 | 
    -------------+----------------------------------------------------------------
          mvalue |   .1729062   .0162539    10.64   0.000     .1410491    .2047633
          kstock |   .3105774   .0893991     3.47   0.001     .1353584    .4857964
           _cons |  -30.09974   23.32863    -1.29   0.197    -75.82302    15.62354
    -------------+----------------------------------------------------------------
         Group 3 | 
    -------------+----------------------------------------------------------------
          mvalue |   .0251393   .0122704     2.05   0.040     .0010899    .0491888
          kstock |   .1515969   .0276489     5.48   0.000     .0974061    .2057878
           _cons |  -6.562793   23.40595    -0.28   0.779    -52.43762    39.31203
    -------------+----------------------------------------------------------------
         Group 4 | 
    -------------+----------------------------------------------------------------
          mvalue |   .0810174   .0192287     4.21   0.000     .0433298     .118705
          kstock |   .3103015   .0305597    10.15   0.000     .2504055    .3701974
           _cons |  -7.788197   13.20259    -0.59   0.555     -33.6648    18.08841
    -------------+----------------------------------------------------------------
         Group 5 | 
    -------------+----------------------------------------------------------------
          mvalue |   .1209065   .0320356     3.77   0.000      .058118    .1836951
          kstock |   .0181317   .0159495     1.14   0.256    -.0131288    .0493923
           _cons |   24.95391    6.72261     3.71   0.000     11.77783    38.12998
    -------------+----------------------------------------------------------------
         Group 6 | 
    -------------+----------------------------------------------------------------
          mvalue |   .1159036   .0217112     5.34   0.000     .0733505    .1584567
          kstock |   .1351526   .0677458     1.99   0.046     .0023732    .2679319
           _cons |  -7.346842   4.644928    -1.58   0.114    -16.45073     1.75705
    -------------+----------------------------------------------------------------
         Group 7 | 
    -------------+----------------------------------------------------------------
          mvalue |   .0891736   .0319398     2.79   0.005     .0265728    .1517744
          kstock |   .1244533   .0185686     6.70   0.000     .0880596     .160847
           _cons |    -4.9349   7.979126    -0.62   0.536     -20.5737     10.7039
    -------------+----------------------------------------------------------------
         Group 8 | 
    -------------+----------------------------------------------------------------
          mvalue |   .0511706    .015045     3.40   0.001      .021683    .0806582
          kstock |   .1048735   .0518497     2.02   0.043       .00325    .2064969
           _cons |  -.3579146    8.30961    -0.04   0.966    -16.64445    15.92862
    -------------+----------------------------------------------------------------
         Group 9 | 
    -------------+----------------------------------------------------------------
          mvalue |   .0775452   .0282758     2.74   0.006     .0221255    .1329648
          kstock |   .0825908   .0278685     2.96   0.003     .0279696     .137212
           _cons |  -8.524686   9.271697    -0.92   0.358    -26.69688    9.647507
    -------------+----------------------------------------------------------------
        Group 10 | 
    -------------+----------------------------------------------------------------
          mvalue |   .0139647   .0240671     0.58   0.562     -.033206    .0611353
          kstock |   .3842605   .0638395     6.02   0.000     .2591375    .5093836
           _cons |  -.1898842    1.72094    -0.11   0.912    -3.562865    3.183097
    ------------------------------------------------------------------------------
    
    . outreg2 using "xtrc", excel dec(3) replace
    xtrc.xml
    dir : seeout
    My question is: How can I use outreg2 (please ssc install outreg2) to collect the coefficients in Group 1-10 along with the original main result in the excel file?
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)
Working...
X