Announcement

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

  • Output table Stata

    Hi,

    I am running several regressions and then want to ouput the results in a concise manner in Excel. Here is the code I have so far:

    Code:
    use sample_noise.dta, clear
    
    global var "ch3m_noise_w"
    global All_ANO "beta as_turn retvol gma maxret ms ps rsup stdacc baspread chfeps"
    
    foreach i of varlist $All_ANO {
    gen D_`i'_L1_$var = D_`i'*L1_$var
    gen D_`i'_L1_D_$var = D_`i'*L1_D_$var
    
    quietly newey `i' L1_D_$var D_`i'_L1_D_$var  D_`i', lag(5) force
    outreg2 using "publi_date_B", label ctitle(`i') dta dec(3)  tstat nocons drop(Mkt_RF SMB HML) alpha(.02, .10, .20)  nonotes addnote(t-statistics in parentheses, one-sided t-statistics, ***p<0.01; **p<0.05; *p<0.10)
    }
    
    use "publi_date_B_dta.dta", clear
    export excel using $var.xlsx , /*replace*/ sheetreplace sheet("Publication Date - B")
    Here are my data:
    Code:
    ym    beta    as_turn    retvol    gma    maxret    ms    ps    rsup    stdacc    baspread    chfeps    RF    Mkt_RF    SMB    HML    ch_noise_w
    1987m4    -4.031828    .5665293    -3.562902    2.933317    -1.926573    3.800406    -2.135415    -.9528576    1.526641    -2.12236        .44    -2.11    -1.69    -.32    1.411289
    1987m5    -3.087543    2.355569    -.9416796    2.959575    -1.319767    1.384146    .5161018    -1.156925    -.0712486    -1.06877        .38    .11    -.52    .12    .9583769
    1987m6    7.496861    1.482077    6.705112    -.1577106    4.175952    -2.045524    2.241884    -.0834573    4.511261    6.729168        .48    3.94    -2.19    1.06    -1.572835
    1987m7    -.7845994    4.364578    -1.916614    1.008461    -1.837684    -.1531013    -3.019662    .2370811    -.0668041    -1.103105        .46    3.85    -.63    .71    .5004749
    1987m8    -2.976107    -2.516852    1.206757    .2214915    2.291762    3.888111    -.4897887    -.438806    1.781745    -.5335383        .47    3.52    -.74    -.93    -.1788225
    1987m9    1.904939    -1.197485    .1444719    -1.925517    .0050595    .6573381    -.7300012    -.0531384    -1.353002    .2657921        .45    -2.59    .54    .28    -1.031109
    1987m10    17.75418    -5.55263    15.11718    -3.967996    13.53885    1.86781    7.497076    -5.16283    8.344318    11.80085        .6    -23.24    -8.42    4.23    3.158195
    1987m11    10.24424    -3.26521    6.36503    -2.471189    6.13591    -4.476544    2.878814    -.4599758    -.158664    7.624292        .35    -7.77    2.76    3.08    -1.720168
    1987m12    -14.48465    6.121767    -9.588703    10.2468    -2.803698    11.10483    -.6215067    3.757487    2.847481    -8.252355        .39    6.81    .14    -4.45    -.218431
    1988m1    8.98735    -4.744936    2.563546    -6.0894    5.822382    -8.084696    -.9711636    -2.828097    .4125161    3.11357        .29    4.21    -.71    5.17    -1.605674
    1988m2    -11.30435    5.810012    -7.698685    5.288568    -5.822155    -.1363569    .1767531    1.833565    -2.178874    -6.341976        .46    4.75    3.35    -1.65    -.3186386
    1988m3    -4.71446    2.996438    -3.620034    .6127492    -4.374222    -2.141388    -1.642055    2.848933    -1.324977    .2735081        .44    -2.27    6.14    .75    .9501665
    1988m4    -1.944875    2.094418    .1226072    1.455372    -.3637265    -2.17255    -.7365742    .7938695    .3418547    .0474411        .46    .56    .96    1.68    -.4561872
    1988m5    4.106129    -1.57732    1.219917    -3.584458    2.328698    -1.720937    .313263    -.3385183    -2.443667    .5164252        .51    -.29    -2.65    2.28    -.2478542
    1988m6    -6.995058    -.1835973    -1.383736    1.829104    .2131224    -.6020278    .8326551    4.12623    .341608    -3.691374        .49    4.79    2.1    -1.11    .2288923
    1988m7    4.299152    -1.0834    1.712216    -4.078659    1.927485    -3.047734    -.3123012    -.7608059    -1.164788    2.128115        .51    -1.25    -.2    2.27    .2419186
    1988m8    5.018091    -1.384443    4.545624    -2.733395    3.714663    -4.245328    -1.209007    -1.721197    -.1595033    3.795788        .59    -3.31    .08    2.08    .527565


    Here is the output I'm getting:
    Code:
     
    (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12)
    VARIABLES Test beta assetturnover retvol gma maxret ms ps rsup stdacc baspread chfeps
    Ch. Noise(t-1) 0.212* 0.776** 0.365*** -0.388 0.453*** 0.648** 0.194 -0.207 0.089 0.257** 1.224*** 0.373**
    (1.396) (2.080) (2.383) (-0.482) (3.547) (2.127) (0.656) (-1.172) (0.841) (2.215) (5.639) (2.330)
    D_beta_L1_ch3m_noise_w -4.393***
    (-3.507)
    D_beta 1.028
    (0.937)
    D_assetturnover_L1_ch3m_noise_w = o, -
    D_assetturnover = o, -
    D_retvol_L1_ch3m_noise_w 1.599**
    (1.884)
    D_retvol -0.688
    (-0.859)
    D_gma_L1_ch3m_noise_w -0.297
    (-0.295)
    D_gma -0.407
    (-0.862)
    D_maxret_L1_ch3m_noise_w -0.641
    (-0.458)
    D_maxret -0.191
    (-0.282)
    D_ms_L1_ch3m_noise_w 0.138
    (0.453)
    D_ms -0.033
    (-0.096)
    D_ps_L1_ch3m_noise_w 0.676***
    (3.428)
    D_ps 0.205
    (0.770)
    D_rsup_L1_ch3m_noise_w 0.566**
    (2.201)
    D_rsup 0.168
    (0.607)
    D_stdacc_L1_ch3m_noise_w -1.079**
    (-2.093)
    D_stdacc -0.163
    (-0.364)
    D_baspread_L1_ch3m_noise_w -0.418
    (-0.905)
    D_baspread -0.026
    (-0.031)
    D_chfeps_L1_ch3m_noise_w = o, -
    D_chfeps = o, -
    Observations 312 332 332 332 332 332 332 332 332 332 332 312
    t-statistics in parentheses
    one-sided t-statistics
    ***p<0.01; **p<0.05; *p<0.10
    I would like to present the regression coefficients on the same row:

    Code:
     
    (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12)
    VARIABLES Test beta assetturnover retvol gma maxret ms ps rsup stdacc baspread chfeps
    Ch. Noise(t-1) 0.212* 0.776** 0.365*** -0.388 0.453*** 0.648** 0.194 -0.207 0.089 0.257** 1.224*** 0.373**
    (1.396) (2.080) (2.383) (-0.482) (3.547) (2.127) (0.656) (-1.172) (0.841) (2.215) (5.639) (2.330)
    D_ANO_L1_ch3m_noise_w -4.393*** - 1.599** -0.297 -0.641 0.138 0.676*** 0.566** -1.079** -0.418 -
    (-3.507) (1.884) (-0.295) (-0.458) (0.453) (3.428) (2.201) (-2.093) (-0.905)
    D_ANO 1.028 - -0.688 -0.407 -0.191 -0.033 0.205 0.168 -0.163 -0.026 -
    (0.937) (-0.859) (-0.862) (-0.282) (-0.096) (0.770) (0.607) (-0.364) (-0.031)
    Observations 312 332 332 332 332 332 332 332 332 332 332 312
    t-statistics in parentheses
    one-sided t-statistics
    ***p<0.01; **p<0.05; *p<0.10
    How can I achieve this outcome? Thanks!


  • #2
    Is there anything unclear? Can I help understand anything? Thanks a lot!

    Comment


    • #3
      I'd like to mention that I'd be happy with any help/solution even if it does not go through the command "outreg2" thanks!

      Comment


      • #4
        How about relabelling all your variables "D_ANO_L1_ch3m_noise_w" og "D_ANO" and use the label option (if it exists)

        Comment


        • #5
          That would be great, I just do not know how to program that. Would you be able to help? Thanks

          Comment


          • #6
            Anyone could help me with that? Thanks a lot in advance!

            Comment


            • #7
              Francois Durant Ok, forget about what I suggested it does not work.
              One solution I see is to create two temporary variables with names D_ANO_L1_ch3m_noise_w and D_ANO which content are replaced during the loop with the same expression using the relevant variable. Hope this helps.

              Code:
              local replace 
              foreach i of varlist $All_ANO {
              cap drop D_ANO_L1_ch3m_noise_w
              cap drop D_ANO
              gen D_ANO_L1_$var = D_`i'*L1_$var
              gen D_ANO_L1_D_$var = D_`i'*L1_D_$var
              
              quietly newey `i' L1_D_$var D_ANO_L1_D_$var  D_ANO, lag(5) force
              outreg2 using "publi_date_B", `replace' label ctitle(`i') dta dec(3)  tstat nocons drop(Mkt_RF SMB HML) alpha(.02, .10, .20)  nonotes addnote(t-statistics in parentheses, one-sided t-statistics, ***p<0.01; **p<0.05; *p<0.10)
              local replace
              }
              Here is a working example
              Code:
              sysuse auto ,clear
              
              cd C:\Users\Christophe\Documents
              
              local replace replace
              foreach x in weight mpg {
              cap drop x
              gen x = `x'
              reg price x 
              outreg2 using "publi_date_B", label dta `replace'
              local replace
              }

              Comment


              • #8
                Thank you so much for taking the time to look at and solve my problem Christophe, I really appreciate it. It really helps for my research!

                Comment

                Working...
                X