Announcement

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

  • changing col headers in etable

    if I estimate two mlogit commands with the same outcome (dependent) variable but different sets of covariates, I will, by default, get from e(table) the name of the outcome variable as the column header (see below); I want to change that to show something else so the columns will be easier to refer to; the following simple (and unrealistic) example shows the result and my attempt to change one of the headers using the eqrecode option:

    Code:
    . sysuse auto
    (1978 automobile data)
    
    . mlogit rep78 price
    
    Iteration 0:  Log likelihood = -93.692061  
    Iteration 1:  Log likelihood = -93.113707  
    Iteration 2:  Log likelihood = -92.974678  
    Iteration 3:  Log likelihood = -92.970763  
    Iteration 4:  Log likelihood = -92.970763  
    
    Multinomial logistic regression                         Number of obs =     69
                                                            LR chi2(4)    =   1.44
                                                            Prob > chi2   = 0.8368
    Log likelihood = -92.970763                             Pseudo R2     = 0.0077
    
    ------------------------------------------------------------------------------
           rep78 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    1            |
           price |   -.000549   .0007284    -0.75   0.451    -.0019766    .0008786
           _cons |   .1169081   3.421563     0.03   0.973    -6.589231    6.823048
    -------------+----------------------------------------------------------------
    2            |
           price |  -.0000547   .0001431    -0.38   0.703    -.0003352    .0002259
           _cons |  -.9834618    .952914    -1.03   0.302    -2.851139    .8842154
    -------------+----------------------------------------------------------------
    3            |  (base outcome)
    -------------+----------------------------------------------------------------
    4            |
           price |   -.000041   .0001027    -0.40   0.690    -.0002424    .0001603
           _cons |  -.2545298   .7025195    -0.36   0.717    -1.631443    1.122383
    -------------+----------------------------------------------------------------
    5            |
           price |  -.0000622   .0001279    -0.49   0.627    -.0003129    .0001884
           _cons |  -.6201496   .8475732    -0.73   0.464    -2.281363    1.041063
    ------------------------------------------------------------------------------
    
    . est store m1
    
    . mlogit rep78 mpg
    
    Iteration 0:  Log likelihood = -93.692061  
    Iteration 1:  Log likelihood = -86.581485  
    Iteration 2:  Log likelihood = -85.767758  
    Iteration 3:  Log likelihood = -85.752385  
    Iteration 4:  Log likelihood = -85.752375  
    Iteration 5:  Log likelihood = -85.752375  
    
    Multinomial logistic regression                         Number of obs =     69
                                                            LR chi2(4)    =  15.88
                                                            Prob > chi2   = 0.0032
    Log likelihood = -85.752375                             Pseudo R2     = 0.0847
    
    ------------------------------------------------------------------------------
           rep78 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    1            |
             mpg |   .0708122   .1471461     0.48   0.630    -.2175888    .3592132
           _cons |  -4.137144    3.15707    -1.31   0.190    -10.32489      2.0506
    -------------+----------------------------------------------------------------
    2            |
             mpg |  -.0164251   .0926724    -0.18   0.859    -.1980597    .1652096
           _cons |  -1.005118   1.822129    -0.55   0.581    -4.576426     2.56619
    -------------+----------------------------------------------------------------
    3            |  (base outcome)
    -------------+----------------------------------------------------------------
    4            |
             mpg |   .0958626   .0633329     1.51   0.130    -.0282676    .2199927
           _cons |  -2.474187   1.341131    -1.84   0.065    -5.102756    .1543813
    -------------+----------------------------------------------------------------
    5            |
             mpg |   .2477469   .0764076     3.24   0.001     .0979908     .397503
           _cons |  -6.653164   1.841794    -3.61   0.000    -10.26301   -3.043314
    ------------------------------------------------------------------------------
    r; t=0.03 8:49:53
    
    . est store m2
    
    . etable, estimates(m1 m2) showeq eqrecode(m1 = mi) cstat(_r_b) cstat(_r_p)
    
    ------------------------------------
                            rep78  rep78
    ------------------------------------
    1                                  
      Price                -0.001      
                             0.45      
      Mileage (mpg)                0.071
                                    0.63
      Intercept             0.117 -4.137
                             0.97   0.19
    2                                  
      Price                -0.000      
                             0.70      
      Mileage (mpg)               -0.016
                                    0.86
      Intercept            -0.983 -1.005
                             0.30   0.58
    4                                  
      Price                -0.000      
                             0.69      
      Mileage (mpg)                0.096
                                    0.13
      Intercept            -0.255 -2.474
                             0.72   0.07
    5                                  
      Price                -0.000      
                             0.63      
      Mileage (mpg)                0.248
                                    0.00
      Intercept            -0.620 -6.653
                             0.46   0.00
    Number of observations     69     69
    ------------------------------------
    here, I attempted to change the first column header to "mi" but no change was made

    I think that my problem is that I don't understand what the equation name is for mlogit, but it could be something else???

    In case it makes a difference, in my actual data, I will have one column for the data with missing values and one column that comes after multiple imputation and using "mi estimate"
    Last edited by Rich Goldstein; 13 Feb 2026, 07:03.

  • #2
    You can name the estimates using the desired column name and add the option -column(estimates)- to etable. However, this restricts you to a single-word column name, or to using underscores in place of spaces. A more general solution is to use collect to modify the column titles.

    Code:
    sysuse auto, clear
    mlogit rep78 price
    est store m1
    mlogit rep78 mpg
    est store m2
    etable, estimates(m1 m2) cstat(_r_b) cstat(_r_p)
    *LOOK AT ETABLE'S LAYOUT
    collect layout
    collect levelsof etable_depvar
    *CHANGE LABELS
    collect label levels etable_depvar 1 "mi" 2 "rep78", modify
    collect style header etable_depvar, title(hide) level(label)
    collect preview
    Res.:

    Code:
    . collect preview
    
    ------------------------------------
                             mi    rep78
    ------------------------------------
    1                                  
      Price                -0.001      
                             0.45      
      Mileage (mpg)                0.071
                                    0.63
      Intercept             0.117 -4.137
                             0.97   0.19
    2                                  
      Price                -0.000      
                             0.70      
      Mileage (mpg)               -0.016
                                    0.86
      Intercept            -0.983 -1.005
                             0.30   0.58
    4                                  
      Price                -0.000      
                             0.69      
      Mileage (mpg)                0.096
                                    0.13
      Intercept            -0.255 -2.474
                             0.72   0.07
    5                                  
      Price                -0.000      
                             0.63      
      Mileage (mpg)                0.248
                                    0.00
      Intercept            -0.620 -6.653
                             0.46   0.00
    Number of observations     69     69
    ------------------------------------
    Last edited by Andrew Musau; 13 Feb 2026, 07:47.

    Comment


    • #3
      thank you

      Comment

      Working...
      X