Announcement

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

  • combomarginsplot with mimrgns

    Hi everyone,

    Does anyone know how to use combomarginsplot with margins derived from the mimrgns command? For reference, I'm looking at the interaction between time and race in students' self-evaluations of their future grades. I'd like to combine plots that show what the addition of new controls does to the estimate of interest. I get as far as the "saving" option before Stata tells me my code is wrong. Any insight?

    Code:
    global controls age i.sex i.educ
    mi estimate, or: svy: logistic pass i.race##i.year $controls
    mimrgns i.race#i.year, predict(pr) cmdmargins post saving (f1, replace)
    marginsplot, by(race) 
    
    mi estimate, or: svy: logistic pass i.race##i.year $controls parent_educ
    mimrgns i.race#i.year, predict(pr) cmdmargins post saving (f2, replace)
    marginsplot, by(race) 
    
    mi estimate, or: svy: logistic pass i.race##i.year $controls parent_educ zipcode
    mimrgns i.race#i.year, predict(pr) cmdmargins post saving (f3, replace)
    marginsplot, by(race)
    
    combomarginsplot file1 file2 file3
    Thanks for considering.

  • #2
    mimrgns and combomarginsplot are community-contributed software, both (probably) from SSC.

    Concerning the presented code, I would like to point to a couple of potential pitfalls without going into details:
    • Be careful with globals; they might lead to hard to find bugs. Often, locals are safer.
    • With the data svy-set, you might want to think about vce(unconditional) for the margins/mimrgns call.
    • parent_educ and zipcode enter the models in a linear way, that is, as continuous variables; that might or might not be appropriate.
    • Nesting non-linear models in the way you do (adding variables one after another) might not give you the results you are looking for. This has been discussed extensively in the past decade (e.g., Mood, 2010; Karlson et. al 2012).
    Concerning the technical problem, mimrgns does not support the (undocumented) saving() option. I have sketched a possible workaround in #2 and #4 elsewhere. Also, the approach relying on the _marg_save routine that I have shown elsewehere might be a good starting point (lose the post option for mimrgns for that).

    In some situations, the outlined workarounds should be rather straightforward (depending on your Stata programming knowledge) to apply. Unfortunately, the approaches might not generalize as easily to all the estimations that margins is capable of doing.

    Best
    Daniel


    Karlson, K. B., Holm, A., & Breen, R. 2012. Comparing Regression Coefficients Between Same-sample Nested Models Using Logit and Probit: A New Method. Sociological Methodology, 42(1), 286--313.
    Mood, C. 2010. Logistic Regression: Why We Cannot Do What We Think We Can Do, and What We Can Do about It. European Sociological Review, 26(1), 67--82.
    Last edited by daniel klein; 27 Jan 2020, 03:15.

    Comment


    • #3
      Thank you so much! Your response was incredibly helpful, Daniel.

      Comment

      Working...
      X