Announcement

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

  • Margins for semiparametric regression

    Hello,

    I'm trying to estimate a semi-parametric regression model with (1) a continuous and a categorical variable interacting in the basis function and (2) a continuous parametric regressor. I then want to plot predicted probabilities using margins. However, when specifying covariate values at which to estimate predicted probabilities, margins does not recognize the continuous regressor specified in the asis() option as a covariate:
    Code:
    sysuse auto, clear
    npregress series price mpg i.foreign, asis(weight)
    margins, over(foreign) at(mpg = (15 (5) 40) weight = 3000)
    The problem does not occur with categorical variables specified in the asis() option:
    Code:
    gen group = mod(_n, 2) == 0
    npregress series price mpg i.foreign, asis(weight i.group)
    margins, over(foreign) at(mpg = (15 (5) 40) group = 1)
    Most curiously, the problem also disappears if the categorical variable is removed from the basis function:

    Code:
    npregress series price mpg, asis(weight i.foreign)
    margins, over(foreign) at(mpg = (15 (5) 40) weight = 3000 foreign = 1)
    How can I specify the values of a parametric (i.e. asis) continuous variable when calculating margins for an npregress model?
    Last edited by Alex Roehrkasse; 03 Jan 2020, 10:34.

  • #2
    the Stata blog has at least two blogs re: npregress and each has some material about the use of margins - the second is almost entirely about this; so, google "Stata blog" and when you are there enter "npregress" in the search box to find these

    Comment


    • #3
      Hi Alex,
      I think what you found is a bug within "npregress series". You should write to Stata technical support, so they can address the problem.
      Best Regards

      Comment


      • #4
        Rich, the documentation on margins with npregress is indeed very good, but I've perused it carefully and I don't believe it addresses this issue. Fernando, thanks for your confirmation of my intuition: I've been in touch with tech support and I will update this post based on what I hear.

        Comment


        • #5
          Stata confirmed this was a bug, and it has been resolved in subsequent updates.

          Comment

          Working...
          X