Announcement

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

  • Esttab output not showing correct variable names after using the "i."-command

    Hello everyone,
    I am doing an analysis and am struggling with the esttab feature, more specifically with the names for the variables:

    I'm doing a regression that takes five continents into account, which I modelled by using the "i."-command. Now the problem is that the esttab command doesn't properly display the continent names anymore and I cannot find a way to change the variable names. When using the "label" command, it doesn't work and only puts out:

    1bn.Countries' continent .
    .

    2.Countries' continent 1.210**
    (3.04)

    3.Countries' continent 0.365
    (1.13)

    4.Countries' continent 1.036*
    (2.45)

    5.Countries' continent



    Which does not look nice, as the names should obviously be Africa, Europe, Americas, Asia, Oceania

    I tried everything I could and also googled around but couldn't find a solution so I'm glad if anyone can point me in the right direction.


    Thanks in advance and all best,

    Josef

  • #2
    Code:
    . clear all
    
    . sysuse auto
    (1978 automobile data)
    
    . describe foreign
    
    Variable      Storage   Display    Value
        name         type    format    label      Variable label
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
    foreign         byte    %8.0g      origin     Car origin
    
    . label list origin
    origin:
               0 Domestic
               1 Foreign
    
    . eststo: reg price i.foreign
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(1, 72)        =      0.17
           Model |  1507382.66         1  1507382.66   Prob > F        =    0.6802
        Residual |   633558013        72  8799416.85   R-squared       =    0.0024
    -------------+----------------------------------   Adj R-squared   =   -0.0115
           Total |   635065396        73  8699525.97   Root MSE        =    2966.4
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         foreign |
        Foreign  |   312.2587   754.4488     0.41   0.680    -1191.708    1816.225
           _cons |   6072.423    411.363    14.76   0.000     5252.386     6892.46
    ------------------------------------------------------------------------------
    (est1 stored)
    
    . esttab .,
    
    ----------------------------
                          (1)   
                        price   
    ----------------------------
    0.foreign               0   
                          (.)   
    
    1.foreign           312.3   
                       (0.41)   
    
    _cons              6072.4***
                      (14.76)   
    ----------------------------
    N                      74   
    ----------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001
    
    . esttab ., label
    
    ------------------------------------
                                  (1)   
                                Price   
    ------------------------------------
    Domestic                        0   
                                  (.)   
    
    Foreign                     312.3   
                               (0.41)   
    
    Constant                   6072.4***
                              (14.76)   
    ------------------------------------
    Observations                   74   
    ------------------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001
    
    . 
    end of do-file

    Comment


    • #3
      Originally posted by Øyvind Snilsberg View Post
      Thank you so much for your fast reply. For some reason, this approach does not give me the correct labels, here's my code and the output:

      Code:
      . label list
      continnt_en:
                 1 Africa
                 2 Americas
                 3 Asia
                 4 Europe
                 5 Oceania
      
      reg log_gdp_n i.continent_en traditional_n kinship_n popdense_n latitude_n oil_rent_n, robust
      eststo m4
      
      
      esttab m1 m2 m3 m4, label varwidth(25) ///
              nonumbers mtitles("Model 1" "Model 2" "Model 3" "Model 4")
      
      Output:
      ------------------------------------------------------------------------------------
                                Model 1         Model 2         Model 3         Model 4  
      ------------------------------------------------------------------------------------
      traditional_n               0.973***                        0.803***        0.637***
                                 (8.10)                          (6.64)          (4.20)  
      
      Kinship index.. 2019                       -0.700***       -0.336**        -0.101  
                                                (-5.83)         (-3.16)         (-0.65)  
      
      1bn.Continent                                                                   .  
                                                                                      .  
      
      2.Continent                                                                 1.210**
                                                                                 (3.04)  
      
      3.Continent                                                                 0.365  
                                                                                 (1.13)  
      
      4.Continent                                                                 1.036*  
                                                                                 (2.45)  
      
      5.Continent                                                                 2.316***
                                                                                 (6.03)  
      
      Population density~i                                                    0.0000748*  
                                                                                 (2.62)  
      
      Latitude of the co~y                                                      0.00683  
                                                                                 (1.39)  
      
      Oil Rent (% of ~2020                                                       0.0503  
                                                                                 (1.82)  
      
      Constant                    9.320***        8.872***        9.180***        8.180***
                               (110.83)         (75.77)        (100.48)         (33.19)  
      ------------------------------------------------------------------------------------
      Observations                  106             104             104             102  
      ------------------------------------------------------------------------------------
      t statistics in parentheses
      * p<0.05, ** p<0.01, *** p<0.001


      Do you have any suggestion why I can't get this to work?
      Last edited by Josef Bialas; 11 Dec 2022, 08:11.

      Comment


      • #4
        what happens if you run,
        Code:
        clear all
        sysuse auto
        reg price i.foreign
        esttab ., label
        can you give a reproducible data example?
        Last edited by Øyvind Snilsberg; 11 Dec 2022, 11:32.

        Comment


        • #5
          Without a -dataex- example, I can't be sure. But my best guess is that in O.P.'s data set, although the value label continent_en is defined, it has not actually been applied to the variable continent_en. If this is correct, running -label values continent_en continent_en- and then redoing the regression and -esttab- will solve the problem.

          Comment


          • #6
            Thanks to both of you for your help. For some frustrating reason, Stata still doesn't cooperate even though I did as you advised me to. So, here's a data example:
            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input float log_gdp_n long continent_en str9 continent
             8.581699 4 "Europe"  
             8.104056 1 "Africa"  
              10.5299 4 "Europe"  
             9.057969 2 "Americas"
              8.35867 3 "Asia"    
            10.852852 5 "Oceania" 
            10.791166 4 "Europe"  
             8.350173 3 "Asia"    
             7.728128 3 "Asia"    
             8.788201 4 "Europe"  
             10.71864 4 "Europe"  
             8.051657 2 "Americas"
             8.713313 4 "Europe"  
              8.82701 2 "Americas"
             9.218328 4 "Europe"  
             6.755691 1 "Africa"  
            10.674967 2 "Americas"
             9.489605 2 "Americas"
              9.25049 3 "Asia"    
              8.57795 2 "Americas"
             9.556302 4 "Europe"  
            10.228559 4 "Europe"  
            10.040398 4 "Europe"  
            11.019683 4 "Europe"  
             8.635647 2 "Americas"
             8.180379 1 "Africa"  
            10.045653 4 "Europe"  
             6.843164 1 "Africa"  
            10.802873 4 "Europe"  
            10.572294 4 "Europe"  
             8.356259 3 "Asia"    
            10.741897 4 "Europe"  
             7.720973 1 "Africa"  
             10.62374 4 "Europe"  
             9.778391 4 "Europe"  
             8.434754 2 "Americas"
             7.149421 2 "Americas"
             10.73861 3 "Asia"    
             9.685143 4 "Europe"  
            10.989775 4 "Europe"  
             7.567398 3 "Asia"    
             8.261413 3 "Asia"    
              7.92217 3 "Asia"    
            8.4304905 3 "Asia"    
            10.695995 3 "Asia"    
            10.368352 4 "Europe"  
            10.594612 3 "Asia"    
             8.362588 3 "Asia"    
             9.118514 3 "Asia"    
             7.535363 1 "Africa"  
              7.07625 3 "Asia"    
               9.7816 4 "Europe"  
             8.243491 3 "Asia"    
             8.937918 1 "Africa"  
             9.915085 4 "Europe"  
            10.581626 3 "Asia"    
             9.250844 3 "Asia"    
             8.842909 3 "Asia"    
              6.76094 1 "Africa"  
             9.039868 2 "Americas"
             8.417762 4 "Europe"  
             8.309419 3 "Asia"    
             8.948408 4 "Europe"  
              8.02607 1 "Africa"  
             7.280465 3 "Asia"    
             8.673763 4 "Europe"  
            10.866605 4 "Europe"  
            10.635796 5 "Oceania" 
             7.550159 2 "Americas"
             7.648784 1 "Africa"  
            11.117372 4 "Europe"  
             7.215618 3 "Asia"    
             8.719071 2 "Americas"
              8.10235 3 "Asia"    
              9.66418 4 "Europe"  
            10.007648 4 "Europe"  
            10.355546 2 "Americas"
            10.822283 3 "Asia"    
             9.469435 4 "Europe"  
             9.226507 4 "Europe"  
             6.668612 1 "Africa"  
             9.913669 1 "Africa"  
             8.953083 4 "Europe"  
              11.0142 3 "Asia"    
             9.866176 4 "Europe"  
             10.14606 4 "Europe"  
             8.640626 1 "Africa"  
            10.360865 3 "Asia"    
            10.205717 4 "Europe"  
            10.864775 4 "Europe"  
            11.374828 4 "Europe"  
             6.749733 3 "Asia"    
             6.982371 1 "Africa"  
             8.876233 3 "Asia"    
             9.634754 2 "Americas"
             8.188194 1 "Africa"  
             9.052216 3 "Asia"    
              6.71299 1 "Africa"  
             8.230242 4 "Europe"  
             9.643409 2 "Americas"
            end
            label values continent_en continent_en
            label def continent_en 1 "Africa", modify
            label def continent_en 2 "Americas", modify
            label def continent_en 3 "Asia", modify
            label def continent_en 4 "Europe", modify
            label def continent_en 5 "Oceania", modify
            
            //Regression table: 
            reg log_gdp_n i.continent_en 
            eststo m1 
            esttab m1, label
            Clyde, I see that you already suggested the -label values continent_en continent_en- command which the dataex-command also put out, but it still does not work. Can anyone figure out what's wrong?

            Comment


            • #7
              I am unable to reproduce the error you are getting:
              Code:
              . * Example generated by -dataex-. For more info, type help dataex
              . clear
              
              . input float log_gdp_n long continent_en str9 continent
              
                   log_gdp_n  continent_en  continent
                1.  8.581699 4 "Europe"  
                2.  8.104056 1 "Africa"  
                3.   10.5299 4 "Europe"  
                4.  9.057969 2 "Americas"
                5.   8.35867 3 "Asia"    
                6. 10.852852 5 "Oceania"
                7. 10.791166 4 "Europe"  
                8.  8.350173 3 "Asia"    
                9.  7.728128 3 "Asia"    
               10.  8.788201 4 "Europe"  
               11.  10.71864 4 "Europe"  
               12.  8.051657 2 "Americas"
               13.  8.713313 4 "Europe"  
               14.   8.82701 2 "Americas"
               15.  9.218328 4 "Europe"  
               16.  6.755691 1 "Africa"  
               17. 10.674967 2 "Americas"
               18.  9.489605 2 "Americas"
               19.   9.25049 3 "Asia"    
               20.   8.57795 2 "Americas"
               21.  9.556302 4 "Europe"  
               22. 10.228559 4 "Europe"  
               23. 10.040398 4 "Europe"  
               24. 11.019683 4 "Europe"  
               25.  8.635647 2 "Americas"
               26.  8.180379 1 "Africa"  
               27. 10.045653 4 "Europe"  
               28.  6.843164 1 "Africa"  
               29. 10.802873 4 "Europe"  
               30. 10.572294 4 "Europe"  
               31.  8.356259 3 "Asia"    
               32. 10.741897 4 "Europe"  
               33.  7.720973 1 "Africa"  
               34.  10.62374 4 "Europe"  
               35.  9.778391 4 "Europe"  
               36.  8.434754 2 "Americas"
               37.  7.149421 2 "Americas"
               38.  10.73861 3 "Asia"    
               39.  9.685143 4 "Europe"  
               40. 10.989775 4 "Europe"  
               41.  7.567398 3 "Asia"    
               42.  8.261413 3 "Asia"    
               43.   7.92217 3 "Asia"    
               44. 8.4304905 3 "Asia"    
               45. 10.695995 3 "Asia"    
               46. 10.368352 4 "Europe"  
               47. 10.594612 3 "Asia"    
               48.  8.362588 3 "Asia"    
               49.  9.118514 3 "Asia"    
               50.  7.535363 1 "Africa"  
               51.   7.07625 3 "Asia"    
               52.    9.7816 4 "Europe"  
               53.  8.243491 3 "Asia"    
               54.  8.937918 1 "Africa"  
               55.  9.915085 4 "Europe"  
               56. 10.581626 3 "Asia"    
               57.  9.250844 3 "Asia"    
               58.  8.842909 3 "Asia"    
               59.   6.76094 1 "Africa"  
               60.  9.039868 2 "Americas"
               61.  8.417762 4 "Europe"  
               62.  8.309419 3 "Asia"    
               63.  8.948408 4 "Europe"  
               64.   8.02607 1 "Africa"  
               65.  7.280465 3 "Asia"    
               66.  8.673763 4 "Europe"  
               67. 10.866605 4 "Europe"  
               68. 10.635796 5 "Oceania"
               69.  7.550159 2 "Americas"
               70.  7.648784 1 "Africa"  
               71. 11.117372 4 "Europe"  
               72.  7.215618 3 "Asia"    
               73.  8.719071 2 "Americas"
               74.   8.10235 3 "Asia"    
               75.   9.66418 4 "Europe"  
               76. 10.007648 4 "Europe"  
               77. 10.355546 2 "Americas"
               78. 10.822283 3 "Asia"    
               79.  9.469435 4 "Europe"  
               80.  9.226507 4 "Europe"  
               81.  6.668612 1 "Africa"  
               82.  9.913669 1 "Africa"  
               83.  8.953083 4 "Europe"  
               84.   11.0142 3 "Asia"    
               85.  9.866176 4 "Europe"  
               86.  10.14606 4 "Europe"  
               87.  8.640626 1 "Africa"  
               88. 10.360865 3 "Asia"    
               89. 10.205717 4 "Europe"  
               90. 10.864775 4 "Europe"  
               91. 11.374828 4 "Europe"  
               92.  6.749733 3 "Asia"    
               93.  6.982371 1 "Africa"  
               94.  8.876233 3 "Asia"    
               95.  9.634754 2 "Americas"
               96.  8.188194 1 "Africa"  
               97.  9.052216 3 "Asia"    
               98.   6.71299 1 "Africa"  
               99.  8.230242 4 "Europe"  
              100.  9.643409 2 "Americas"
              101. end
              
              . label values continent_en continent_en
              
              . label def continent_en 1 "Africa", modify
              
              . label def continent_en 2 "Americas", modify
              
              . label def continent_en 3 "Asia", modify
              
              . label def continent_en 4 "Europe", modify
              
              . label def continent_en 5 "Oceania", modify
              
              .
              . //Regression table:
              . reg log_gdp_n i.continent_en
              
                    Source |       SS           df       MS      Number of obs   =       100
              -------------+----------------------------------   F(4, 95)        =     16.03
                     Model |  64.9435127         4  16.2358782   Prob > F        =    0.0000
                  Residual |  96.2130357        95   1.0127688   R-squared       =    0.4030
              -------------+----------------------------------   Adj R-squared   =    0.3778
                     Total |  161.156548        99  1.62784392   Root MSE        =    1.0064
              
              ------------------------------------------------------------------------------
                 log_gdp_n | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
              -------------+----------------------------------------------------------------
              continent_en |
                 Americas  |   1.196548   .3616849     3.31   0.001      .478513    1.914584
                     Asia  |   1.084591   .3134025     3.46   0.001      .462408    1.706773
                   Europe  |   2.208593   .2999164     7.36   0.000     1.613183    2.804002
                  Oceania  |   3.018086   .7547731     4.00   0.000     1.519672      4.5165
                           |
                     _cons |   7.726237    .251591    30.71   0.000     7.226766    8.225709
              ------------------------------------------------------------------------------
              
              . eststo m1
              
              . esttab m1, label
              
              ------------------------------------
                                            (1)   
                                      log_gdp_n   
              ------------------------------------
              Africa                          0   
                                            (.)   
              
              Americas                    1.197**
                                         (3.31)   
              
              Asia                        1.085***
                                         (3.46)   
              
              Europe                      2.209***
                                         (7.36)   
              
              Oceania                     3.018***
                                         (4.00)   
              
              Constant                    7.726***
                                        (30.71)   
              ------------------------------------
              Observations                  100   
              ------------------------------------
              t statistics in parentheses
              * p<0.05, ** p<0.01, *** p<0.001
              In a situation like this, it is hard to advise. Some generic things one does is make sure your Stata is competely up to date and that you have the latest version of -esttab-. So -update all- and -adoupdate, update-. Then try again. If that does not work, try re-booting your computer. If none of that works, then I think you will need to bump this up to Stata technical support.

              Comment


              • #8
                Clyde, thank you so much. The last update line (adoupdate, update) FINALLY fixed it. Thanks again, this took me forever for such a silly reason and I'm glad this is finally fixed. Have a good one!

                Comment

                Working...
                X