Announcement

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

  • Referring to an element of a coefficient matrix after margins cmd

    Hello everyone,

    I have the following problem: I estimate a logit regression with a number of covariates. I then obtain fitted values at several values of a covariate of interest using the "margins" command. For example:

    Code:
    webuse margex, clear
    logit outcome i.group distance
    margins, at(distance=(100 200)) post
    Now I would like to refer to the estimated margins to use them in further calculations (so something like _b[distance=100], _b[distance=200]). What is the syntax to do this?

    Thank you!

  • #2
    Does this do what you need?

    Code:
    ereturn list
    matrix list  e(b)
    matrix b=e(b)
    scalar b100=b[1,1]
    scalar b200=b[1,2]
    display b100 b200
    Devra
    Devra Golbe
    Professor Emerita, Dept. of Economics
    Hunter College, CUNY

    Comment


    • #3
      Yes, this works, but I was wondering if there was any shorthand syntax to do that, as with regression coefficients.

      Comment


      • #4
        The first two lines of my code and the last are purely illustrative. I would also be curious to know if there's a way to condense the middle three!
        Devra Golbe
        Professor Emerita, Dept. of Economics
        Hunter College, CUNY

        Comment


        • #5
          Since you post margins results you can

          Code:
          display _b[1._at]
          Also see the el() function.

          Code:
          display el(e(b), 1, 1)
          Whether any of these methods is more convenient, I do not know.

          Best
          Daniel

          Comment


          • #6
            Originally posted by daniel klein View Post
            Since you post margins results you can

            Code:
            display _b[1._at]
            Also see the el() function.

            Code:
            display el(e(b), 1, 1)
            Whether any of these methods is more convenient, I do not know.

            Best
            Daniel
            The first one is exactly what I had in mind. Thanks!

            Comment

            Working...
            X