I have a dataset ("mort") containing two variables in R. The predictor variable is Treatment (categorical, 4 categories A, B, C, D) and the response variable is mortality (denoted as 1 for died and 0 for survived). I am interested in the question, "does mortality rate differ significantly between treatments." I'm trying to run a GLM with a binomial distribution.

Below is a subset of the dataset:

ID  Treatment  Mortality
1    A         0
2    A         0
3    A         0
4    A         0
5    B         0
6    B         1
7    B         1
8    B         0
9    C         0
10   C         0
11   D         0
12   D         1

I also made a summary table to get a sense of the counts and percentage mortality per treatment, which looks like this:

Treatment    Survived  Died  Total   Percent_mort
A            38         3     41      7.32
B            29         9     38      23.68
C            39         0     39      0.00
D            76         5     81      6.17

I've read through a couple guides on GLMs and seen several different methods of setting up the data for the GLM, but I am still unclear whether I should input the raw data or the summary of counts or percentages. I have a different total sample size in each treatment so it seems like I should be dealing in percentages to reflect that.

The Crawley R book chapter on proportion data summarizes deaths and survival counts by treatment, use cbind to combine the two columns, and runs the GLM on that data. Another source ran the glm on the raw 0/1 data as shown above (example here). I am confused on what the difference is between these methods and which would be better to use here to account for my different sample sizes. I guess my main question is, should I be running the model on the raw data (0s and 1s) or the summary (counts or percents)?

I then want to perform pairwise comparisons to see which treatments are significantly different from each other.

Here is what I ran so far on the raw data:

model <- glm(Mortality ~ Treatment, family = binomial, data = mort) 


##to get a p value

##to perform post-hoc comparisons

lsmeans(model, pairwise ~ Treatment)

Any advice would be greatly appreciated. Thank you!


1 Answer 1


You can do it either way, if you're careful. You'll get the same results from

model2 <- glm(cbind(Died, Survived) ~ Treatment, 
              family = binomial, 
              data = mort_table)

where mort_table is a data frame containing the summary you show.

Or yet another option:

model3 <- glm(Percent_mort/100 ~ Treatment,
              weights = Total,
              family = binomial,
              data = mort_table)
  • $\begingroup$ Thank you very much for your help! $\endgroup$
    – mels
    Dec 15, 2022 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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