Announcement

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

  • Calculating R2 with xtpoisson

    Dear Forum Members,

    I am estimating models predicting organizational turnover counts over time using xtpoisson. The unbalanced panel includes about 8,000 organizations per year for 8 years. I have been asked to calculate R2 for my models. Stata provides a pseudo-R2 for the poisson command but not for xtpoisson. So far I have tried the following, which I used for a model using xtlogit:
    Code:
    xtpoisson y, irr pa
    local ll0 = e(ll)
    xtpoisson y x1 x2... x7, irr pa exp(z)
    local llt = e(ll)
    display "pseudo R2 t=" (`ll0' - `llt')/`ll0'
    However, when I do this Stata returns "." as the result. I'm not sure if this is an inappropriate way to calculate it in xtpoisson or my model or data have problems that prevent it from being calculated in this way. Moreover I'm not sure calculating a pseudo-R2 is meaningful in any case. I am using both population averaged and organizational fixed effects models. Any help, specific or general, is much appreciated.

  • #2
    Welcome to Statalist! Thanks for posting your example using CODE delimiters.

    I have deleted an answer previously posted. Looking at help xtpoisson we see that xtpoisson ..., pa does not return e(ll).

    My aplogies to Matt, he read my original answer while I was correcting it, but luckily it got him to the right place.
    Last edited by William Lisowski; 03 Aug 2016, 10:19.

    Comment


    • #3
      Thank you for the help. I fixed this, but the result still returned as ".". However, your response clicked something for me, and I discovered the issue.

      This code works for fixed effects and random effects models, but population averaged models do not provide a log likelihood (confirmed using the "ereturn list" command) so this method doesn't work. This leads me to two questions... this is admittedly a bit beyond my experience.
      1. Is there another way to calculate a pseduo-R2 using a population averaged model?
      2. What would be the proper specification for the null fixed effects model? Stata informs me that "independent variables required with fixed-effects model." I can figure out the change in the pseudo R2 from adding my key predictor but not the effect of all the controls.

      Once again, thank you for taking the time to read and respond.

      Comment


      • #4
        By definition, McFadden's pseudo-R2 looks at the change in (maximized) log-likelihood for the full model (L*) and the model with intercept only .(L0​).


        Code:
        Pseudo R2 = 1 - (L*/ L0)
        xtpoisson, fe does not output an intercept, and therefore you cannot estimate the model with intercept only. However, as is the case with LSDV, you can estimate a poisson model with dummy variables which will output a pseudo-R2.




        Code:
        . webuse ships
        
        . xtset ship
               panel variable:  ship (balanced)
        
        *XTPOISSON, FE
        
        . xtpoisson accident op_75_79 co_65_69 co_70_74 co_75_79, irr fe
        
        Iteration 0:   log likelihood = -120.64946  
        Iteration 1:   log likelihood = -104.89768  
        Iteration 2:   log likelihood = -104.83697  
        Iteration 3:   log likelihood = -104.83697  
        
        Conditional fixed-effects Poisson regression    Number of obs     =         34
        Group variable: ship                            Number of groups  =          5
        
                                                        Obs per group:
                                                                      min =          6
                                                                      avg =        6.8
                                                                      max =          7
        
                                                        Wald chi2(4)      =      30.48
        Log likelihood  = -104.83697                    Prob > chi2       =     0.0000
        
        ------------------------------------------------------------------------------
            accident |        IRR   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
            op_75_79 |   1.340175   .1511002     2.60   0.009     1.074463    1.671597
            co_65_69 |   1.790418   .2650797     3.93   0.000     1.339461    2.393199
            co_70_74 |   1.588491   .2402561     3.06   0.002     1.180979     2.13662
            co_75_79 |   .8227304   .1757145    -0.91   0.361     .5413302    1.250411
        ------------------------------------------------------------------------------
        
        *POISSON WITH DUMMIES
        
        
        . poisson accident op_75_79 co_65_69 co_70_74 co_75_79 i.ship, irr
        
        Iteration 0:   log likelihood = -131.31515  
        Iteration 1:   log likelihood = -118.52901  
        Iteration 2:   log likelihood =  -118.4759  
        Iteration 3:   log likelihood = -118.47588  
        Iteration 4:   log likelihood = -118.47588  
        
        Poisson regression                              Number of obs     =         34
                                                        LR chi2(8)        =     475.45
                                                        Prob > chi2       =     0.0000
        Log likelihood = -118.47588                     Pseudo R2         =     0.6674
        
        ------------------------------------------------------------------------------
            accident |        IRR   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
            op_75_79 |   1.340175   .1511002     2.60   0.009     1.074463    1.671597
            co_65_69 |   1.790418   .2650797     3.93   0.000     1.339461    2.393199
            co_70_74 |   1.588491   .2402561     3.06   0.002     1.180979     2.13662
            co_75_79 |   .8227304   .1757145    -0.91   0.361     .5413302    1.250411
                     |
                ship |
                  2  |    6.02381   1.003685    10.78   0.000     4.345546    8.350223
                  3  |   .2857143    .093522    -3.83   0.000     .1504218    .5426916
                  4  |   .4047619   .1163527    -3.15   0.002     .2304165    .7110264
                  5  |    .863913   .2031718    -0.62   0.534     .5448634    1.369785
                     |
               _cons |   3.700435   .7299915     6.63   0.000     2.513823    5.447169
        ------------------------------------------------------------------------------

        Comment


        • #5
          Thank you Andrew. This sounds similar to the process I saw for using the "areg" command to get an R2 from a fixed effects linear regression using xtreg while still accounting for the variance explained fixed effects. I'll try this next.

          Comment

          Working...
          X