Announcement

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

  • Inconsistent results between xtpoisson and margins

    Hi Statalisters,

    I am using -xtpoisson,fe- count data model to analyze my panel data. The dependent variable is the number of patents (npatent) and the independent variables include customer concentration (CC) and customer dependence (CD). The moderator is supplier-customer linked years (Linkage).

    The full model should be: npatent=β0 + β1*CC + β2*CD + β3*Linkage + β4*(CC*Linkage) + β5*(CD*Linkage)+ controls + industry fixed effects + year fixed effects

    When I run -xtpoisson,fe- regression with the full model, I see coefficients for CC and CD are both negative, -1.19 and -0.59, respectively.

    Code:
    xtpoisson npatent CC CDsum Linkage c.CC#c.Linkage c.CDsum#c.Linkage $controls i.SIC2N i.fyear, fe

    Click image for larger version

Name:	1.jpg
Views:	1
Size:	244.8 KB
ID:	1599324



    However, when I run the -margins- for both CC and CD, I see coefficients turn to positive. These inconsistent coefficients make me confused about whether CC and CD are positive or negative signals of the dependent variables.

    Code:
    margins, at(CC=(0(0.1)0.6)) vsquish

    Click image for larger version

Name:	2.jpg
Views:	1
Size:	157.5 KB
ID:	1599325




    I am appreciated for any explanation and instruction about my data project.

    BTW, I have read previous threads that argue about the function of -margins- in -xtpoisson,fe- settings. I just want to use -marginsplot- to better illustrate my interaction terms but find these inconsistent results by accident.

    Thanks in advance.

    Last edited by Chris Jiao; 23 Mar 2021, 04:23.

  • #2
    In case anyone want to browse the data, I list here.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float conmid double fyear str58 conm byte SIC2N str58 CustomerName float npatent double ncites float(CC CDsum SupSize SupSG SupROA SupRD SupDR IndHHI IndSize Linkage)
    1 1999 "AAON INC"           35 "WALMART INC"           0 0  .05289982  5.320606e-08  4.088595  1.199043  .16531983        0  .12049918 1014.7343  10.28236         1
    1 2000 "AAON INC"           35 "WALMART INC"           0 0  .03610103  3.965827e-08  4.354373  1.210466   .1665495        0  .17851284   2512.07 11.374654         2
    1 2001 "AAON INC"           35 "WALMART INC"           2 2  .03169849  4.200259e-07  4.347629 1.0146469  .18554296        0  .02449702 1675.0355 11.489744 2.1200142
    1 2002 "AAON INC"           35 "TARGET CORP"           0 0  .03170055  3.530984e-07 4.5295086   .986156   .1593122        0  .03888217  871.9003  10.97228  3.120019
    1 2003 "AAON INC"           35 "WALMART INC"           4 0  .02559957 1.4877586e-08  4.635554  .9598259  .13936426        0          0  937.9097  10.89374         5
    1 2004 "AAON INC"           35 "WALMART INC"           2 1  .01959939  1.267091e-08 4.6655784 1.1640767  .07147405 .0101875 .002613398  987.2667 10.901987         6
    2 1994 "ABC-NACO INC"       34 "UNION PACIFIC CORP"    0 0 .029600967 .000023776935  4.572378 1.2589524  .05426316        0          0 1750.3617   7.24552         1
    2 1995 "ABC-NACO INC"       34 "ATCHISON CASTING CORP" 0 0  .03249965     .10847612  5.064264  1.299467   .0614063        0          0 1895.2457  7.328974 1.4000033
    2 1996 "ABC-NACO INC"       34 "UNION PACIFIC CORP"    0 0  .02650028    .036737252  5.142272  .9894544  .03954052        0          0 2588.8074  7.303065  2.478258
    2 1997 "ABC-NACO INC"       34 "UNION PACIFIC CORP"    0 0  .04410016  .00003830055  5.445042 1.0769787 .014271033        0          0 2302.4573  6.827462         4
    2 1998 "ABC-NACO INC"       34 "UNION PACIFIC CORP"    0 0  .03240018  .00003976322  5.691511  1.230904 .021266943        0          0  3338.779   6.55522         5
    3 1982 "ABS INDUSTRIES INC" 34 "EMERSON ELECTRIC CO"   0 0 .014398667 3.9453935e-06 3.2842515  .8164237  -.2466036        0          0  2986.094  5.863887         1
    3 1985 "ABS INDUSTRIES INC" 34 "CHRYSLER CORP"         0 0  .04609681     .08453968  2.446599  .9756411   .2854299        0          0 2402.2542  6.317769         1
    3 1986 "ABS INDUSTRIES INC" 34 "CHRYSLER CORP"         0 0  .03240224 3.3920834e-08   2.71866  .9394841  .18368644        0          0  2464.904  6.428724         2
    3 1987 "ABS INDUSTRIES INC" 34 "CHRYSLER CORP"         0 0      .0256  2.077696e-08 2.9093025  1.014741  .06688192        0          0 1807.2454  7.073068         3
    3 1988 "ABS INDUSTRIES INC" 34 "FORD MOTOR CO"         0 0  .19600394  4.622248e-08  2.845897 1.4536574  .09280385        0          0 1565.9762   7.17337  1.750047
    3 1989 "ABS INDUSTRIES INC" 34 "CHRYSLER CORP"         0 0    .231411   9.65143e-08   3.32536 1.2803406  .07325898        0          0 1756.6558  7.047041  2.822606
    3 1990 "ABS INDUSTRIES INC" 34 "CHRYSLER CORP"         0 0  .16129415  8.351466e-08  3.506608   1.11367  .06602752        0          0  3575.552  6.604062  3.764734
    3 1991 "ABS INDUSTRIES INC" 34 "CHRYSLER CORP"         0 0  .14899461  5.704386e-08 3.5989275  .8938848 .030484546        0          0 4847.3477  7.818247 4.6874495
    3 1992 "ABS INDUSTRIES INC" 34 "FORD MOTOR CO"         0 0  .05760299  2.046049e-08  3.760642 1.4192203  .05688965        0          0 2251.7498  6.116969         5
    end

    Comment


    • #3
      You can, and should, also paste results in the code delimiter blocks rather than attaching screenshots. When you paste results in the code blocks, the table formats correctly. Screenshots aren't consistently readable on all devices, as advised by the FAQ.

      That said, let's go back to what Poisson regression actually does. You stated that the model is

      npatent=β0 + β1*CC + β2*CD + β3*Linkage + β4*(CC*Linkage) + β5*(CD*Linkage)+ controls + industry fixed effects + year fixed effects
      That's true for a linear model. For a Poisson regression, though, remember that the Poisson distribution is governed by a rate parameter, lambda. The higher lambda is, the higher the rate of patent production. Your model really is more like lambda = exp(insert your model here). You can either exponentiate the raw coefficients you see to get incidence rate ratios, or you can use the irr option to have Stata do that for you.

      You're right that your model implies that as CC increases, the predicted number of patents should go down. e^-1.187776 = about 0.30. Now, the thing you need to realize about margins is that it reports results in the raw scale, in predicted number of patents. It's not reporting results on the same scale as the Poisson model you just fit. It's saying that at CC = 0, the predicted number of patents is 1.055. As CC increases, the predicted number of patents decreases, which is what you saw in your regression output. The predicted number of patents can't be negative in a Poisson model. There's no inconsistency.
      Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

      When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

      Comment


      • #4
        Weiwen Ng

        Thanks for your reply. If I understand correctly, I can say

        1. -xtpoisson,fe- adds more restriction than -margins-, like fixed effects, which results in different reported results.
        2. When CC=0, the margins coefficient is 1.055, meaning that one unit increase in CC will result in 1.055 unit increase in patent. However, as CC increases, the marginal effect is shrinking, which makes CC not that important in function of patent. However, margins cannot report a negative coefficient because it is not true for count data.

        If I make any mistake for the above, please point out. Many thanks.

        Plus, I report sample data using -dataex- in #2 but I really appreciate you point out how to illustrate data result using 'code' button.

        Comment


        • #5
          Originally posted by Chris Jiao View Post
          ...
          2. When CC=0, the margins coefficient is 1.055, meaning that one unit increase in CC will result in 1.055 unit increase in patent. However, as CC increases, the marginal effect is shrinking, which makes CC not that important in function of patent. However, margins cannot report a negative coefficient because it is not true for count data.

          ...
          No, actually. 1.055 is the predicted mean number of patents at CC = 0. It's not the average marginal effect of a one-unit change in CC. You would use margins, dydx(CC) to get that sort of thing - but the problem is, I get the sense that CC is a proportion (e.g. it's coded 0 to 1), and you'd be requesting the average marginal effect of a one whole unit change in CC, i.e. what happens when customer concentration goes from exactly 0 to exactly 1. And Stata doesn't know that CC is only supposed to take on values from 0 to 1. It will happily give you out of sample predictions if you let it. One thing I've done in the past is to recode proportions to 10 percentage point units, i.e. you multiply CC by 10. You could use any chunk that's sensible, really.
          Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

          When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

          Comment


          • #6
            Dear Chris Jiao,

            You may have seen my comments about this elsewhere in this forum, but just in case here is my standard warning; margins after xtpoisson and xtlogit with fixed effects produces results that are meaningless. That is because the marginal effects depend on the fixed effects and these are not estimated when you use these commands, and cannot be estimated consistently unless T gets large. For more details, see here.

            Stata should really disable the margins command after these estimators.

            Best wishes,

            Joao

            Comment


            • #7
              Originally posted by Weiwen Ng View Post

              No, actually. 1.055 is the predicted mean number of patents at CC = 0. It's not the average marginal effect of a one-unit change in CC. You would use margins, dydx(CC) to get that sort of thing - but the problem is, I get the sense that CC is a proportion (e.g. it's coded 0 to 1), and you'd be requesting the average marginal effect of a one whole unit change in CC, i.e. what happens when customer concentration goes from exactly 0 to exactly 1. And Stata doesn't know that CC is only supposed to take on values from 0 to 1. It will happily give you out of sample predictions if you let it. One thing I've done in the past is to recode proportions to 10 percentage point units, i.e. you multiply CC by 10. You could use any chunk that's sensible, really.
              Notwithstanding Joao's comment (and I wasn't aware of this issue, so good to know!), this demonstrates that margins operates in the raw scale.

              Code:
              use https://www.stata-press.com/data/r16/gsem_mixture
              mean drvisits
              Mean estimation                   Number of obs   =      3,677
              
              --------------------------------------------------------------
                           |       Mean   Std. Err.     [95% Conf. Interval]
              -------------+------------------------------------------------
                  drvisits |   6.822682   .1219516      6.583582    7.061781
              --------------------------------------------------------------
              quietly poisson drvisits
              margins
              Warning: prediction constant over observations.
              
              Predictive margins                              Number of obs     =      3,677
              Model VCE    : OIM
              
              Expression   : Predicted number of events, predict()
              
              ------------------------------------------------------------------------------
                           |            Delta-method
                           |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                     _cons |   6.822682   .0430755   158.39   0.000     6.738255    6.907108
              ------------------------------------------------------------------------------
              You could indeed have asked for the marginal effect of CC at various values of CC. The parallel to that in this dataset would look like:

              Code:
              poisson drvisits c.age##(c.educ c.chronic), irr
              margins, dydx(age) at(age = (65(5)85))
              Average marginal effects                        Number of obs     =      3,677
              Model VCE    : OIM
              
              Expression   : Predicted number of events, predict()
              dy/dx w.r.t. : age
              
              1._at        : age             =          65
              
              2._at        : age             =          70
              
              3._at        : age             =          75
              
              4._at        : age             =          80
              
              5._at        : age             =          85
              
              ------------------------------------------------------------------------------
                           |            Delta-method
                           |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
              age          |
                       _at |
                        1  |   .0292312   .0062668     4.66   0.000     .0169486    .0415139
                        2  |   .0305763   .0065387     4.68   0.000     .0177606     .043392
                        3  |   .0319771   .0068445     4.67   0.000     .0185621    .0453922
                        4  |   .0334367   .0071856     4.65   0.000     .0193532    .0475203
                        5  |   .0349582   .0075636     4.62   0.000     .0201339    .0497825
              ------------------------------------------------------------------------------
              Basically, one year of age has a marginal effect of between 0.029 and 0.035 expected physician visits at various ages in the sample.
              Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

              When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

              Comment


              • #8
                Joao Santos Silva The default output from -margins- after -xtlogit, fe- is the probability of a positive outcome conditional on the fixed effect being 0. I could sympathize with an argument that this is not very useful, or maybe even not useful at all, but I don't see why it is meaningless. And the only other output from -margins- after -xtlogit, fe- is xb, which clearly is independent of the fixed effects. So I think that as long as people understand that the output is a conditioned on fixed effect = 0, not an average margin/marginal effect, I don't see the harm. What am I missing?

                Comment


                • #9
                  Dear Clyde Schechter,

                  The problem is that the assumption that the fixed effects are zero is not a sensible one. Note that unlike in the RE case, there is no reason to assume that the FE have mean zero or even that the FE are equal to zero for someone in the population; they may well be all positive and large. To illustrate the issue, suppose that one of the variables in the model is the log of income or of some other variable. If, say, we change the scale of the variable from dollars to pounds or thousands of dollars, the estimates do not change but the implicit fixed effects change, and therefore margins will give a different results. Therefore, if two researchers have the same data and one decides to work with dollars and the other with thousands of dollars, they will estimate the same coefficients but will find different marginal effects. This is illustrated here.

                  Best wishes,

                  Joao

                  Comment


                  • #10
                    Joao Santos Silva Thank you!

                    Comment


                    • #11
                      Weiwen Ng

                      Weiwen,

                      Thanks. Indeed, CC is a ratio ranging from 0 to 1, which means if I use the following code, it shows one increase in CC has actually exceeding marginal effect on patents.

                      Code:
                      poisson npatent CC CDsum Linkage c.CC#c.Linkage c.CDsum#c.Linkage $controls, irr
                      quietly margins, dydx(CC) at(CC=(0(0.1)0.6))
                      marginsplot
                      My concern is if there is any trick that makes Stata know it is a 0-1 ratio without multiplying CC by 10. Therefore, it generates marginal effect by 0.1unit increase instead of 1.

                      Thanks.

                      Comment


                      • #12
                        Originally posted by Joao Santos Silva View Post
                        Dear Chris Jiao,

                        You may have seen my comments about this elsewhere in this forum, but just in case here is my standard warning; margins after xtpoisson and xtlogit with fixed effects produces results that are meaningless. That is because the marginal effects depend on the fixed effects and these are not estimated when you use these commands, and cannot be estimated consistently unless T gets large. For more details, see here.

                        Stata should really disable the margins command after these estimators.

                        Best wishes,

                        Joao
                        Hi Joao,

                        Thanks for your guide.

                        After reading your slides, I still have several questions.

                        I am using -xtpoisson- command for my data with excess zeros. I want to use plots to better present my interaction effects between IV and moderator. However, as -margins- for fixed effects is not applicable here, I cannot plot these unless I cancel the command -fe- in my model.

                        Do you have any suggestion about this? My purpose is to present interaction effects in a clear plot. Thanks

                        Comment


                        • #13
                          Dear Chris Jiao,

                          I am afraid I am not familiar with that sort of plots, but note that in parameters estimated by xtpoisson have a simple interpretation as elasticities or semi-elasticities (this is not the case with xtlogit) so you do not really need marginal effects and can work directly with the estimates you obtain.

                          Best wishes,

                          Joao

                          Comment


                          • #14
                            Originally posted by Joao Santos Silva View Post
                            Dear Chris Jiao,

                            I am afraid I am not familiar with that sort of plots, but note that in parameters estimated by xtpoisson have a simple interpretation as elasticities or semi-elasticities (this is not the case with xtlogit) so you do not really need marginal effects and can work directly with the estimates you obtain.

                            Best wishes,

                            Joao
                            Joao: Thanks for your suggestion. I will check it.

                            Comment

                            Working...
                            X