title: Contingency table on logistic regression in R with missing fitted values
body: <p>In my R logistic regression in R, I am trying to create a contingency table comparing fitted to observed values (i.e. 0 or 1 actual vs. 0 or 1 fitted value). However, my data has missing values in various rows of various variables, hence the fitted value vector is of a shorter length than the original data set. Here is an example:</p>
  
  <pre><code>test &lt;- data.frame(male=c(1,0,1,0,0,1,1,0,1,0,0,1), 
                   height=c(58,100,NA,19,20,69,58,24,46,19,97,69))
  
  model &lt;- glm(male~height, family=binomial("logit"),data=test)
  
  check_model &lt;- table(test$male,fitted.values(model)&gt;0.5)
  </code></pre>
  
  <blockquote>
    <p>Error in table(test$male, fitted.values(model) > 0.5) : 
      all arguments must have the same length</p>
  </blockquote>
  
  <p>Does anyone know of a way to feed in the actual values (test$male) only in rows where the model has a <code>fitted.value</code> that is not <code>NULL</code>?</p>