Announcement

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

  • Coefplot graph error despite running the regression

    I'm supposed to get a coefplot graph using the following data and code but unfortunately I'm coming across this error. Why lths variable is not being allowed , I'm simply not getting it.

    Code:
    option lths not allowed
    r(198);
    The code is like the following

    Code:
    eststo clear
    reghdfe ln_incwage black  ///
    hks mks lks ///
    age ismarried /// 
    somecollege hsdegree  /// 
    lths  [aw=asecwt] , absorb(i.county) vce(cluster county) 
    eststo e1 
    
    coefplot (e1 , mcolor(red%50) msymbol(O) msize(large) ciopts(recast(rcap)) color(red%50)) keep(black)) ///
    (e1 , mcolor(green%50) msymbol(S) msize(large) keep(hks mks lks) ciopts(recast(rcap)) color(green%50)))  ///
    (e1 , mcolor(purple%50) msymbol(T) msize(large) keep(age ismarried)  ciopts(recast(rcap)) color(purple%50))) ///
    (auto_dube , mcolor(blue%50) msymbol(D) msize(large) keep(lths)  ciopts(recast(rcap)) color(blue%50))) , ///
    scheme(plotplain) xtitle("Coefplot",size(large)) /// 
    xline(0, lcolor(gs7) lpat(solid)) legend(off) grid(none) ///
    yline(-1 -2 -3, lcolor(gs7%40) lpat(dot)) ///
    groups(black ="{bf:Local}") ///
    hks mks lks ="{bf:Spectrum}") ///
    age ismarried  = "{bf:Industry}") /// 
    lths = "{bf:Rec}") ///
    graph export "coefplot.png"
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float ln_incwage byte black float(hks mks lks) byte(age ismarried somecollege hsdegree lths) double(asecwt county)
    10.414393 0 1 0 0 54 0 0 0 0 1434.86 36055
     10.46846 0 0 1 0 38 1 0 1 0  606.54     0
     9.538924 0 0 1 0 37 0 0 0 1 1000.35     0
    11.436045 0 1 0 0 55 1 0 0 0  463.44     0
            . 0 0 0 0 46 1 0 0 1 1215.63  6037
    10.008928 0 0 1 0 30 1 1 0 0 2010.14     0
    10.037678 0 0 1 0 44 1 0 1 0  459.67     0
     12.08503 0 0 0 1 37 1 0 0 0 1296.95 34039
     5.914584 0 0 0 1 18 0 0 0 1 1544.17 42091
    10.232072 0 0 0 1 18 1 1 0 0 1599.78  4013
     9.775313 1 0 0 1 26 1 0 1 0 1329.36 42011
    10.033458 0 0 0 1 35 1 1 0 0 1222.95     0
            . 0 0 0 0 63 0 0 1 0   910.7     0
     9.469932 1 0 1 0 42 0 0 1 0 1269.54     0
     9.826607 0 0 0 1 36 1 0 0 1  1672.3     0
            . 0 0 0 0 18 0 0 0 1 1224.82 34023
            . 0 0 0 0 60 0 0 0 1  547.61     0
    8.9103155 0 0 0 1 62 1 0 1 0 1492.59     0
    10.519753 0 0 0 1 47 0 0 0 1 1284.65  6037
     11.30821 0 1 0 0 39 1 1 0 0 1230.16 34029
            . 0 0 0 0 49 1 0 1 0 1377.73 12011
     8.555781 0 0 1 0 46 1 0 0 0 1059.27     0
    10.519753 0 0 0 1 31 0 1 0 0 1243.65 12025
    10.163078 0 0 0 1 47 1 0 1 0  125.48     0
            . 0 0 0 0 36 1 0 1 0   445.1     0
    11.455847 0 1 0 0 36 1 0 0 0  606.54  8059
    10.491868 0 1 0 0 38 0 0 0 0 1482.28 36047
            . 0 0 0 0 30 0 1 0 0   557.1     0
     9.826607 0 0 1 0 42 1 0 1 0   928.9     0
            . 0 0 0 0 18 0 1 0 0 1261.18 12011
    10.659515 0 0 1 0 38 1 0 1 0  744.99     0
    9.3958235 0 0 1 0 27 1 1 0 0  369.12     0
     10.04975 0 0 0 1 38 1 0 1 0 1397.47     0
    10.008928 0 0 1 0 40 1 0 0 1 1841.38     0
    11.772516 0 0 0 1 39 1 1 0 0 1207.02 12025
            . 0 0 0 0 27 1 1 0 0  994.94     0
    10.568543 0 0 1 0 35 1 1 0 0  801.43  8031
    10.592074 0 1 0 0 28 1 0 0 0 1149.52     0
            . 0 0 0 0 25 0 1 0 0 2619.46  6085
    10.568543 0 0 1 0 44 1 0 1 0  1546.2 12011
            . 0 0 0 0 48 1 0 0 0 1737.04 34003
     9.826607 0 0 1 0 26 1 0 0 0 1421.61     0
            . 0 0 0 1 53 1 1 0 0  446.02     0
     8.776784 0 1 0 0 18 0 0 1 0 1067.93     0
            . 0 1 0 0 44 1 0 0 0 1204.65  6037
            . 0 0 0 0 50 1 0 1 0  724.72     0
    10.386222 0 0 1 0 23 0 0 1 0  352.97     0
            . 0 0 0 0 18 0 0 0 1 1059.78     0
     9.603463 0 0 0 1 18 0 0 0 1 1421.59     0
    11.035567 0 0 1 0 31 0 0 0 1 2132.08  6079
     9.415627 0 0 0 1 40 1 0 1 0 1191.55 27137
     9.469932 0 0 0 1 50 1 0 1 0  960.59     0
     6.830874 1 0 1 0 22 0 0 1 0  1716.9     0
    end

  • #2
    (deleted; accidental multiple posting)
    Last edited by Hemanshu Kumar; 01 Oct 2022, 00:45.

    Comment


    • #3
      Tariq Abdullah there seems to multiple places in your code where you have problems with matched parentheses. This is the version I was able to make work on my machine. I had to comment out one portion, since the estimation results auto_dube were not included in the code you provided.

      Code:
      eststo clear
      
      #delimit ;
      reghdfe ln_incwage black
              hks mks lks
              age ismarried 
              somecollege hsdegree 
              lths  [aw=asecwt] 
                  , absorb(i.county) vce(cluster county) 
              ;
      
      eststo e1 ;
      
      coefplot 
          (e1 , mcolor(red%50) msymbol(O) msize(large) ciopts(recast(rcap)) color(red%50) keep(black))
          (e1 , mcolor(green%50) msymbol(S) msize(large) keep(hks mks lks) ciopts(recast(rcap)) color(green%50))
          (e1 , mcolor(purple%50) msymbol(T) msize(large) keep(age ismarried)  ciopts(recast(rcap)) color(purple%50))
          /*(auto_dube , mcolor(blue%50) msymbol(D) msize(large) keep(lths)  ciopts(recast(rcap)) color(blue%50)) */,
              scheme(plotplain) 
              xtitle("Coefplot", size(large) ) 
              xline(0, lcolor(gs7) lpat(solid) ) 
              legend(off) 
              grid(none)
              yline(-1 -2 -3, lcolor(gs7%40) lpat(dot) )
              groups(black = "{bf:Local}" hks mks lks = "{bf:Spectrum}" age ismarried = "{bf:Industry}" lths = "{bf:Rec}" )
          ;
      #delimit cr

      Comment


      • #4
        Thanks a ton ton for your kind and thoughtful suggestion. With your help finally I got around this issue. Spent fair share of time fixing it but was at a loss. Thanks again so much for helping me out!

        Comment

        Working...
        X