# Accounting for unequal sample sizes - offset() code and which data to use

I have a set of data that contain two separate species placed in 4 habitat types. One of the species has 10 less organisms than the other for a particular habitat and I was hoping to account for the unequal sizes by using an offset() code. However, I am having trouble determining which data to input within the offset() to account for the difference.

The data is arranged by cages with 10 specimens in each and labeled with a coordinating letter for habitat and number for cage/species ID (odds are species 1 and evens are species 2). nStart is the initial amount of specimen/cage and is linked to each habitat and cage. Am I wrong in thinking that "+ offset(nStart)" will account for the missing cage? Also, does "+ offset(log(nStart))" only work for negative binomials? Thanks! Any input is appreciated

| Habitat  | Cage           || nStart   |
| I        | 6              ||  10
| I        | 7              ||  10
| L        | 6              ||  10
| O        | 7              ||  10
| O        | 8              ||  10


Model survival code:

 Model <- glmer(cbind(nAlive,nDead) ~ Species*Habitat+ (1|Cage),
data=CleanData, family="binomial")


I have tried this

 Model <- glmer(cbind(nAlive, nDead) ~ Species*Habitat +
offset(nStart) + (1|Cage), data=CleanData, family="binomial")


no luck.

Model Infestation Code:

 Model1 <- glmer(Lice01 ~ Species*Habitat+(1|Cage), data = JulyData,
family="binomial")

and I have tried this:


Model1 <- glmer(Lice01 ~ Species*Habitat+ offset(nStart) + (1|Cage), data = JulyData, family="binomial")

but still not convinced.


• In addition to @MrFlick's comment, we need a little bit more information. You haven't told us anything about your response variable, and it's important to know. What are you measuring/counting in each cage? What model/formula would you use if you weren't worried about unbalanced sampling? – Ben Bolker Jan 14 at 0:13
• @BenBolker So I am looking at survival rate of these species when infested with a parasite and whether habitat plays a role in determining infestation rate. Also, whether infestation rate differs based on habitat or if it does between species . Right now I have code set up to run a glm model and using emmeans and pairwise comparisons to look at multiple interactions. – Garrett Malone Jan 14 at 16:15
• "Model<-glmer(cbind(nAlive,nDead)~SpeciesHabitat+ (1|Cage), data=CleanData, family="binomial")" is code for the survival data. I have tried this "Model<-glmer(cbind(nAlive,nDead)~SpeciesHabitat + offset(nStart) + (1|Cage), data=CleanData, family="binomial")" and no luck. I also tried it without the random cage effect and it still was not convincing so I wanted a second opinion – Garrett Malone Jan 14 at 16:19