Announcement

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

  • Help with graph, poisson regression

    Hello,

    I have ran a poisson regression for a paper that I have to write. My goal was to find the proportional relationship between firm size and innovative output (measured in patents) for small, medium and large companies. This is my results table, I already know how to interpret them, but I do not know how to make a nice graph that people can easily understand. Is there someone who can help me with this?

    Thanks in advance!
    Click image for larger version

Name:	Table 4.png
Views:	1
Size:	22.3 KB
ID:	1614529
    Click image for larger version

Name:	2021-06-14 (1).png
Views:	1
Size:	177.9 KB
ID:	1614530

  • #2
    Not an advice about graph, but for the model. Unless I'm missing something, I think it has gone wrong.
    • If ib2.group is the reference group, then its "RR" should be 1.00. Because all other RR is referring to this group as the reference group (aka, "this group is xxx times as group 2"). So, the fact that your group 2 is 1.739 in the table is very odd. The reason is that currently in your output, 1.739 is actually the RR of ln(emp), which got omitted from the Poisson statement.
    • It's unclear why you picked to only report the RR of the product between ln(emp) and group and completely ignore the other two at the bottom (5.31316 and 14.38719).
    • Once the main predictor is involved in an interaction, there will no long be one set of RRs that apply through the interpretation, because those RRs will change when emp changes.
    • What is the reason log-transforming the patent number? That would completely change the interpretation of RR.
    Last edited by Ken Chui; 14 Jun 2021, 05:56.

    Comment


    • #3
      Hello,

      Ah okay do you know how to fix this?
      What do the other two at the bottom mean?
      I have transformed my number of patents to log because then you would gain insights about the proportional effect, right? Or am I missing something

      Comment


      • #4
        Since you didn't use -dataex- to provide data I will not be able to get you the codes that you can immediately use. Here I can only provide an example using a built-in data set:

        Code:
        sysuse nlsw88, clear
        
        * Find out some representative values for the continuous independent varaible:
        sum tenure, detail
        * Let's say we will use 5th,  25th, 50th (median), 75th, and 95th percentile.
        
        * Set up the Poisson model:
        poisson wage ib2.race##c.tenure, base irr
        
        * Compute predicted margins:
        margins race, at(tenure = (.25 1.58 3.83 9.33 17.42))
        marginsplot
        Feel free to run and see how it can be done. Because the IRR in the model is no longer "universal" as now they will change according to tenure's value, we have to do more work to interpret them. For example, one way is to set up some small number of scenarios and derive the predicted outcomes for them using techniques like -margins-, followed by a visualization using -marginsplot-.

        I have transformed my number of patents to log because then you would gain insights about the proportional effect, right? Or am I missing something
        ^ Yes, I believe something may be missing. Using ln(y) as a way to get to percent change is a trick for linear regression, and not Poisson. If you use ln(y) in Poisson, the IRR will be "relative change in a log scale" and log scale is already an expression of relative change. The interpretation will be mind-boggling.

        The remaining issues are that:
        1. Does the continuous variable in the independent (predictor) side need to be log-transformed? That I don't think so, but without the data I cannot tell.
        2. The y appears to be patent per year. And if that's the case it's a rate, and that assumes all companies have the same weight in the analysis. That is likely untrue because some companies may have been observed for a longer period of time in your data simply because they are older. In those case, Poisson regression would need an "offset". That's a technical detail I don't think I can cover here.
        3. Poisson regression has its own set of assumptions, which would need to be checked.
        I'd suggest, if possible, take your data and research question to someone who is experienced in analyzing these types of data before, and lay out the analysis plan first.

        To learn more about the model, check out the use cases in the PDF document by command -help poisson-, click the top link to access the PDF. To learn more about the margins, use -help margins-. A great title on visualizing regression output is Interpreting and Visualizing Regression Models Using Stata (https://www.stata.com/bookstore/inte...ession-models/).
        Last edited by Ken Chui; 14 Jun 2021, 08:50.

        Comment


        • #5
          input long gvkey double(year pat_yr pub_yr) long gind double(emp xrd) float(group group_2 ln_pat_yr ln_emp ln_xrd c c1 c2 c3) byte(_Igroup_2 _Igroup_3)
          5811 1989 2 0 151010 4 168000 1 1 .6931472 1.3862944 12.03172 .18758322 .18758322 . . 0 0
          4176 1994 0 0 151010 4 139000 1 1 . 1.3862944 11.84223 .18758322 .18758322 . . 0 0
          5811 1988 1 0 151010 4 155000 1 1 0 1.3862944 11.95118 .18758322 .18758322 . . 0 0
          4176 1993 0 0 151010 4 170000 1 1 . 1.3862944 12.043553 .18758322 .18758322 . . 0 0
          4176 1992 0 0 151010 4 89000 1 1 . 1.3862944 11.396392 .18758322 .18758322 . . 0 0
          4176 1995 0 0 151010 4 183000 1 1 . 1.3862944 12.117242 .18758322 .18758322 . . 0 0
          5811 1987 1 0 151010 4 154000 1 1 0 1.3862944 11.944708 .18758322 .18758322 . . 0 0
          5811 1990 0 0 151010 5 158000 1 1 . 1.609438 11.97035 .19982676 .19982676 . . 0 0
          5811 1991 1 0 151010 6 208000 1 1 0 1.7917595 12.245294 .21042137 .21042137 . . 0 0
          5811 1986 0 0 151010 6 137000 1 1 . 1.7917595 11.827736 .21042137 .21042137 . . 0 0
          5811 1985 1 0 151010 7 251000 1 1 0 1.94591 12.433208 .219816 .219816 . . 0 0
          12408 1990 0 0 151010 7 371000 1 1 . 1.94591 12.823957 .219816 .219816 . . 0 0
          15283 1996 0 0 151010 8 170000 1 1 . 2.0794415 12.043553 .2282924 .2282924 . . 0 0
          15283 1998 0 0 151010 8 183000 1 1 . 2.0794415 12.117242 .2282924 .2282924 . . 0 0
          12408 1996 0 0 151010 8 309000 1 1 . 2.0794415 12.641096 .2282924 .2282924 . . 0 0
          12408 1991 1 0 151010 8 460000 1 1 0 2.0794415 13.038981 .2282924 .2282924 . . 0 0
          61774 1998 3 0 151010 8 1009000 1 1 1.0986123 2.0794415 13.82447 .2282924 .2282924 . . 0 0
          15283 1997 1 0 151010 8 165000 1 1 0 2.0794415 12.0137 .2282924 .2282924 . . 0 0
          12408 1997 0 0 151010 8 522000 1 1 . 2.0794415 13.165422 .2282924 .2282924 . . 0 0
          12408 1998 0 0 151010 8 453000 1 1 . 2.0794415 13.023647 .2282924 .2282924 . . 0 0
          21361 1998 3 0 151010 9 376000 1 1 1.0986123 2.1972246 12.837344 .23604003 .23604003 . . 0 0
          12408 1993 1 0 151010 9 329000 1 1 0 2.1972246 12.703813 .23604003 .23604003 . . 0 0
          5811 1992 1 0 151010 9 254000 1 1 0 2.1972246 12.44509 .23604003 .23604003 . . 0 0
          12408 1994 1 0 151010 9 392000 1 1 0 2.1972246 12.879017 .23604003 .23604003 . . 0 0
          15283 1995 0 0 151010 9 153000 1 1 . 2.1972246 11.938193 .23604003 .23604003 . . 0 0
          12408 1995 0 0 151010 9 348000 1 1 . 2.1972246 12.759957 .23604003 .23604003 . . 0 0
          21116 1993 2 0 151010 9 0 1 1 .6931472 2.1972246 . .23604003 .23604003 . . 0 0
          12408 1989 1 0 151010 10 796000 1 1 0 2.3025851 13.587355 .24319305 .24319305 . . 0 0
          5811 1984 1 0 151010 10 412000 1 1 0 2.3025851 12.92878 .24319305 .24319305 . . 0 0
          12408 1992 0 0 151010 10 410000 1 1 . 2.3025851 12.923912 .24319305 .24319305 . . 0 0
          5811 1994 0 0 151010 10 465000 1 1 . 2.3025851 13.049792 .24319305 .24319305 . . 0 0
          5811 1993 1 0 151010 10 411000 1 1 0 2.3025851 12.92635 .24319305 .24319305 . . 0 0
          5811 1995 1 0 151010 11 575000 1 1 0 2.397895 13.262125 .2498503 .2498503 . . 0 0
          5811 1996 0 0 151010 11 499000 1 1 . 2.397895 13.12036 .2498503 .2498503 . . 0 0
          5811 1997 0 0 151010 11 385000 1 1 . 2.397895 12.860998 .2498503 .2498503 . . 0 0
          15283 1990 1 3 151010 13 300000 1 1 0 2.564949 12.611538 .26196134 .26196134 . . 0 0
          5811 1998 2 0 151010 14 512000 1 1 .6931472 2.6390574 13.14608 .26752037 .26752037 . . 0 0
          21361 1997 2 0 151010 14 481000 1 1 .6931472 2.6390574 13.083623 .26752037 .26752037 . . 0 0
          24815 1995 1 0 151010 15 22000 1 1 0 2.70805 9.998797 .27280164 .27280164 . . 0 0
          13766 1990 0 0 151010 19 244000 1 1 . 2.944439 12.404923 .2917001 .2917001 . . 0 0
          4176 1996 0 0 151010 19 109000 1 1 . 2.944439 11.599103 .2917001 .2917001 . . 0 0
          27856 1998 5 0 151010 20 1168000 1 1 1.609438 2.995732 13.970803 .29597065 .29597065 . . 0 0
          12408 1988 2 1 151010 23 1409000 1 1 .6931472 3.135494 14.15839 .3079268 .3079268 . . 0 0
          13766 1989 1 0 151010 24 1082000 1 1 0 3.178054 13.894321 .3116627 .3116627 . . 0 0
          25637 1993 2 0 151010 26 643000 1 1 .6931472 3.2580965 13.3739 .318812 .318812 . . 0 0
          24815 1992 1 0 151010 26 283000 1 1 0 3.2580965 12.553203 .318812 .318812 . . 0 0
          11070 1991 2 4 151010 27 227000 1 1 .6931472 3.295837 12.332705 .3222396 .3222396 . . 0 0
          8849 1993 0 0 151010 28 7966000 2 1 . 3.3322046 15.890693 .3255774 . .3255774 . 1 0
          12408 1987 1 0 151010 28 1210000 1 1 0 3.3322046 14.00613 .3255774 .3255774 . . 0 0
          64483 1998 1 0 151010 28 51000 1 1 0 3.3322046 10.83958 .3255774 .3255774 . . 0 0
          24815 1994 0 1 151010 28 59000 1 1 . 3.3322046 10.985292 .3255774 .3255774 . . 0 0
          24815 1991 3 0 151010 29 181000 1 1 1.0986123 3.367296 12.106253 .3288309 .3288309 . . 0 0
          13766 1988 1 0 151010 31 662000 1 1 0 3.433987 13.40302 .3351039 .3351039 . . 0 0
          24815 1993 1 0 151010 34 47000 1 1 0 3.5263605 10.757903 .3439908 .3439908 . . 0 0
          7430 1992 1 0 151010 38 135000 1 1 0 3.637586 11.81303 .3550046 .3550046 . . 0 0
          7430 1993 1 0 151010 39 294000 1 1 0 3.6635616 12.591335 .3576272 .3576272 . . 0 0
          11070 1984 5 2 151010 41 676000 1 1 1.609438 3.713572 13.423948 .362731 .362731 . . 0 0
          28828 1996 2 0 151010 43 203000 1 1 .6931472 3.7612 12.220962 .3676595 .3676595 . . 0 0
          7430 1986 1 0 151010 44 301000 1 1 0 3.78419 12.614865 .3700623 .3700623 . . 0 0
          7430 1988 0 0 151010 44 215000 1 1 . 3.78419 12.278394 .3700623 .3700623 . . 0 0
          4176 1998 0 0 151010 44 81000 1 1 . 3.78419 11.302204 .3700623 .3700623 . . 0 0
          7430 1987 0 0 151010 44 245000 1 1 . 3.78419 12.409014 .3700623 .3700623 . . 0 0
          11070 1981 2 1 151010 44 279000 1 1 .6931472 3.78419 12.538967 .3700623 .3700623 . . 0 0
          4176 1997 0 0 151010 44 225000 1 1 . 3.78419 12.323855 .3700623 .3700623 . . 0 0
          26018 1994 2 .5 151010 45 23000 1 1 .6931472 3.8066626 10.04325 .3724262 .3724262 . . 0 0
          26018 1993 2 0 151010 45 48000 1 1 .6931472 3.8066626 10.778956 .3724262 .3724262 . . 0 0
          7430 1989 0 0 151010 46 102000 1 1 . 3.8286414 11.532728 .3747529 .3747529 . . 0 0
          7430 1990 0 0 151010 47 229000 1 1 . 3.8501475 12.341477 .3770435 .3770435 . . 0 0
          7430 1991 0 0 151010 47 200000 1 1 . 3.8501475 12.206073 .3770435 .3770435 . . 0 0
          11070 1985 2 1 151010 48 140000 1 1 .6931472 3.871201 11.849398 .3792995 .3792995 . . 0 0
          7430 1994 0 0 151010 48 275000 1 1 . 3.871201 12.524527 .3792995 .3792995 . . 0 0
          4551 1997 0 0 151010 50 419000 1 1 . 3.912023 12.945626 .3837123 .3837123 . . 0 0
          7430 1995 2 0 151010 50 478000 1 1 .6931472 3.912023 13.077366 .3837123 .3837123 . . 0 0
          11070 1983 1 0 151010 51 851000 1 1 0 3.9318256 13.654167 .3858714 .3858714 . . 0 0
          4551 1998 0 0 151010 51 359000 1 1 . 3.9318256 12.791078 .3858714 .3858714 . . 0 0
          8257 1986 0 0 151010 51 84000 1 1 . 3.9318256 11.338573 .3858714 .3858714 . . 0 0
          9925 1982 0 0 151010 53 197000 1 1 . 3.970292 12.19096 .3901002 .3901002 . . 0 0
          11070 1982 2 0 151010 53 429000 1 1 .6931472 3.970292 12.969213 .3901002 .3901002 . . 0 0
          11070 1990 3 0 151010 54 236000 1 1 1.0986123 3.988984 12.371587 .3921719 .3921719 . . 0 0
          11070 1989 3 3 151010 54 377000 1 1 1.0986123 3.988984 12.84 .3921719 .3921719 . . 0 0
          11070 1980 1 0 151010 56 217000 1 1 0 4.0253515 12.287653 .396234 .396234 . . 0 0
          11070 1986 1 0 151010 57 255000 1 1 0 4.0430512 12.449018 .3982262 .3982262 . . 0 0
          4551 1987 1 0 151010 58 484000 1 1 0 4.060443 13.08984 .4001935 .4001935 . . 0 0
          27856 1997 5 0 151010 58 605000 1 1 1.609438 4.060443 13.312984 .4001935 .4001935 . . 0 0
          8257 1987 0 0 151010 60 64000 1 1 . 4.0943446 11.066638 .4040563 .4040563 . . 0 0
          27856 1996 3 3 151010 61 6186000 2 1 1.0986123 4.1108737 15.6378 .4059532 . .4059532 . 1 0
          8257 1984 0 0 151010 61 79000 1 1 . 4.1108737 11.277204 .4059532 .4059532 . . 0 0
          1979 1988 1 0 151010 62 99000 1 1 0 4.1271343 11.502875 .4078279 .4078279 . . 0 0
          9925 1983 0 0 151010 64 120000 1 1 . 4.158883 11.695247 .4115134 .4115134 . . 0 0
          8257 1985 1 0 151010 65 91000 1 1 0 4.1743875 11.418614 .4133252 .4133252 . . 0 0
          7430 1996 0 0 151010 65 503000 1 1 . 4.1743875 13.128345 .4133252 .4133252 . . 0 0
          9925 1981 1 0 151010 66 211000 1 1 0 4.189655 12.259613 .4151171 .4151171 . . 0 0
          1979 1989 1 0 151010 66 175000 1 1 0 4.189655 12.07254 .4151171 .4151171 . . 0 0
          4551 1994 4 0 151010 67 514000 1 1 1.3862944 4.204693 13.14998 .4168897 .4168897 . . 0 0
          4551 1995 1 0 151010 67 489000 1 1 0 4.204693 13.100118 .4168897 .4168897 . . 0 0
          8886 1986 0 1 151010 69 187000 1 1 . 4.2341065 12.138864 .4203788 .4203788 . . 0 0
          4551 1992 1 0 151010 70 398000 1 1 0 4.248495 12.894207 .4220962 .4220962 . . 0 0
          4551 1996 0 0 151010 70 484000 1 1 . 4.248495 13.08984 .4220962 .4220962 . . 0 0
          7430 1997 0 0 151010 70 488000 1 1 . 4.248495 13.09807 .4220962 .4220962 . . 0 0
          25637 1994 0 0 151010 71 1657000 1 1 . 4.26268 14.32052 .42379615 .42379615 . . 0 0
          This is my dataex if that is what you meant?

          Comment


          • #6
            Yes, you can just replace "race" with "group" and replace "tenure" with "emp" (or if you feel log is better, ln_emp). In this example it's also clear that log-transforming the patent number is a very bad idea due to the many 0. ln(0) is not defined so those cases with 0 patent ended up being missing (.) in the ln_pat_yr. Using pat_yr as is would be better.

            Comment


            • #7
              Okay, the code I have used is: poisson pat_yr ib2.group##c.ln_emp, base irr

              This is what I got, what would this say?

              Click image for larger version

Name:	2021-06-15 (2).png
Views:	1
Size:	40.1 KB
ID:	1614742

              Comment

              Working...
              X