1
$\begingroup$

I built a logistic regression in R using 6 predictor variables and the output is as shown:

  fracmodel = glm(frx ~ age + meds + weight + hip_bmd + fall_risk + tneck, 
         family = binomial(link = 'logit'), data = fracture)

  summary(fracmodel)

  Coefficients:
               Estimate Std. Error z value Pr(>|z|)    
  (Intercept) -1.782151   0.824666  -2.161  0.03069 *  
  age          0.013800   0.006251   2.208  0.02727 *  
  meds1       -0.200508   0.072979  -2.747  0.00601 ** 
  weight       0.014985   0.003543   4.229 2.34e-05 ***
  hip_bmd     -3.278159   0.675582  -4.852 1.22e-06 ***
  fall_risk1   0.219837   0.091021   2.415  0.01572 *  
  tneck       -0.150665   0.105696  -1.425  0.15402    

  (Dispersion parameter for binomial family taken to be 1)

  Null deviance: 5173.2  on 6365  degrees of freedom
  Residual deviance: 5055.7  on 6359  degrees of freedom
  (93 observations deleted due to missingness)
  AIC: 5069.7

I tried to derive MC facdden's R2 using an additional NULL model defined as below

  nullmodel <- glm(frx~1, binomial(link = 'logit'), data = fracture)
  Coefficients:
               Estimate Std. Error z value Pr(>|z|)    
  (Intercept) -1.81177    0.03581  -50.59   <2e-16 ***

 Null deviance: 5241.3  on 6458  degrees of freedom
 Residual deviance: 5241.3  on 6458  degrees of freedom
 AIC: 5243.3

 #Pseudo R2
 1- logLik(fracmodel)/logLik(nullmodel)

But if I had used the formula for R2 as R2 = 1- fracmodel$deviance/fracmodel$null.deviance I should have obtained the same answer. But I'm not.

Then I noticed that the degrees of freedom for NULL Deviance are different for the fitted model and the NULL model. There are 6459 observations. DF for NULL deviance in fitted model is 6365 but for the NULL model is 6458.

What is the reason for the variation in degrees of freedom. Which one should I use to derive MCFadden's R squared?

$\endgroup$
1
  • $\begingroup$ You seem to have data missigness issues that plague some of your predictor variables, as seen in the output for your 6-predictor variable: 93 observations deleted due to missigness. So the comparison of your intercept-only model with that of the 6-predictors model is not "fair", given the two models have different numbers of obsevations. For the comparison to be fair, you would want both models to have the same number of observations. In other words, you would have to address the data missigness issues first (e.g., multiple imputation) and then compare the models. $\endgroup$ Feb 9, 2020 at 22:54

0

Your Answer

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