Search code examples
reventslogistic-regressiontrial

Looking for resources for help modeling logistic regression with an event/trial syntax in R?


I am modeling bird nesting success and my advisor wants me to use event/trials syntax in R to model the amount of eggs that hatched vs the total amount of eggs per nest (i.e. the event/trials) against a variety of predictor variables - using essentially the logistic regression format.

This is totally new to me, so any online resources or code help would be incredibly useful! Thank you!

Haven't tried much yet, can't find the resources! I can only find info for SAS.


Solution

  • When specifying a logistic regression with glm(), the response can be specified multiple different ways. One is as a two-column matrix, first column is number of successes, second is number of failures.

    So if you have two variables, total_eggs and hatched, try

    mod <- glm( cbind(hatched, total_eggs-hatched) ~  x + ..., 
                data=your_data_frame, family=binomial)