Announcement

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

  • Evaluate Average Marginal Effects at Arbitrary Value of Exposure

    Dear Statalists,

    I have count data on the occurence of an event, with an exposure time (in days) that differs largely between individuals.

    After running e.g.:


    nbreg y x1 x2 x3, exposure(t)
    margins, dydx(*)

    I obtain the respective average marginal effects. As far as I understand, these effects are evaluated at exp(mean(ln(t))). Is that correct? What I would like to obtain, however, are the average marginal effects evaluated at a value of the exposure time other than the default. In particular, I would like to obtain average marginal effects at an exposure of say 30 or 360 days of time. I want to so in order to obtain average marginal effects that I can easily interpret as e.g.: If I increase x1 by 1 unit, then the number of y per 30 days of exposure increases on average by AME units.

    Thank you very much in advance for your advice.
    Last edited by Justus Weinberg; 02 May 2018, 14:06.

  • #2
    I obtain the respective average marginal effects. As far as I understand, these effects are evaluated at exp(mean(ln(t))). Is that correct?
    No, that's not correct. Marginal effects are actually calculated for every observation in the data set, with all of the variables as they are originally observed. Then the average of those observation-level marginal effects is computed. That, I believe, is why they are called average marginal effects.

    You can calculate marginal effects at any values of any of the variables you want. That is what the -at()- option of the -margins- command is for. Read about it in the PDF documentation for -margins-.

    Comment


    • #3
      Thank you very much for your prompt reply.

      The -at()- option of the -margins- command requires me to include the exposure varible t as a an additional covariate, in addition to the specification in the option ,exposure(t).

      Doing so thus potentially affects the AME’s of the covariates that I am genuinely interested in.

      If there a way to circumvent this issue?

      Thank you very much!

      Comment


      • #4
        Hmm, that is indeed a problem. I don't know a good workaround for that.

        Comment


        • #5
          I wonder if you can do something like this:

          Code:
          webuse dollhill3, clear
          gen ln_pyears = ln(pyears)
          constraint define 1 _b[ln_pyears] = 1
          nbreg deaths i.smokes i.agecat ln_pyears, constraint(1) nolog
          margins, dydx(smokes) at(ln_pyears == `=ln(20000)')

          Comment


          • #6
            Brilliant! I forgot that -nbreg- allows constraints.

            Comment


            • #7
              Excellent, this worked out just fine! Thank you!

              Comment

              Working...
              X