title: Removing completely separated observations from glm()
body: <p>I'm doing a bit of exploratory data analysis using <code>HMDA</code> data from the <code>AER</code> package; however, the variables that I used to fit the model seem to contain some observations that perfectly determine the outcomes, an issue known as "separation." So I tried to remedy this using the solution recommended by <a href="https://stats.stackexchange.com/questions/336424/issue-with-complete-separation-in-logistic-regression-in-r">this thread</a>, yet when I tried to execute the first set of source code from <code>glm.fit()</code>, R returned an error message:</p>
  
  <pre><code>Error in family$family : object of type 'closure' is not subsettable
  </code></pre>
  
  <p>so I could not proceed any further to remove those fully determined observations from my data with this code. I am wondering if anyone could help me fix this?</p>
  
  <p>My current code is provided at below for your reference.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code># load the AER package and HMDA data
  library(AER)
  data(HMDA)
  
  # fit a 2-degree olynomial probit model 
  probit.fit &lt;- glm(deny ~ poly(hirat, 2), family = binomial, data = HMDA)
  
  # using the revised source code from that stackexchage thread to find out observations that received a warning message
  library(tidyverse)
  library(dplyr)
  library(broom)
  
  eps &lt;- 10 * .Machine$double.eps
  if (family$family == "binomial") {
    if (any(mu &gt; 1 - eps) || any(mu &lt; eps)) 
      warning("glm.fit: fitted probabilities numerically 0 or 1 occurred", 
              call. = FALSE)
  }
  
  # this return the following error message
  # Error in family$family : object of type 'closure' is not subsettable
  
  
  probit.resids &lt;- augment(probit.fit) %&gt;%
    mutate(p = 1 / (1 + exp(-.fitted)),
           warning = p &gt; 1-eps)
  
  arrange(probit.resids, desc(.fitted)) %&gt;%  
    select(2:5, p, warning) %&gt;% 
    slice(1:10)
  
  
  HMDA.nwarning &lt;- filter(HMDA, !probit.resids$warning)
  
  # using HMDA.nwarning should solve the problem...
  probit.fit &lt;- glm(deny ~ poly(hirat, 2), family = binomial, data = HMDA.nwarning)</code></pre>
  </div>
  </div>
  </p>