title: How to evaluate goodness of fit of logistic regression model using residual.lrm in R?
body: <p>I'm attempting to evaluate the goodness of fit of a logistic regression model I have constructed. Initially, it was recommended that I use the Hosmer-Lemeshow test, but upon further research, I learned that it is not as reliable as the omnibus goodness of fit test as indicated by <a href="http://www2.stat.duke.edu/~zo2/dropbox/goflogistic.pdf" rel="nofollow noreferrer">Hosmer et al</a>. It is my understanding that <code>residual.lrm</code> in the R <code>rms</code> package is the method to run the le Cessie - van Houwelingen - Copas - Hosmer unweighted sum of squares test. </p>
  
  <p>I have constructed the following model:</p>
  
  <pre><code>&gt; NEDOCModel &lt;- glm(complication ~ ultrasound + fNEDOC, family = "binomial", data = modelmain);
  &gt; summary(NEDOCModel);
  
  Call:
  glm(formula = complication ~ ultrasound + fNEDOC, family = "binomial", 
  data = modelmain, x = TRUE, y = TRUE)
  
  Deviance Residuals: 
      Min       1Q   Median       3Q      Max  
  -0.5841  -0.5812  -0.4899  -0.4899   2.0878  
  
  Coefficients:
                                Estimate Std. Error z value Pr(&gt;|z|)    
  (Intercept)                   -1.69293    0.10126 -16.719   &lt;2e-16 ***
  ultrasound1                   -0.36661    0.12514  -2.929   0.0034 **
  fNEDOCOvercrowded (140 - 200)  0.01087    0.13524   0.080   0.9359    
  
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  (Dispersion parameter for binomial family taken to be 1)
  
  Null deviance: 1765.6  on 2284  degrees of freedom
  Residual deviance: 1757.1  on 2282  degrees of freedom
  
  AIC: 1763.1
  
  Number of Fisher Scoring iterations: 4
  </code></pre>
  
  <p>where complication is a binary outcome (0 or 1), ultrasound and fNEDOC are binary predictors (0 or 1). </p>
  
  <p>Following the description (and examples) for the <code>residual.lrm</code> function, I receive the following error:</p>
  
  <pre><code>&gt; resid(NEDOCModel, "gof");
  Error in match.arg(type) : 
  
  'arg' should be one of “deviance”, “pearson”, “working”, “response”, “partial”
  </code></pre>
  
  <p>Being an amateur and relatively new to this field, I would appreciate any assistance in resolving this error and guidance in ensuring I'm properly evaluating my model. </p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT: Here's a small subset of the data:</p>
  
  <pre><code>simExample &lt;- structure(list(complication = structure(c(1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", 
  "1"), class = "factor"), ultrasound = structure(c(1L, 2L, 2L, 
  1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 
  1L), .Label = c("0", "1"), class = "factor"), fNEDOC = structure(c(1L, 
  2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 
  1L, 1L, 2L), .Label = c("Not Overcrowded (00 - 140)", "Overcrowded (140 -
  200)"), class = "factor")), .Names = c("complication", "ultrasound",
  "fNEDOC"), row.names = c(NA, 20L), class = "data.frame")
  
  View(simExample)
     complication ultrasound                     fNEDOC
  1             0          0 Not Overcrowded (00 - 140)
  2             0          1    Overcrowded (140 - 200)
  3             0          1 Not Overcrowded (00 - 140)
  4             0          0 Not Overcrowded (00 - 140)
  5             0          1 Not Overcrowded (00 - 140)
  6             0          0 Not Overcrowded (00 - 140)
  7             0          0 Not Overcrowded (00 - 140)
  8             0          1    Overcrowded (140 - 200)
  9             0          1 Not Overcrowded (00 - 140)
  10            1          0    Overcrowded (140 - 200)
  11            0          0 Not Overcrowded (00 - 140)
  12            0          1 Not Overcrowded (00 - 140)
  13            0          1 Not Overcrowded (00 - 140)
  14            0          1    Overcrowded (140 - 200)
  15            0          1    Overcrowded (140 - 200)
  16            0          1 Not Overcrowded (00 - 140)
  17            0          1 Not Overcrowded (00 - 140)
  18            0          0 Not Overcrowded (00 - 140)
  19            0          1 Not Overcrowded (00 - 140)
  20            0          0    Overcrowded (140 - 200)
  </code></pre>