Solved – Why does a binomial glm give negative predictions

binomial distributiongeneralized linear modelr

I'm using count data in quite a simple way, but I cannot understand how a binomial glm can return negative predictions

example code, where count of successes increases with responce variable:

    suc=c(1:10)
    fail=c(10:1)
    predict(glm(cbind(suc,fail)~c(1:10),family=binomial))

which results in:

    -1.9974174 -1.5535469 -1.1096763 -0.6658058 -0.2219353  0.2219353  0.6658058 1.1096763  1.5535469  1.9974174 

I don't understand this: how can a binomial model give these predictions? It should be integer positive predictions, no?

Best Answer

Assuming that you are using the predict.glm() from the stats package.

A quote from the manual, under the entry explaining the type parameter:

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 instead, try the following:

predict(glm(cbind(suc,fail)~c(1:10),family=binomial), type="response")