6
$\begingroup$

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?

$\endgroup$
12
$\begingroup$

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")
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.