Announcement

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

  • Testing the slopes of regression lines after -margins-

    Hello dear forum members!

    Consider I estimate the following model:

    Code:
    xtpoisson y x1 x2 c.x1##c.x2, fe vce(robust)
    Next, to examine the interaction effects, I calculate the adjusted predictions and plot them:

    Code:
    margins, at(x1=(0 1) x2=(1,2,3,4,5,6,7))
    marginsplot, noci
    Below are my adjusted predictions:

    HTML Code:
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             _at |
              1  |   .3913537   .0408903     9.57   0.000     .3112102    .4714972
              2  |   .3951653   .0509069     7.76   0.000     .2953896    .4949411
              3  |    .398977   .0812081     4.91   0.000     .2398119     .558142
              4  |   .4027886    .116969     3.44   0.001     .1735335    .6320437
              5  |   .4066002   .1544425     2.63   0.008     .1038984    .7093021
              6  |   .4104119   .1926317     2.13   0.033     .0328606    .7879632
              7  |   .4142235   .2311822     1.79   0.073    -.0388853    .8673324
              8  |    .437338    .036421    12.01   0.000     .3659542    .5087219
              9  |   .4744837   .0684443     6.93   0.000     .3403353    .6086321
             10  |   .5116294   .1181651     4.33   0.000       .28003    .7432288
             11  |   .5487751   .1707677     3.21   0.001     .2140766    .8834736
             12  |   .5859207    .224233     2.61   0.009     .1464322    1.025409
             13  |   .6230664   .2780638     2.24   0.025     .0780713    1.168062
             14  |   .6602121   .3320825     1.99   0.047     .0093423    1.311082
    ------------------------------------------------------------------------------
    My question: Is it correct to use -test- (see below) to test if there is a difference between the slopes of the regression lines?

    Code:
    test (1bn._at = 2._at) (2._at = 3._at) (3._at = 4._at) (4._at = 5._at) (5._at = 6._at) (6._at = 7._at) (7._at = 8._at) (8._at = 9._at) (9._at = 10._at) (10._at = 11._at) (11._at = 12._at) (12._at = 13._at) (13._at = 14._at)
    Thankfully,
    Anton
    Last edited by Anton Ivanov; 24 May 2016, 09:38.

  • #2
    I am sincerely curious if this is a difficult question or there is something wrong with the way I ask it.

    Comment


    • #3
      The margins command you issued does not calculate slopes of the regression lines. It calculates the average values of the linear prediction (-xb- in Stataspeak) at the specified values of x1 and x2. If you want the marginal effects of x1 and x2 on xb at the corresponding values of the other, then it would be:
      Code:
      margins, dydx(x1) at(x2 = (1(1)7))
      margins, dydx(x2) at(x1 = (0 1))
      If you want the marginal effect on some more interesting outcome (e.g. event rates, predicted numbers of events) then you would have to add the corresponding -predict()- option to these commands. See -help xtpoisson postestimation-. (Note that with fixed effects estimation you cannot estimate predicted number of events: you can only do so conditional on the fixed effect being zero.)

      Then it isn't entirely clear exactly what kind of test you are trying to do. Do you want an omnibus test? Or do you want a series of separate tests corresponding to particular values of x2? If the latter, try the -pwcompare- option on -margins, dydx()-.

      Last edited by Clyde Schechter; 24 May 2016, 12:39.

      Comment


      • #4
        I appreciate your reply, Clyde.

        Ok, I understand that. But based on the average values of the linear predictions I can plot the regression lines and examine their slopes (see the attached picture). Then what would be the proper formal way to test if, say, the bottom one is significantly different from the upper one?

        In my initial post, I tried to elaborate based on the example for using -test- after -margins- provided by IDRE UCLA (http://www.ats.ucla.edu/stat/stata/f...nteraction.htm), but was not sure about it and decided to ask here.

        Click image for larger version

Name:	Screen Shot 2016-05-24 at 14.40.51.png
Views:	1
Size:	132.4 KB
ID:	1342453
        Last edited by Anton Ivanov; 24 May 2016, 13:09.

        Comment


        • #5
          Well, I don't think you can test the slopes using the output of just plain -margins-. The slopes are marginal effects, not margins. So you need to get them from -margins, dydx(x1), at(x2 = (1(1)7))-. This will give you 7 slopes. You could then apply -test 1._at = test 7._at- to formally test whether the first and the last are distinguishable with your data. And again, don't forget that this -margins, dydx()- command will give you the marginal effects of x1 on -xb- at those values of x2, not the marginal effect of x1 on the expected outcome. Marginal effects on -xb- are usually not of great interest. So you need to decide what outcome you are most interested in seeing the marginal effects on and specify the appropriate -predict()- option.

          Comment


          • #6
            Thank you very much for reply, Clyde. I got your point and will elaborate on it accordingly.

            Comment

            Working...
            X