Announcement

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

  • Goodness of Fit for Logistic Regression

    I am running a logistic regression on a binary dependent variable. I got the following answers after applying the following code:
    Code:
     estat classification
    
    Logistic model for improved
    
                  -------- True --------
    Classified |         D            ~D  |      Total
    -----------+--------------------------+-----------
         +     |      4362          2617  |       6979
         -     |      3899          7113  |      11012
    -----------+--------------------------+-----------
       Total   |      8261          9730  |      17991
    
    Classified + if predicted Pr(D) >= .5
    True D defined as improved != 0
    --------------------------------------------------
    Sensitivity                     Pr( +| D)   52.80%
    Specificity                     Pr( -|~D)   73.10%
    Positive predictive value       Pr( D| +)   62.50%
    Negative predictive value       Pr(~D| -)   64.59%
    --------------------------------------------------
    False + rate for true ~D        Pr( +|~D)   26.90%
    False - rate for true D         Pr( -| D)   47.20%
    False + rate for classified +   Pr(~D| +)   37.50%
    False - rate for classified -   Pr( D| -)   35.41%
    --------------------------------------------------
    Correctly classified                        63.78%
    --------------------------------------------------
    
    . 
    . 
    . 
    . 
    . 
    . lroc
    
    Logistic model for improved
    
    number of observations =    17991
    area under ROC curve   =   0.6835
    
    . 
    . 
    . 
    . 
    . 
    . lfit, group(10) table
    
    Logistic model for improved, goodness-of-fit test
    
      (Table collapsed on quantiles of estimated probabilities)
      +----------------------------------------------------------+
      | Group |   Prob | Obs_1 |  Exp_1 | Obs_0 |  Exp_0 | Total |
      |-------+--------+-------+--------+-------+--------+-------|
      |     1 | 0.2610 |   419 |  430.4 |  1418 | 1406.6 |  1837 |
      |     2 | 0.3300 |   659 |  685.8 |  1634 | 1607.2 |  2293 |
      |     3 | 0.3389 |   464 |  431.3 |   817 |  849.7 |  1281 |
      |     4 | 0.4072 |   615 |  698.5 |  1255 | 1171.5 |  1870 |
      |     5 | 0.4315 |   752 |  724.4 |   969 |  996.6 |  1721 |
      |-------+--------+-------+--------+-------+--------+-------|
      |     6 | 0.4984 |   895 |  844.5 |   931 |  981.5 |  1826 |
      |     7 | 0.5227 |  1013 |  964.9 |   869 |  917.1 |  1882 |
      |     8 | 0.5948 |   969 |  995.5 |   763 |  736.5 |  1732 |
      |     9 | 0.6732 |  1230 | 1199.1 |   654 |  684.9 |  1884 |
      |    10 | 0.9740 |  1245 | 1286.7 |   420 |  378.3 |  1665 |
      +----------------------------------------------------------+
    
           number of observations =     17991
                 number of groups =        10
          Hosmer-Lemeshow chi2(8) =        43.71
                      Prob > chi2 =         0.0000
    How can I know if my model is fit or not? As my Prob > chi2 = 0.0000 but my number of observation is large, how can I interpret my goodness of fit for this?

  • #2
    Logit reports Pseudo R², which you can use. An alternative is fitstat
    Code:
    ssc install fitstat, replace
    logit ...
    fitstat
    Best wishes

    Stata 18.0 MP | ORCID | Google Scholar

    Comment


    • #3
      Thank you, I have used the code. But I am not sure how to interpret the results.
      Code:
      fitstat
      
      Measures of Fit for logit of improved
      
      Log-Lik Intercept Only:   -12410.371     Log-Lik Full Model:       -11452.652
      D(17973):                  22905.305     LR(12):                     1915.437
                                               Prob > LR:                     0.000
      McFadden's R2:                 0.077     McFadden's Adj R2:             0.076
      Maximum Likelihood R2:         0.101     Cragg & Uhler's R2:            0.135
      McKelvey and Zavoina's R2:     0.134     Efron's R2:                    0.102
      Variance of y*:                3.798     Variance of error:             3.290
      Count R2:                      0.638     Adj Count R2:                  0.211
      AIC:                           1.275     AIC*n:                     22941.305
      BIC:                     -153187.444     BIC':                      -1797.865

      Comment


      • #4
        These numbers need to be seen as relational. For example, take McFaddens R2. This means that your predictors explain about 7.7% of the variation in the dependent variable. Is this low or high? Depends on your research question and related research. I would attempt to compare with result to previous research from the literature.
        Best wishes

        Stata 18.0 MP | ORCID | Google Scholar

        Comment

        Working...
        X