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

  • Multiple "lincoms" after "margins" with "at"?

    Goal: I want to subtract the results of "margins" from a constant.

    My approach: Use margins with "at" and subsequently use "lincom" to do the subtraction. That's a bit cumbersome, because I have to address the results of "margins" manually (or in a loop).

    Question: What's the easiest way to calculate multiple "lincom"s after the "margins" command with "at"?

    Here's a toy example:

    sysuse auto, clear
    regress price mpg headroom trunk weight
    margins, at(mpg = 20 headroom = 3 trunk = 14 weight = (1760(10)1800)) noatlegend post
    lincom 3000 - 1._at
    lincom 3000 - 2._at
    Here, I simply want to subtract the resulting margins from a constant of 3000. If I wanted to do this for all calculated margins, I'd have to address all "_at" coefficients manually (or in a loop). Is there an easier way to do this?

    Thanks for your guidance.
    Last edited by Denis Infanger; 13 Nov 2019, 04:19. Reason: Added tags.