Announcement

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

  • Margins for multiple terms

    Suppose I have:

    Code:
    logistic y a b
    where a and b are continuous.

    I can run

    Code:
    margins, at(a==10 20 30)) atmeans
    and

    Code:
    margins, at(b==(50 60 70)) atmeans
    to obtain adjusted predictions at selected values of a at the mean of b and selected values of b at the mean of a (I think this is correct).

    Is there some way to do this simultaneously? I'm saving post-estimation results from margins and I think I'll have to run my regression again unless perhaps I can use preserve and restore. Any advice appreciated.

  • #2
    I don't see any way to combine those into a single -margins- command.

    But you definitely do not have to re-run the regression to use -margins- a second time. You can run as many different -margins- commands as you want after a single regression. -margins- for a given estimation command remains available until you run a new estimation command.

    Comment


    • #3
      The examples I ever saw sofar with - margins, at() - used "=" instead of "==". To my surprise, I tested - margins - a few minutes ago with the double equal sign and it worked the same way as the equal sign. That said, in order to avoid potential problems (albeit I cannot envisage at this very moment), I fear we'd better follow the Stata manual (http://www.stata.com/manuals13/rmargins.pdf), the Stata Journal (http://www.stata-journal.com/sjpdf.h...iclenum=st0260) and a series of papers and hand outs, and stick to the first option.
      Best regards,

      Marcos

      Comment


      • #4
        Is this what you have in mind?

        Code:
        webuse nhanes2f, clear
        logit diabetes height weight
        margins, at(height = (150 175 200) weight) at(weight = (30 100 175) height)
        margins, at(height = (150 175 200) _continuous) at(weight = (30 100 175) _continuous)
        The last variation might be handy if you have a bunch of other vars. See help margins##atspec.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          This is the solution that I need:

          Code:
          margins, at(height = (150 175 200) weight) at(weight = (30 100 175) height)
          That gives me margins of height at the mean of weight and margins of weight at the mean of height. Perfect. Thanks for your help.

          Comment

          Working...
          X