Announcement

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

  • Making labels appear in the X axis (marginsplot)

    Dear members of the list,

    For exploratory purposes, I intend to run an OLS regression for a pool of countries drawn from PIAAC. My ultimate goal is to graphically explore cross-national differences in the effect of father's education on attainment of a master level diploma.

    My dependent variable ('master') is dichotomous but I apply a linear probability model to my data; that is, for now, I treat it as continuous. My key independent variable (father's educational attainment, 'edufath'), it is split up into three categories: (a) ISCED 1/2/3(short) (b) ISCED 3/4 (c) ISCED 5/6

    Following the great Chuck Huber's video on 'Profile plots and interaction plots in Stata: Interactions of categorical variables', I generate the interaction plots by running the following commands:

    HTML Code:
    reg master female i.AGEG10LFS i.imgen2 edufath##cntryid
    margins edufath#cntryid
    marginsplot, xdimension(cntryid) recast(line) plotopts(connect(none)) xlabel(, labels)
    AGEG10LFS and imgen are just control variables. The important variables for me are father's education (edufath) and the variable identifying countries (cntryid).

    As a result of the last line in the codes above, I get a graph that is comes next:

    Click image for larger version

Name:	edufather_cntryid.png
Views:	1
Size:	175.6 KB
ID:	1505945

    Here comes my question. The graph is satisfactory, but I am not able to make the country labels appear in the X axis (Austria, Belgium... ) so as to easily identify the marginal effect of father's education for each country, which was my initial intention. There only appear the numerical codes of my country variable. I have tried with all the possible options in the command marginsplot, to no avail.

    I have also imagined that it was a matter of changing the format of cntryid, but I suspect that this is wrong. In case it helps, I provide the information on 'cntryid' that is provided by Stata about this variable

    Code:
    . codebook cntryid
    
    ------------------------------------------------------------------------------------------------------------------------
    cntryid                                                                                   Country ID (ISO 3166, numeric)
    ------------------------------------------------------------------------------------------------------------------------
    
                      type:  numeric (double)
                     label:  CNTRYID
    
                     range:  [40,840]                     units:  1
             unique values:  31                       missing .:  0/200,588
    
                  examples:  152   Chile
                             250   France
                             440   Lithuania
                             703   Slovak Republic
    
    . des cntryid
    
                  storage   display    value
    variable name   type    format     label      variable label
    ------------------------------------------------------------------------------------------------------------------------
    cntryid         double  %23.0g     CNTRYID    Country ID (ISO 3166, numeric)
    Any advice in this respect would be more than welcome.

    At any rate, thanks for your attention

    Best wishes

    Luis Ortiz

  • Luis Ortiz
    replied
    Many thanks for your help, Scott

    I did not know this command (mplotoffset), and it's definitely very valuable to have the lines in the graph not overlapped for each category. This is already an improvement...ยก

    Many thanks again

    Luis

    Leave a comment:


  • Scott Merryman
    replied
    I cannot replicate the problem the value labels, but I would suggest you take a look at NickWinter's -mplotoffset- (see -ssc desc mplotoffset-). Compare:

    Code:
    sysuse census,clear
    qui {
    sum pop
    gen lowpop = pop< r(mean)
    reg med low#region
    margins low#region
    }
    marginsplot, xdim(region)  recast(scatter) name(gr1,replace) legend(pos(6) row(1))
    mplotoffset, offset(.1) xdim(region)  recast(scatter) name(gr2,replace)  legend(pos(6) row(1))
    graph combine gr1 gr2
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	80.5 KB
ID:	1505964

    Leave a comment:

Working...
X