# Output of logistic model in R

I'm trying to interpret the following type of logistic model:

mdl <- glm(c(suc,fail) ~ fac1 + fac2, data=df, family=binomial)


Is the output of predict(mdl) the expected odds of success for each data point? Is there a simple way to tabulate the odds for each factor level of the model, rather than all the data points?

• Could you be more precise about what you mean by cross-tabulating the ORs? Your factors have more than two levels?
– chl
Sep 3, 2010 at 12:50
• Yes, the factors have 3 and 6 levels respectively. I'm wanting a table of what the predicted odds are for each possible combination of fac1 and fac2. Sep 3, 2010 at 13:22
• Ok, @Bernd's answer is fine with me. Maybe have a look at the Design package from Franck Harrell; it has very nice functions along lrm() for GLMs and related stuff.
– chl
Sep 3, 2010 at 14:52

The help pages for

predict.glm


state: "Thus for a default binomial model the default predictions are of log-odds (probabilities on logit scale) and ‘type = "response"’ gives the predicted probabilities". So, predict(mdl) returns the log(odds), and using "type = "response" returns the predicted probabilities. You might find this toy example instructive:

> y <- c(0,0,0,1,1,1,1,1,1,1)
> prop.table(table(y))
y
0   1
0.3 0.7
> glm.y <- glm(y~1, family = "binomial")
> ## predicted log(odds)
> predict(glm.y)
1         2         3         4         5         6         7         8
0.8472979 0.8472979 0.8472979 0.8472979 0.8472979 0.8472979 0.8472979 0.8472979
9        10
0.8472979 0.8472979
> ## predicted probabilities (p = odds/(1+odds))
> exp(predict(glm.y))/(1+exp(predict(glm.y)))
1   2   3   4   5   6   7   8   9  10
0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7
> predict(glm.y, type = "response")
1   2   3   4   5   6   7   8   9  10
0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7


Regarding your second question, you might want to check out the effects-package http://socserv.socsci.mcmaster.ca/jfox/Misc/effects/index.html by John Fox; see also his JSS article "Effect Displays in R for Generalised Linear Models" (pp. 8-10).

• Excellent! This is exactly what I was looking for, thanks! Sep 3, 2010 at 14:01