Announcement

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

  • Convert margins/marginsplot

    HI everyone,
    I am studying the influence of different factors on remote working. My main code is as follows:

    logistic job_remote $Controls $Job_controls $Location_dummies $Founder_controls large_firm c.perc_remote_location_30_days##c.perc_remote_loca tion_30_days if job_full_time==1 &only_non_us_office==0 & company_size_combi_categ_incunkn!=7&covid==0, vce (robust) cformat(%9.3f)
    qui margins, at(c.perc_remote_location_30_days =(0 (5) 54.19143))
    marginsplot

    I get the below graph. The green line (added manually) is when the probability (e.g. 30%) is equal to the 30% in the x-axis. I have two questions:

    1) how can I include the green line automatically (y=x)?
    2) I would like to convert the graph into the ratio between the y-axis and x-axis so that it more or less hovers around 1. For example, probability/perc_location_remote is 0.65/0.5 = 1.3 and so on. Is there a way to write this in the code and get a new plot? (I will divide by 10 the x variable to make them comparable).

    Thank you,

    Cristiano
    Click image for larger version

Name:	Picture 1.png
Views:	1
Size:	23.8 KB
ID:	1686708

  • #2
    The -margins- command has an undocumented -saving()- option that will let you save the data that is used by -marginsplot- in a Stata .dta file. Use that. Then you will need to rename the variables in that saved data set so that you can work with them more easily. (When you open that data set, you'll see what I mean.) Then go ahead and compute the ratio, and just make your graph using all of the machinery available in -graph twoway-.

    Comment

    Working...
    X