Logistic regression - cbind command in glm

11,954

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.

Share:
11,954
Eddie
Author by

Eddie

Updated on August 02, 2022

Comments

  • Eddie
    Eddie almost 2 years

    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
    
  • Hong Ooi
    Hong Ooi over 12 years
    Note that when using the frequency form of a binomial glm, you should supply the number of observations per trial in the weights argument. It would look like: glm(events/n ~ x, data=*, weights=n, ...)