# Categorical independent variables and binary dependent variable? GLM?

I've done a literature review. The variable treat takes only TRUE and FALSE values. It says whether they applied a given treatment in a given article. I want to know if the probability of applying the treatment changes depending on the journal and on the article.type. By the way, I should say that all journals do not have the same frequency of article type.

Here is a data to use as an example:

df = data.frame ( treat=c(T,F,T,T,F,T,T,T,F,T,T,T,T,F,T,T,F,T,F,T,T,T,F,F),
journal=rep(c('a','b','c'),8),
article.type=c('a','b','c','a','b','a','a','b','c','a','a','b','c','a','c',
'a','a','a','b','a','c','a','a','c')
)


First question:

What statistics test should I use ?

I thought of using GLM (generalized linear model) with a binomial error distribution. Does it seem good to you ?

summary(glm(treat~journal*article.type, data=df, family='binomial'))

Coefficients: (1 not defined because of singularities)
Estimate Std. Error z value Pr(>|z|)
(Intercept)             1.957e+01  4.390e+03   0.004    0.996
journalb               -1.997e+01  4.390e+03  -0.005    0.996
journalc                8.429e-09  8.781e+03   0.000    1.000
article.typeb          -3.913e+01  1.162e+04  -0.003    0.997
article.typec           4.134e-08  1.162e+04   0.000    1.000
journalb:article.typeb  3.884e+01  1.162e+04   0.003    0.997
journalc:article.typeb  3.913e+01  1.756e+04   0.002    0.998
journalb:article.typec         NA         NA      NA       NA
journalc:article.typec -1.916e+01  1.388e+04  -0.001    0.999


When running this, I get several p-values per variable. One p-value for "article.typeb" and one for "article.typec" for example. What does it mean ?

• treat is binary (Boolean) and your response or dependent variable. That being so, your title was the wrong way round. – Nick Cox Jul 18 '13 at 13:48
• Remi.b: Your dataset doesn't work: the variable article.type has 27 elements whereas the other two variables have only 24. – COOLSerdash Jul 18 '13 at 14:05
• I'm sorry about the mistakes. I thought I checked my code. I corrected it. Thank you – Remi.b Jul 18 '13 at 14:38

Regarding your second question, article is categorical so that R automatically defines several “dummy” variables (other codings are possible), making articles of type A the “reference category”. The coefficient and test for article.typeb represents the difference between articles of type A and articles of type B, the coefficient for article.typec represents the difference between article of type A and articles of type C, same thing for other categorical variables, interaction terms, etc.