Announcement

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

  • Esttab, appendmodels & selected coefficients from different estimation models

    Good morning,

    I am having a bit of trouble to create a table reporting selected coefficients that I am obtaining from different estimation models. In addition, each of the estimation uses different dependent variables. Below is what I am trying to do

    Code:
    *RA regression
    foreach depvar of var Y1 Y2 Y3{
    local covariates X1 X2 X3
    eststo `depvar'_ra:teffects ra (`depvar' `covariates') (T), atet
    }
    and,
    Code:
    *OLS regression
    foreach depvar of var Y1 Y2 Y3{
    local covariates X1 X2 X3
    eststo `depvar'_ols:reg depvar'  T `covariates'
    }
    *Run programm appendmodels using Ben Jann's dofile
    Code:
    do "$dofile/appendmodels.do"
    Code:
    eststo dimensions_ra: appendmodels Y1_ra Y2_ra Y3_ra
    eststo dimensions_ols: appendmodels Y1_ols Y2_ols Y3_ols
    Code:
    esttab dimensions_ra dimensions_ols, compress  keep (r1vs0.T  T) ///
    coef ( r1vs0.T "ATE" T "ATE") mtitles("RA" "OLS")
    The table that I obtained has two columns as expected but the coefficients are not matched

    Code:
     
    
        
        (1)          (2)   
        RA          OLS   
        
    main                           
    ATE    -0.260**              
        (-3.03)                
    
    ATE    -0.652***             
        (-5.54)                
    
    ATE    -0.825***             
        (-8.12)                
    
    ATE    -0.342**              
        (-3.11)                      
    
    ATE    -0.680***
        (-6.79)   
    
    ATE   -1.048***
        (-9.60)   
    
    ATE   -0.473***
        (-3.63)   
    
        
    t statistics    in parentheses
    * p<0.05, **    p<0.01, *** p<0.001
    So I have the following questions in case some Stata user can help me:
    1 - How can find the right code to have a table with two columns but only three ATE rows?
    2 - How can I change the ATE name to ATE_Y1, ATE_Y2 and ATE_Y3? Should I do it by changing the rownames in matrix r(coefs)?

    Thank you very much for your help.
    Rubén

  • #2
    You can temporarily rename "T" in each loop. Once the "T"s have unique names, you can use the "rename()" option of estout.

    Code:
    *RA regression
    foreach depvar of var Y1 Y2 Y3{
        rename T T`depvar'
        local covariates X1 X2 X3
        eststo `depvar'_ra: teffects ra (`depvar' `covariates') (T`depvar'), atet
        rename T`depvar' T
    }
    
    *OLS regression
    foreach depvar of var Y1 Y2 Y3{
        rename T T`depvar'
        local covariates X1 X2 X3
        eststo `depvar'_ols: reg `depvar'  T`depvar' `covariates'
        rename T`depvar' T
    }
    
    *Run programm appendmodels using Ben Jann's dofile
    do "$dofile/appendmodels.do"
    
    eststo dimensions_ra: appendmodels Y1_ra Y2_ra Y3_ra
    eststo dimensions_ols: appendmodels Y1_ols Y2_ols Y3_ols
    
    esttab dimensions_ra dimensions_ols, compress  rename(r1vs0.TY1 TY1  r1vs0.TY2 TY2  r1vs0.TY3 TY3) keep(TY?) ///
        coef(TY1 "ATE for Y1" TY2 "ATE for Y2" TY3 "ATE for Y3") mtitles("RA" "OLS")
    Depending on how gnarly your actual Y1…3 variable names are, you may want to make tweaks, but that should give you the gist.

    This yields the below table (with different numbers since I didn't have your data).

    Code:
    ------------------------------------
                     (1)          (2)  
                      RA          OLS  
    ------------------------------------
    main                                
    ATE for Y1    3348.1***    3550.2***
                  (5.26)       (5.42)  
    
    ATE for Y2     1.200***     1.314***
                  (4.05)       (4.81)  
    
    ATE for Y3     1.067        0.658  
                  (0.96)       (0.68)  
    ------------------------------------
    N                                  
    ------------------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001
    Last edited by Nils Enevoldsen; 10 Mar 2022, 15:50.

    Comment


    • #3
      Dear Nils,
      Thank you so much! Your suggestion is smart and intuitive and, of course, it works perfectly well.

      Comment

      Working...
      X