I want to run a GLM to answer a few questions about differences in diet between sex and calendar year.
Questions:
- Does frequency of occurrence (FO) of pieces eaten differ between sex or year?
- Does number of pieces eaten (num.eaten) differ between sex or year?
- Does mass of pieces eaten (mass.eaten) differ between sex or year?
Example of data
table <- "year species age sex num.eaten mass.eaten FO
1 2000 AB adult f 10 0.23 1
2 2000 AB adult m 0 NA 0
3 2001 AB adult f 0 NA 0
4 2001 AB adult m 2 0.01 1
5 2001 AB adult f 6 0.12 1
6 2011 AB adult m 5 0.01 1
7 2011 AB adult m 5 0.06 1
8 2011 AB adult f 20 0.28 1
9 2011 AB adult m 14 0.36 1
10 2011 AB adult f 11 0.46 1"
df <- read.table(text=table, header = TRUE)
df
Attempt
For the first question, frequency of occurrence (FO) has binary data, where 0 = no pieces eaten and 1 = 1 or more pieces eaten.
For this, I am unsure if I should run family = binomial (due to the binary data)
#Binomial example
FO.glm <- glm(FO ~ sex * year,
data = dat, family=binomial())
summary(FO.glm)
Or family = Poisson (because when aggregated by year, the counts of FO in cells is not binomial, see example "eg").
eg <- with(df, table(FO, year))
eg
#Poisson example
FO.glm2 <- glm(FO ~ sex * year,
data = dat, family=Poisson())
summary(FO.glm2)
For question 2, data are non-normal positive integers. So I assume I should use a Poisson distribution.
num.eaten.glm <- glm(num.eaten ~ sex * year,
data = dat, family=Poisson())
summary(num.eaten.glm)
For question 3, the mass values are non-normal positive decimals. So I am unsure if I should use a Poisson or Gamma distribution.
#Poisson example
mass.eaten.glm <- glm(mass.eaten ~ sex * year,
data = dat, family=Poisson())
summary(num.eaten.glm)
#Gamma example
mass.eaten.glm2 <- glm(mass.eaten ~ sex * year,
data = dat, family=Gamma())
summary(mass.eaten.glm2)
I have read various help pages on choosing a family for non-normal data (e.g. here or here), but I can't seem to wrap my head around which I should choose for each question.
Additionally, some of these forums recommend log links for Poisson and Gamma distributions, but I'm unsure if I should be using those.
Edit: Another thing: In my datasets (I have a dataset for each species), a lot of the animals did not eat, so I have a lot of zero values for FO, num.eaten and mass.eaten. Should I be using a zero-inflated GLM for this dataset? I'm not sure how to account for this in my GLM.
I am relatively new to GLM modeling, so any help/clarification would be appreciated.