title: How to analyze data with a binary response and two categorical variables in R
body: <p>I have a set of data with a binary response (0 and 1) and two categorical variables (one with two levels and the other with four levels).</p>
  
  <pre><code>library(data.table)
  
  data&lt;-data.table(Factor1=rep(c("A","B","C","D"),each=36),
                   Factor2=rep(c(rep("Red",18),rep("Blue",18)),4),
                   Response=rep(c(rep(1,11),rep(0,7),rep(0,18)),4))
  </code></pre>
  
  <p>I´ve trying to analize this with with <code>glm()</code> but I'm not sure is the best way.</p>
  
  <pre><code>model&lt;-glm(Response~Factor1+Factor2,family = binomial(),data=data)
  summary(model)
  
  Call:
  glm(formula = Response ~ Factor1 + Factor2, family = binomial(), 
  data = data)
  
  Deviance Residuals: 
   Min        1Q    Median        3Q       Max  
  -1.37438  -0.00008  -0.00008   0.99245   0.99245  
  
  Coefficients:
                Estimate Std. Error z value Pr(&gt;|z|)
  (Intercept) -1.957e+01  1.267e+03  -0.015    0.988
  Factor1B     8.942e-15  6.838e-01   0.000    1.000
  Factor1C     7.681e-15  6.838e-01   0.000    1.000
  Factor1D     7.345e-15  6.838e-01   0.000    1.000
  Factor2Red   2.002e+01  1.267e+03   0.016    0.987
  
  (Dispersion parameter for binomial family taken to be 1)
  
  Null deviance: 177.264  on 143  degrees of freedom
  Residual deviance:  96.228  on 139  degrees of freedom
  AIC: 106.23
  
  Number of Fisher Scoring iterations: 18
  </code></pre>
  
  <p>According to this, none of the coefficients are significant. But I see the data and evidently there is a difference between "Red" and "Blue".</p>
  
  <pre><code>data[,sum(Response),by=c("Factor1","Factor2")]
  
     Factor1 Factor2 V1
  1:       A     Red 11
  2:       A    Blue  0
  3:       B     Red 11
  4:       B    Blue  0
  5:       C     Red 11
  6:       C    Blue  0
  7:       D     Red 11
  8:       D    Blue  0
  </code></pre>
  
  <p>I was expecting that the coeffcient Factor2Red was significant but it was not that way. I think that maybe is because of the high estandard error for this coefficient.</p>
  
  <p>If I check the odds ratio I see that the value for this coefficient is very high. But I do not know if that's enough to say that there is a significant effect of being red or blue.</p>
  
  <pre><code>exp(cbind(coef(model)))
  
                      [,1]
  (Intercept) 3.181005e-09
  Factor1B    1.000000e+00
  Factor1C    1.000000e+00
  Factor1D    1.000000e+00
  Factor2Red  4.940037e+08
  </code></pre>
  
  <p>Would you recommend another way to analyze this?</p>