title: What happens to the coefficients when we switch labels (0/1) - in practice?
body: <p>I am trying to see in practice what was explained here <a href="https://stats.stackexchange.com/questions/168637/logistic-regression-what-happens-to-the-coefficients-when-we-switch-the-labels">what happens to the coefficients once labels are switched</a> but I am not getting what is expected. Here is my attempt:</p>
  
  <p>I am using the example of natality public-use data given as an example in "Practical Data Science with R" Where the output is a logical variable that classifies new born babies if they are atRisk with levels FALSE and TRUE</p>
  
  <pre><code>load(url("https://github.com/WinVector/zmPDSwR/tree/master/CDC/NatalRiskData.rData"))
  train &lt;- sdata[sdata$ORIGRANDGROUP&lt;=5,]
  test &lt;- sdata[sdata$ORIGRANDGROUP&gt;5,]
  complications &lt;- c("ULD_MECO","ULD_PRECIP","ULD_BREECH")
  riskfactors &lt;- c("URF_DIAB", "URF_CHYPER", "URF_PHYPER",
                   "URF_ECLAM")
  y &lt;- "atRisk"
  x &lt;- c("PWGT", "UPREVIS", "CIG_REC", "GESTREC3", "DPLURAL", complications,  riskfactors)
  fmla &lt;- paste(y, paste(x, collapse="+"), sep="~")
  model &lt;- glm(fmla, data=train, family=binomial(link="logit"))
  summary(model)
  </code></pre>
  
  <p>This results to the following coefficients:</p>
  
  <pre><code>Coefficients:
                            Estimate Std. Error z value Pr(&gt;|z|)    
  (Intercept)              -4.412189   0.289352 -15.249  &lt; 2e-16 ***
  PWGT                      0.003762   0.001487   2.530 0.011417 *  
  UPREVIS                  -0.063289   0.015252  -4.150 3.33e-05 ***
  CIG_RECTRUE               0.313169   0.187230   1.673 0.094398 .  
  GESTREC3&lt; 37 weeks        1.545183   0.140795  10.975  &lt; 2e-16 ***
  DPLURALtriplet or higher  1.394193   0.498866   2.795 0.005194 ** 
  DPLURALtwin               0.312319   0.241088   1.295 0.195163    
  ULD_MECOTRUE              0.818426   0.235798   3.471 0.000519 ***
  ULD_PRECIPTRUE            0.191720   0.357680   0.536 0.591951    
  ULD_BREECHTRUE            0.749237   0.178129   4.206 2.60e-05 ***
  URF_DIABTRUE             -0.346467   0.287514  -1.205 0.228187    
  URF_CHYPERTRUE            0.560025   0.389678   1.437 0.150676    
  URF_PHYPERTRUE            0.161599   0.250003   0.646 0.518029    
  URF_ECLAMTRUE             0.498064   0.776948   0.641 0.521489
  </code></pre>
  
  <p>OK, now let us switch the labels in our atRisk variable:</p>
  
  <pre><code>esdata$atRisk  &lt;- factor(sdata$atRisk)
  levels(sdata$atRisk) &lt;- c("TRUE", "FALSE")
  </code></pre>
  
  <p>and re-run the above analysis where I am expecting to see a change in the signs of the above reported coefficients, however, I am getting exactly the same coefficients:</p>
  
  <pre><code>Coefficients:
                            Estimate Std. Error z value Pr(&gt;|z|)    
  (Intercept)              -4.412189   0.289352 -15.249  &lt; 2e-16 ***
  PWGT                      0.003762   0.001487   2.530 0.011417 *  
  UPREVIS                  -0.063289   0.015252  -4.150 3.33e-05 ***
  CIG_RECTRUE               0.313169   0.187230   1.673 0.094398 .  
  GESTREC3&lt; 37 weeks        1.545183   0.140795  10.975  &lt; 2e-16 ***
  DPLURALtriplet or higher  1.394193   0.498866   2.795 0.005194 ** 
  DPLURALtwin               0.312319   0.241088   1.295 0.195163    
  ULD_MECOTRUE              0.818426   0.235798   3.471 0.000519 ***
  ULD_PRECIPTRUE            0.191720   0.357680   0.536 0.591951    
  ULD_BREECHTRUE            0.749237   0.178129   4.206 2.60e-05 ***
  URF_DIABTRUE             -0.346467   0.287514  -1.205 0.228187    
  URF_CHYPERTRUE            0.560025   0.389678   1.437 0.150676    
  URF_PHYPERTRUE            0.161599   0.250003   0.646 0.518029    
  URF_ECLAMTRUE             0.498064   0.776948   0.641 0.521489
  </code></pre>
  
  <p>What is that am I doing wrong here? Can you help please</p>