title: Inconsistent results between glm() in R and manual implementation of logistic regression in Excel
body: <p>You'll find a manual implementation of <strong>logistic regression in Excel</strong> at: <a href="http://blog.excelmasterseries.com/2014/06/logistic-regression-performed-in-excel.html" rel="nofollow noreferrer">http://blog.excelmasterseries.com/2014/06/logistic-regression-performed-in-excel.html</a>.</p>
  <p>This implementation uses the dataset below and reports the following coefficients</p>
  <blockquote>
  <p>b0 = 12.48285608</p>
  <p>b1 = -0.117031374</p>
  <p>b2 = -1.469140055</p>
  </blockquote>
  <p>However, when I analyze the same dataset with <code>glm()</code> in <strong>R</strong>, the results are not the same, i.e.:</p>
  <blockquote>
  <p>b0 = 1.687445</p>
  <p>b1 = -0.012525</p>
  <p>b2 = -0.116473</p>
  </blockquote>
  <pre><code>d &lt;- structure(list(Y = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), X1 = c(78L, 73L, 73L, 
  71L, 68L, 59L, 57L, 49L, 35L, 27L, 59L, 57L, 44L, 38L, 36L, 36L, 
  22L, 22L, 15L, 10L), X2 = c(8L, 8L, 5L, 7L, 5L, 4L, 7L, 5L, 4L, 
  7L, 3L, 4L, 5L, 5L, 4L, 2L, 6L, 5L, 4L, 6L)), .Names = c(&quot;Y&quot;, 
  &quot;X1&quot;, &quot;X2&quot;), class = &quot;data.frame&quot;, row.names = c(NA, -20L))  
  
  summary(glm(Y ~ X1+X2, data=d), family=binomial(link='logit'))
  
  
  # &gt; summary(glm(Y ~ X1+X2, data=d), family=binomial(link='logit'))
  # 
  # Call:
  #   glm(formula = Y ~ X1 + X2, data = d)
  # 
  # Deviance Residuals: 
  #   Min        1Q    Median        3Q       Max  
  # -0.78318  -0.20641   0.07689   0.24375   0.49237  
  # 
  # Coefficients:
  #   Estimate Std. Error t value Pr(&gt;|t|)    
  # (Intercept)  1.687445   0.319872   5.275 6.18e-05 ***
  #   X1          -0.012525   0.004376  -2.862   0.0108 *  
  #   X2          -0.116473   0.056959  -2.045   0.0567 .  
  # ---
  #   Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  # 
  # (Dispersion parameter for gaussian family taken to be 0.146843)
  # 
  # Null deviance: 5.0000  on 19  degrees of freedom
  # Residual deviance: 2.4963  on 17  degrees of freedom
  # AIC: 23.139
  # 
  # Number of Fisher Scoring iterations: 2
  </code></pre>
  <p>Why do the results differ?</p>