Logistic regression - cbind command in glm

Eddie picture Eddie · Feb 2, 2012 · Viewed 10.7k times · Source

I am doing logistic regression in R. Can somebody clarify what is the differences of running these two lines?

1. glm(Response ~ Temperature, data=temp, 
                    family = binomial(link="logit"))
2. glm(cbind(Response, n - Response) ~ Temperature, 
                    data=temp, family =binomial, Ntrials=n)

The data looks like this: (Note : Response is binary. 0=Die 1=Not die)

Response  Temperature
0         24.61
1         39.61
1         39.50
0         22.71
0         21.61
1         39.70
1         36.73
1         33.32
0         21.73
1         49.61

Answer

James picture James · Feb 2, 2012

When doing the binomial or quasibinomial glm, you either supply a probability of success, a two-column matrix with the columns giving the numbers of successes and failures or a factor where the first level denotes failure and the others success on the left hand side of the equation. See details in ?glm.