6
$\begingroup$

I am running a logistic regression model in r programming and wanted to know the goodness of fit of it since the command does not give out the f-test value as in the linear regression models.

So I used the following command:

summary( glm( vomiting ~ age, family = binomial(link = logit) ) )

# Call:
# glm(formula = vomiting ~ age, family = binomial(link = logit))

# Deviance Residuals:
#    Min       1Q   Median       3Q      Max 
# -1.0671  -1.0174  -0.9365   1.3395   1.9196 

#  Coefficients:
#               Estimate Std. Error z value Pr(>|z|)   
#  (Intercept) -0.141729   0.106206  -1.334    0.182   
#  age         -0.015437   0.003965  -3.893 9.89e-05 ***
#  ---
#  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' '

#  (Dispersion parameter for binomial family taken to be 1
#  Null deviance: 1452.3  on 1093  degrees of freedom
#  Residual deviance: 1433.9 on 1092  degrees of freedom

#  AIC: 1437.9
#  Number of Fisher Scoring iterations: 4

Then I run the following which I got some idea from someone else and get:

 1-pchisq(1452.3-1433.9, 1093-1092)
 # [1] 1.79058e-05

May I know in detail what the null hypothesis and alternative hypothesis are and what this 1.79058e-05 value means in this case?

$\endgroup$
16
  • 3
    $\begingroup$ I suggest to use the Hosmer-Lemeshow goodness of fit test for logistic regression which is implemented in the ResourceSelection library with the hoslem.test function. See: thestatsgeek.com/2014/02/16/… $\endgroup$ Commented Oct 22, 2017 at 9:32
  • 2
    $\begingroup$ I agree with @RuiBarradas. The test that you are using is not a goodness-of-fit test but a likelihood ratio test for the comparison of the proposed model with the null model. P=1.79058e-05 means that the fit of your model is significantly better than the fit of the null model $\endgroup$ Commented Oct 22, 2017 at 14:38
  • 3
    $\begingroup$ Like @MarcoSandri says, your model is significantly better than the model vomiting ~ 1, which is basically a computation of the means. Read the link I've provided you with. $\endgroup$ Commented Oct 22, 2017 at 15:40
  • 2
    $\begingroup$ @Eric No. If you want to make a goodness-of-fit test on your logistic regression model, use the Hosmer-Lemeshow test: en.wikipedia.org/wiki/Hosmer%E2%80%93Lemeshow_test The test statistic asymptotically follows a chi-square distribution. $\endgroup$ Commented Oct 22, 2017 at 17:05
  • 1
    $\begingroup$ @Eric The Hosmer–Lemeshow test determine if the differences between observed and expected proportions are significant. If your p is greater than 0.05, than you can say that you have a good fit. $\endgroup$ Commented Oct 22, 2017 at 17:24

1 Answer 1

3
$\begingroup$

I suggest to use the Hosmer-Lemeshow goodness of fit test for logistic regression which is implemented in the ResourceSelection library with the hoslem.test function. See: thestatsgeek.com/2014/02/16/ - Marco Sandri

But as @kjetilbhalvorsen points out below, Frank Harrell disagrees:

The Hosmer-Lemeshow test is to some extent obsolete because it requires arbitrary binning of predicted probabilities and does not possess excellent power to detect lack of calibration. It also does not fully penalize for extreme overfitting of the model. Better methods are available such as

Hosmer, D. W.; Hosmer, T.; le Cessie, S. & Lemeshow, S. A comparison of goodness-of-fit tests for the logistic regression model. Statistics in Medicine, 1997, 16, 965-980

Their new measure is implemented in the R rms package.

$\endgroup$
3
  • 4
    $\begingroup$ I've copied this comment by @MarcoSandri as a community wiki answer because the comment is, more or less, an answer to this question. We have a dramatic gap between answers and questions. At least part of the problem is that some questions are answered in comments: if comments which answered the question were answers instead, we would have fewer unanswered questions. $\endgroup$
    – mkt
    Commented Aug 19, 2018 at 11:53
  • 4
    $\begingroup$ Please see this answer stats.stackexchange.com/questions/18750/… by Frank Harrell for diverging opinion! He seems to think Hosmer-Lemeshow is obsolete $\endgroup$ Commented Aug 31, 2018 at 8:35
  • 2
    $\begingroup$ @kjetilbhalvorsen Thanks, edited to include that disagreement. $\endgroup$
    – mkt
    Commented Aug 31, 2018 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.