Announcement

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

  • #16
    Sorry, I did not realize that there was more pages, so couldnt find my post. Look at #18 for my question
    Last edited by Gustav Egede Hansen; 16 Nov 2021, 08:16.

    Comment


    • #17
      Sorry, I did not realize that there was more pages, so couldnt find my post. Look at #18 for my question
      Last edited by Gustav Egede Hansen; 16 Nov 2021, 08:16.

      Comment


      • #18

        @Fei Wang I have a question if you dont mind. For the time being, I am using a poisson regression to estimate the effect of my treatment variable on salary.
        Code:
        xtpoisson salary i.treatment##i.time..., vce(robust) fe
        I am looking to use the margins-command to calculate the percentage change in salary before the treatment (time = 99) and after (time = 101). - dydx - seems to yield sensible results:
        Code:
        margins, dydx(treatment) at(time = 99 101))
        lincom _b[1.treatment:2._at]-_b[1.treatment:1bn._at]
        di (exp(r(estimate))-1)*100
        In the contrary, the results from running the eydx seem wrong. The sentence you wrote "an advantage of using -poisson- is that the reported coefficient has already been the semi-elasticity (if you don't have interactions)" has gotten me a bit confussed because if the reported coefficients are semi-elastic wouldn't be possible to just use dydx to interpret them across the treatment-variable (rather than using eydx)?

        Best,
        Gustav

        Comment


        • #19
          I don't understand your calculation in #18. If you'd like to derive "the percentage change in salary before the treatment (time = 99) and after (time = 101)", I would show a simple way as below, with a poisson regression based on you example data in #1. After setting time 99 as the base, the original coefficient of "time#c.treatment" at 101 is exactly what you need (that's what I meant by "reported coefficient has already been the semi-elasticity"). I also show how you could equivalently derive this number with -margins-.

          Code:
          . poisson salary c.treatment##ib(99).time, vce(cluster id)
          
          Iteration 0:   log pseudolikelihood = -36592.386  
          Iteration 1:   log pseudolikelihood = -36592.386  
          
          Poisson regression                              Number of obs     =        100
                                                          Wald chi2(7)      =          .
                                                          Prob > chi2       =          .
          Log pseudolikelihood = -36592.386               Pseudo R2         =     0.1445
          
                                                  (Std. Err. adjusted for 16 clusters in id)
          ----------------------------------------------------------------------------------
                           |               Robust
                    salary |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -----------------+----------------------------------------------------------------
                 treatment |   .0263173    .076578     0.34   0.731    -.1237728    .1764074
                           |
                      time |
                       97  |  -.0202027   .0205503    -0.98   0.326    -.0604805     .020075
                       98  |   8.97e-16   1.19e-08     0.00   1.000    -2.33e-08    2.33e-08
                      100  |  -.0202027   .0205503    -0.98   0.326    -.0604805     .020075
                      101  |   1.06e-15    .033385     0.00   1.000    -.0654334    .0654334
                      102  |   .0263173   .0263149     1.00   0.317    -.0252589    .0778935
                      103  |   1.04e-15          .        .       .            .           .
                           |
          time#c.treatment |
                       97  |  -.0263173   .0382658    -0.69   0.492    -.1013169    .0486823
                       98  |    -.04652   .0322794    -1.44   0.150    -.1097865    .0167464
                      100  |  -.0061146   .0333884    -0.18   0.855    -.0715547    .0593255
                      101  |  -.1771402   .0446678    -3.97   0.000    -.2646875   -.0895929
                      102  |  -.2034575   .0396627    -5.13   0.000     -.281195     -.12572
                      103  |  -.1771402   .0509788    -3.47   0.001    -.2770568   -.0772236
                           |
                     _cons |   10.48331   .0540899   193.81   0.000     10.37729    10.58932
          ----------------------------------------------------------------------------------
          
          . margins, eydx(treatment) at(time = (99 101))
          
          Average marginal effects                        Number of obs     =        100
          Model VCE    : Robust
          
          Expression   : Predicted number of events, predict()
          ey/dx w.r.t. : treatment
          
          1._at        : time            =          99
          
          2._at        : time            =         101
          
          ------------------------------------------------------------------------------
                       |            Delta-method
                       |      ey/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          treatment    |
                   _at |
                    1  |   .0263173    .076578     0.34   0.731    -.1237728    .1764074
                    2  |  -.1508229   .0829549    -1.82   0.069    -.3134116    .0117658
          ------------------------------------------------------------------------------
          
          . di r(table)[1,2]-r(table)[1,1]
          -.1771402

          Comment


          • #20
            Thanks for the reply. I need the fixed effects, so I need to use the xtpoisson. Curiously, when I run - possion -, then eydx provides the elasticity, but when I run - xtpoisson - then dydx seems to provide the elasticity. Can you explain this? To me, it seems like xtpoisson has already calculated the coefficients in semi-elastic form, which is why the dydx following xtpoisson is similar to eydx following poisson. But this is just from experimenting.
            Last edited by Gustav Egede Hansen; 16 Nov 2021, 11:12.

            Comment


            • #21
              -margins- after -xtlogit, fe- or -xtpoisson, fe- won't give meaningful results because they are both conditional MLE where heterogeneity distributions are not specified. The original coefficients from -xtpoisson, fe- have already been semi-elasticities and you won't need -margins- anyway.

              Another solution where FE can be accounted for and -margins- can be used is to go with -poisson- + Mundlak device to which Jeff gave an example in here (replacing oprobit with poisson). With unbalanced data, some adjustment is needed, and you may refer to Jeff's paper in here. BTW, If your poisson regression only controls for treatment, time and their interactions, then my estimation in #19 has already been an application of this approach with balanced panel data (-xtpoisson, fe- with the same model specification should give similar coefficients).
              Last edited by Fei Wang; 16 Nov 2021, 12:19.

              Comment


              • #22
                To further explain the Mundlak device in #21, I only keep balanced panel from the example data in #1. With the same model specification, results are consistent, too. With unbalanced panel (as in #19) or adding time-varying covariates, the first model specification needs adjustment. One advantage of the first method is that time-invariant variables, like gender, can be controlled for, while it's dropped from the second model.

                Code:
                . bys id (time): keep if _N == 7
                (23 observations deleted)
                
                . 
                . poisson salary c.treatment##ib(99).time gender
                
                Iteration 0:   log likelihood = -540.67223  
                Iteration 1:   log likelihood = -540.66877  
                Iteration 2:   log likelihood = -540.66877  
                
                Poisson regression                              Number of obs     =         77
                                                                LR chi2(14)       =   49279.35
                                                                Prob > chi2       =     0.0000
                Log likelihood = -540.66877                     Pseudo R2         =     0.9785
                
                ----------------------------------------------------------------------------------
                          salary |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                -----------------+----------------------------------------------------------------
                       treatment |  -.0007677   .0031363    -0.24   0.807    -.0069147    .0053794
                                 |
                            time |
                             97  |  -5.07e-17   .0030151    -0.00   1.000    -.0059095    .0059095
                             98  |  -5.63e-17   .0030151    -0.00   1.000    -.0059095    .0059095
                            100  |  -2.28e-17   .0030151    -0.00   1.000    -.0059095    .0059095
                            101  |   2.86e-16   .0030151     0.00   1.000    -.0059095    .0059095
                            102  |   3.06e-16   .0030151     0.00   1.000    -.0059095    .0059095
                            103  |   3.20e-16   .0030151     0.00   1.000    -.0059095    .0059095
                                 |
                time#c.treatment |
                             97  |   4.36e-16   .0044291     0.00   1.000    -.0086809    .0086809
                             98  |   4.44e-16   .0044291     0.00   1.000    -.0086809    .0086809
                            100  |   8.90e-17   .0044291     0.00   1.000    -.0086809    .0086809
                            101  |  -.1410786   .0045183   -31.22   0.000    -.1499342    -.132223
                            102  |  -.1410786   .0045183   -31.22   0.000    -.1499342    -.132223
                            103  |  -.1410786   .0045183   -31.22   0.000    -.1499342    -.132223
                                 |
                          gender |    -.29438   .0014577  -201.95   0.000    -.2972369    -.291523
                           _cons |   10.59846   .0021684  4887.68   0.000     10.59421    10.60271
                ----------------------------------------------------------------------------------
                
                . 
                . xtset id
                       panel variable:  id (balanced)
                
                . xtpoisson salary c.treatment##ib(99).time gender, fe
                note: treatment dropped because it is constant within group
                note: gender dropped because it is constant within group
                
                Iteration 0:   log likelihood = -3453.2366  
                Iteration 1:   log likelihood = -443.11526  
                Iteration 2:   log likelihood = -442.71387  
                Iteration 3:   log likelihood = -442.71387  
                
                Conditional fixed-effects Poisson regression    Number of obs     =         77
                Group variable: id                              Number of groups  =         11
                
                                                                Obs per group:
                                                                              min =          7
                                                                              avg =        7.0
                                                                              max =          7
                
                                                                Wald chi2(12)     =    5966.20
                Log likelihood  = -442.71387                    Prob > chi2       =     0.0000
                
                ----------------------------------------------------------------------------------
                          salary |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                -----------------+----------------------------------------------------------------
                            time |
                             97  |  -1.41e-17   .0030151    -0.00   1.000    -.0059095    .0059095
                             98  |  -1.37e-17   .0030151    -0.00   1.000    -.0059095    .0059095
                            100  |  -1.45e-17   .0030151    -0.00   1.000    -.0059095    .0059095
                            101  |  -4.13e-17   .0030151    -0.00   1.000    -.0059095    .0059095
                            102  |  -4.09e-17   .0030151    -0.00   1.000    -.0059095    .0059095
                            103  |   5.96e-23   .0030151     0.00   1.000    -.0059095    .0059095
                                 |
                time#c.treatment |
                             97  |   1.18e-15   .0044291     0.00   1.000    -.0086809    .0086809
                             98  |   1.18e-15   .0044291     0.00   1.000    -.0086809    .0086809
                             99  |          0  (omitted)
                            100  |   9.21e-16   .0044291     0.00   1.000    -.0086809    .0086809
                            101  |  -.1410786   .0045183   -31.22   0.000    -.1499343    -.132223
                            102  |  -.1410786   .0045183   -31.22   0.000    -.1499343    -.132223
                            103  |  -.1410786   .0045183   -31.22   0.000    -.1499343    -.132223
                ----------------------------------------------------------------------------------

                Comment


                • #23
                  Thanks for this elaborate explanation of the Mundlak device! I still have a question for xtpoisson. If the "the original coefficients from -xtpoisson, fe- have already been semi-elasticities" wouldnt it been wise to subsequently use - dydx - to interpret them, especially given the use of interaction between time and treatment? And of couse still using - di (exp(r(estimate))-1)*100 - to have the precentage change.
                  Last edited by Gustav Egede Hansen; 17 Nov 2021, 01:12.

                  Comment


                  • #24
                    In the estimation below, the interaction of treatment and time101 has already been what you need: The intervention decreases salary by 14.88%. If you need accurate percentage, then the last line tells that the intervention decreases salary by 13.82%.

                    Using -margins, dydx- after -xtpoisson, fe- reports the original coefficients which are actually "eyex". So I wouldn't trust any result derived from -margins- in this case, regardless whether it happens to give correct answers.


                    Code:
                    . xtset id
                           panel variable:  id (unbalanced)
                    
                    . xtpoisson salary c.treatment##ib(99).time, fe
                    note: treatment dropped because it is constant within group
                    
                    Iteration 0:   log likelihood = -5157.3203  
                    Iteration 1:   log likelihood = -609.10207  
                    Iteration 2:   log likelihood = -608.27842  
                    Iteration 3:   log likelihood = -608.27842  
                    
                    Conditional fixed-effects Poisson regression    Number of obs     =        100
                    Group variable: id                              Number of groups  =         16
                    
                                                                    Obs per group:
                                                                                  min =          3
                                                                                  avg =        6.2
                                                                                  max =          7
                    
                                                                    Wald chi2(12)     =    9002.57
                    Log likelihood  = -608.27842                    Prob > chi2       =     0.0000
                    
                    ----------------------------------------------------------------------------------
                              salary |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                    -----------------+----------------------------------------------------------------
                                time |
                                 97  |   1.43e-17   .0027776     0.00   1.000     -.005444     .005444
                                 98  |   2.73e-17   .0028284     0.00   1.000    -.0055436    .0055436
                                100  |   6.94e-17   .0027776     0.00   1.000     -.005444     .005444
                                101  |   2.82e-17   .0028761     0.00   1.000    -.0056371    .0056371
                                102  |   9.81e-17   .0029418     0.00   1.000    -.0057659    .0057659
                                103  |  -2.17e-19   .0028284    -0.00   1.000    -.0055436    .0055436
                                     |
                    time#c.treatment |
                                 97  |   .0033096    .004007     0.83   0.409    -.0045439    .0111631
                                 98  |   .0033096   .0040424     0.82   0.413    -.0046132    .0112325
                                 99  |          0  (omitted)
                                100  |   .0016513   .0040466     0.41   0.683    -.0062798    .0095824
                                101  |    -.14877   .0041968   -35.45   0.000    -.1569955   -.1405445
                                102  |  -.1491716   .0042385   -35.19   0.000    -.1574789   -.1408643
                                103  |  -.1484763   .0041901   -35.43   0.000    -.1566888   -.1402638
                    ----------------------------------------------------------------------------------
                    
                    . di (exp(_b[101.time#c.treatment])-1)*100
                    -13.823273

                    Comment


                    • #25
                      This makes a lot of sense. Thank you so much Fei Wang for your explanations and patience! You have helped me out tremendously!

                      Comment

                      Working...
                      X