Announcement

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

  • How do I check goodness of fit when using "xtmlogit"?

    Hello,
    I'm trying to use "xtmlogit", a newly introduced command in stata17.
    How do I check the goodness of fit (e.g., Hosmer-Lemeshow statistics) when using "xtmlogit"?
    It would be very helpful if you could let me know.


  • #2
    The concept of goodness of fit is difficult to define for nonlinear models. Only OLS sets out to minimize the sum of squared errors which coincides with maximizing \(R^2\). However, the output of xtmlogit includes both the maximized log-likelihood from the estimated model \((L_1)\) and the log-likelihood from the model with intercept only \((L_0)\), so you can calculate McFadden's Pseudo \(R^2\) using the following formula:

    $$\text{McFadden's Pseudo}\; R^{2}= 1 - \frac{L_{1}}{L_{0}}$$

    Code:
    use https://www.stata-press.com/data/r17/estatus.dta, clear
    xtset id year
    xtmlogit estatus i.hhchild age hhincome i.hhsigno i.bwinner, fe
    ereturn list
    display "Pseudo R2= `:di %5.4f `=1-(`e(ll)'/`e(ll_0)')''"
    Res.:

    Code:
    . xtmlogit estatus i.hhchild age hhincome i.hhsigno i.bwinner, fe
    note: 80 groups (451 obs) omitted because of no variation in the outcome variable over time.
    
    Computing initial values ...
    
    Setting up 26,168 permutations:
    ....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
    
    Fitting full model:
    
    Iteration 0:   log likelihood = -2136.5919  
    Iteration 1:   log likelihood = -2136.2728  
    Iteration 2:   log likelihood = -2136.2728  
    
    Fixed-effects multinomial logistic regression        Number of obs    =  4,310
    Group variable: id                                   Number of groups =    720
    
                                                         Obs per group:
                                                                      min =      5
                                                                      avg =    6.0
                                                                      max =      7
    
                                                         LR chi2(10)      = 103.29
    Log likelihood = -2136.2728                          Prob > chi2      = 0.0000
    
    ------------------------------------------------------------------------------------
               estatus | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------------+----------------------------------------------------------------
    Out_of_labor_force |
               hhchild |
                  Yes  |   .5881852   .1258696     4.67   0.000     .3414854     .834885
                   age |  -.0003842   .0147741    -0.03   0.979    -.0293409    .0285725
              hhincome |  -.0122043   .0088464    -1.38   0.168     -.029543    .0051344
                       |
               hhsigno |
                  Yes  |   .5090034    .100111     5.08   0.000     .3127893    .7052174
                       |
               bwinner |
                  Yes  |  -.4655745   .0782841    -5.95   0.000    -.6190085   -.3121406
    -------------------+----------------------------------------------------------------
    Unemployed         |
               hhchild |
                  Yes  |    .163612   .1638934     1.00   0.318    -.1576132    .4848372
                   age |   .0063355    .019404     0.33   0.744    -.0316957    .0443667
              hhincome |   -.029742   .0120031    -2.48   0.013    -.0532676   -.0062164
                       |
               hhsigno |
                  Yes  |   .1173192   .1301364     0.90   0.367    -.1377435    .3723819
                       |
               bwinner |
                  Yes  |  -.2489958   .1030027    -2.42   0.016    -.4508773   -.0471142
    -------------------+----------------------------------------------------------------
    Employed           |  (base outcome)
    ------------------------------------------------------------------------------------
    
    
    
    ereturn list
    
    scalars:
                   e(rank) =  10
                     e(ic) =  2
                      e(k) =  16
                   e(k_dv) =  1
              e(converged) =  1
                     e(rc) =  0
                     e(ll) =  -2136.272777563178
                   e(ll_0) =  -2187.918
                   e(df_m) =  10
                   e(chi2) =  103.2904448736444
                      e(p) =  1.19385874005e-17
           e(N_group_drop) =  80
                 e(N_drop) =  451
                    e(N_g) =  720
                      e(N) =  4310
             
    
    . 
    . display "Pseudo R2= `:di %5.4f `=1-(`e(ll)'/`e(ll_0)')''"
    Pseudo R2= 0.0236

    Comment

    Working...
    X