title: Predict response vs manual for logistic regression probability
body: <p>I am trying to manually calculate the probability of a given x with logistic regression model.</p>
  <p>my model looks like this <strong>fit2 &lt;- glm(ability~stability, data = df2)</strong></p>
  <p>I created a function that gives me the response:</p>
  <pre class="lang-r prettyprint-override"><code>estimator &lt;- function(x){
    predict(fit2, type = &quot;response&quot;, newdata = data.frame(stability=x))
  }
  </code></pre>
  <p>this function gives me 0.5304603 for the value x=550</p>
  <p>then i create the manual version. For this i use the function <code>p = e^(B0+B1*x)/(1 + e^(B0+B1*x))</code></p>
  <p>so our code will look like this</p>
  <pre class="lang-r prettyprint-override"><code>est &lt;- function(par, x){
    x = c(1,x)
    exp(par%*%x)/(1+exp(par%*%x))
  }
  </code></pre>
  <p>where par = fit2$coefficients, x = 550</p>
  <p>but this code returns 0.6295905</p>
  <p>Why?</p>
  <p>edit:</p>
  <pre><code>summary(fit2):
  Call:
  glm(formula = ability ~ stability, data = df2)
  
  Deviance Residuals: 
       Min        1Q    Median        3Q       Max  
  -0.78165  -0.33738   0.09462   0.31582   0.72823  
  
  Coefficients:
               Estimate Std. Error t value Pr(&gt;|t|)   
  (Intercept) -1.531574   0.677545   -2.26  0.03275 * 
  stability    0.003749   0.001229    3.05  0.00535 **
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  (Dispersion parameter for gaussian family taken to be 0.1965073)
  
      Null deviance: 6.7407  on 26  degrees of freedom
  Residual deviance: 4.9127  on 25  degrees of freedom
  AIC: 36.614
  
  Number of Fisher Scoring iterations: 2
  </code></pre>