Announcement

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

  • Coefplot - issue with x-axis

    Dear all,

    I have the following dataset:


    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(elite yeard) float(edu_f occup_f) byte sex_stud float nationality double lambda_1
    0 0 1 1 2 1 1.0369200891134476
    0 0 1 1 1 1 1.2773466215065548
    0 0 1 1 2 1 1.0369200891134476
    0 1 1 2 2 1 .8312793625071068
    0 11 1 2 1 1 .8729843442323654
    0 0 1 2 2 1 .7560635291996983
    0 4 1 1 2 1 .7926716817333047
    0 5 1 1 2 0 .
    0 0 1 1 2 1 1.0369200891134476
    0 7 1 4 2 1 .7755610866588346
    0 10 1 4 2 1 1.0160053143124155
    0 8 1 1 2 1 .8887555852577639
    0 11 1 2 2 1 .6680324038100115
    0 10 1 1 1 1 1.3679320903962948
    0 8 1 4 1 1 1.0107202621427354
    0 5 1 1 2 1 1.1311930843211504
    0 10 1 4 2 1 1.0160643653441264
    1 0 1 1 2 1 1.0349573006908248
    0 0 1 2 2 1 .7570583682780064
    0 6 1 2 1 1 1.0072529596758164
    0 12 1 4 1 1 1.367753191436586
    0 0 1 2 1 1 .9730738007889017
    0 8 1 1 1 1 1.1170189979032021
    0 6 1 1 1 1 1.3144360777565052
    0 6 1 1 2 1 1.0726927331894347
    0 6 1 1 2 0 .
    1 11 1 1 2 1 .9341283974570147
    0 2 1 2 1 1 .996309555751049
    0 9 1 2 1 1 .8333933093421787
    0 9 1 1 1 1 1.1242444246785002
    0 5 1 3 1 1 1.1102436654585008
    0 12 1 1 2 1 1.2316692792947987
    0 3 1 2 2 1 .7570828902424422
    0 4 1 1 2 1 .7938476228873457
    0 2 1 2 2 1 .7785689802872727
    0 11 1 2 2 1 .6680324038100115
    1 0 1 1 1 1 1.2773466215065548
    0 1 1 1 2 0 .
    0 9 1 1 2 1 .8935301157318588
    0 8 1 1 2 1 .8887555852577639
    0 12 1 1 2 1 1.2316692792947987
    0 10 1 1 1 1 1.369042565855686
    0 1 1 1 2 1 1.1202806903795384
    0 10 1 1 1 1 1.369042565855686
    0 0 1 1 2 1 1.0369200891134476
    0 11 1 1 2 0 1.4906795149829437
    0 1 1 2 2 0 1.3693299189081976
    0 2 1 1 1 1 1.3026266331568117
    0 6 1 1 2 1 1.0726927331894347
    0 0 1 3 2 1 .7965379426985457
    0 5 1 1 1 1 .
    0 5 1 1 2 1 1.1311930843211504
    0 6 1 1 2 1 1.071909703671093
    0 3 1 1 2 1 1.0355797837686915
    0 0 1 2 2 1 .7570583682780064
    0 11 1 2 1 1 .8728730582057933
    0 9 1 1 2 1 .8935301157318588
    0 8 1 1 1 1 1.1155525294884263
    0 0 1 1 2 1 1.0369200891134476
    0 12 1 1 1 1 1.485016757386524
    0 5 1 4 2 1 1.0242147955656187
    0 12 1 1 2 1 1.2316692792947987
    0 1 1 4 2 1 1.015164129725451
    0 2 1 1 1 1 1.3037204311079884
    0 9 1 1 1 1 1.124611978392552
    0 12 1 1 2 1 1.2314797359971197
    0 12 1 1 1 1 1.4848160304977387
    1 5 1 3 2 1 .8818733881434547
    0 9 1 1 1 1 1.124611978392552
    0 8 1 1 1 1 1.1170189979032021
    0 3 1 1 1 1 .
    0 6 1 1 1 1 1.3148877088987125
    0 0 1 1 1 1 1.2773466215065548
    0 10 1 1 2 1 1.1225602859771444
    0 7 1 1 2 1 .8716736465959619
    0 6 1 1 2 0 .
    0 10 1 1 1 0 .
    1 11 1 1 2 1 .9341283974570147
    0 3 1 1 2 1 1.0355797837686915
    1 5 1 1 2 0 .
    0 6 1 1 2 1 1.0714881580017552
    0 9 1 1 2 1 .8935301157318588
    0 12 1 1 1 1 1.485016757386524
    0 11 1 1 1 1 1.1664940215408328
    0 6 1 4 2 1 .9680181749086781
    0 2 1 1 1 1 1.3037204311079884
    0 4 1 1 1 1 1.0115907523658474
    0 8 1 1 1 0 1.7014600969048974
    0 8 1 4 1 1 1.0107202621427354
    0 2 1 1 1 1 1.3023693110016734
    0 1 1 2 2 1 .8312793625071068
    0 3 1 1 1 1 1.2764815825186624
    0 5 1 1 2 1 1.1311930843211504
    0 12 1 3 2 1 .972769328431093
    0 10 1 1 2 1 1.1215196595130927
    0 9 1 1 1 1 1.122223631833564
    0 11 1 2 1 1 .8729843442323654
    1 7 1 1 2 1 .8734539182656972
    0 2 1 1 2 0 .
    0 6 1 1 2 1 1.0717892559347058
    end
    label values elite elite
    label def elite 0 "Non-elite", modify
    label def elite 1 "Elite", modify
    label values yeard yeard
    label def yeard 0 "2004", modify
    label def yeard 1 "2005", modify
    label def yeard 2 "2006", modify
    label def yeard 3 "2007", modify
    label def yeard 4 "2008", modify
    label def yeard 5 "2009", modify
    label def yeard 6 "2010", modify
    label def yeard 7 "2011", modify
    label def yeard 8 "2012", modify
    label def yeard 9 "2013", modify
    label def yeard 10 "2014", modify
    label def yeard 11 "2015", modify
    label def yeard 12 "2016", modify
    label values edu_f edu_f
    label def edu_f 1 "Primary education or below", modify
    label values occup_f occup_f
    label def occup_f 1 "Blue collar", modify
    label def occup_f 2 "Low skilled white collar", modify
    label def occup_f 3 "High skilled white collar", modify
    label def occup_f 4 "Unemployed", modify
    label values sex_stud sex_stud
    label def sex_stud 1 "Male", modify
    label def sex_stud 2 "Female", modify
    label values nationality nationality
    label def nationality 0 "Non-Greek", modify
    label def nationality 1 "Greek", modify
    [/CODE]


    I am using the following code to plot the coefficients of two models:
    eststo: reg elite i.yeard i.edu_f#ibn.yeard i.occup_f i.sex_stud i.nationality, baselevels
    eststo: reg elite i.yeard i.edu_f#ibn.yeard i.occup_f i.sex_stud i.nationality lambda_1, baselevels

    coefplot est1 est2, nooffset vertical yline(0) keep(2.edu_f#*.yeard 3.edu_f#*.yeard 4.edu_f#*.yeard) ///
    groups(2.edu_f#?.yeard="{bf:Secondary education}" ///
    3.edu_f#?.yeard="{bf:Vocational education}" ///
    4.edu_f#?.yeard="{bf:Tertiary education}") ///
    graphregion(fcolor(white)) ////
    byopts(xrescale) ///
    legend(order(2 "Linear Probability Model" 4 "Linear Probability Model with Heckman correction") size(small)) ///
    coeflabels(2.edu_f#0.yeard="2004" 2.edu_f#1.yeard="2005" 2.edu_f#2.yeard="2006" 2.edu_f#3.yeard="2007" 2.edu_f#4.yeard="2008" 2.edu_f#5.yeard="2009" 2.edu_f#6.yeard="2010" 2.edu_f#7.yeard="2011" 2.edu_f#8.yeard="2012" 2.edu_f#9.yeard="2013" 2.edu_f#10.yeard="2014" 2.edu_f#11.yeard="2015" 2.edu_f#12.yeard="2016" 3.edu_f#0.yeard="2004" 3.edu_f#1.yeard="2005" 3.edu_f#2.yeard="2006" 3.edu_f#3.yeard="2007" 3.edu_f#4.yeard="2008" 3.edu_f#5.yeard="2009" 3.edu_f#6.yeard="2010" 3.edu_f#7.yeard="2011" 3.edu_f#8.yeard="2012" 3.edu_f#9.yeard="2013" 3.edu_f#10.yeard="2014" 3.edu_f#11.yeard="2015" 3.edu_f#12.yeard="2016" 4.edu_f#0.yeard="2004" 4.edu_f#1.yeard="2005" 4.edu_f#2.yeard="2006" 4.edu_f#3.yeard="2007" 4.edu_f#4.yeard="2008" 4.edu_f#5.yeard="2009" 4.edu_f#6.yeard="2010" 4.edu_f#7.yeard="2011" 4.edu_f#8.yeard="2012" 4.edu_f#9.yeard="2013" 4.edu_f#10.yeard="2014" 4.edu_f#11.yeard="2015" 4.edu_f#12.yeard="2016", notick labgap(2) angle(vertical))
    graph export "$coefplots/edu_father_Heck_2.png", replace

    The code produces the following graph:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	337.6 KB
ID:	1693516


    However, I do not understand why there is a bigger gap between 2013 and 2014 across all educational categories.

    Any help would be greatly appreciated!

    Best,
    Konstantina

  • #2
    Should be due to the fact that yeard is coded 0 to 15, and you jump from 1 digit to 2 digits between 9=2013 and 10=2014. Indicators require integer values, so just use the raw year values which are all 4 digits.

    Code:
    lab drop yeard
    replace yeard= yeard+2004
    eststo: reg elite i.yeard i.edu_f#ibn.yeard i.occup_f i.sex_stud i.nationality, baselevels
    eststo: reg elite i.yeard i.edu_f#ibn.yeard i.occup_f i.sex_stud i.nationality lambda_1, baselevels

    Comment


    • #3
      Dear Andrew,

      Thank you very much for your prompt reply. I fixed the issue in the graph now.

      Best,
      Konstantina

      Comment

      Working...
      X