Announcement

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

  • Combomarginsplot Logit Model

    I'm having difficulty using the combomarginsplot and I am not sure if it is because I am using a binary logit model. Below is the sample code followed by the individual outputs and the combomarginsplot.

    Variables descriptions:
    stress: 0=no high stress 1=high stress
    gender: 0=male 1=female
    curmar: 0=not married 1=married
    cohab: 0=not cohabiting 2 = cohabiting


    Commands:

    logit stress gender curmar cohab

    margins, at(gender==0 curmar==0 cohab==0) at(gender==0 curmar==0 cohab==1) ///
    at(gender==0 curmar==1 cohab==0) at(gender==0 curmar==1 cohab==1) atmeans saving(f1, replace)
    marginsplot

    margins, at(gender==1 curmar==0 cohab==0) at(gender==1 curmar==0 cohab==1) ///
    at(gender==1 curmar==1 cohab==0) at(gender==1 curmar==1 cohab==1) atmeans saving(f2, replace)
    marginsplot

    combomarginsplot f1 f2, noci


    Click image for larger version

Name:	bad output.png
Views:	1
Size:	20.2 KB
ID:	1353664


    On the comboplot, it is separated by file. File 1 is on the lest and file 2 is on the right.

    Thank you

  • #2
    This is very old, but I just noticed it now. You don't actually ask a question, but I suspect your question is, "how can I get the plots overlaid in a different way?"

    The answer to that is that you can get *almost* what you want with the -plotdimension()- option of marginsplot:

    Code:
    combomarginsplot f1 f2, noci plotdim(_filenumber)
    The problem is that combomarginsplot has no way to know that the first at() in each call to margins correspond to each other, that the second two correspond to each other, and so on.

    Note also that I think you can get hte same underlying margins results in one go, using Stata's factor notation, and then use -marginsplot- to get close to what I think you want:

    Code:
    logit stress i.gender i.curmar i.cohab
    margins gender#curmar#cohab
    
    marginsplot , by(cohab)

    Comment

    Working...
    X