I want to run multiple GLM's to answer a few questions about changes in diet between species and over time.
Questions:
- Does frequency of occurrence (FO) of pieces eaten differ between species or year?
- Does number of pieces eaten (num.eaten) differ between species or year?
- Does mass of pieces eaten (mass.eaten) differ between species or year?
And then I also want to answer:
- Does frequency of occurrence (FO) differ between sex of species AD in year 2000, 2001 or 2011?
- Does number of pieces eaten (num.eaten) differ between sex of species AD in year 2000, 2001 or 2011?
- Does mass of pieces eaten (mass.eaten) differ between sex of species AD in year 2000, 2001 or 2011? Then I want to answer these same questions for species CD.
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 CD adult m 2 0.01 1
5 2001 CD 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 CD adult f 20 0.28 1
9 2011 CD adult m 14 0.36 1
10 2011 CD adult f 11 0.46 1"
df <- read.table(text=table, header = TRUE)
df
Attempt
For the first 3 questions, I assumed I should do a GLM with species and year as factors, with a species * year interaction term.
For frequency of occurrence (FO), data are binary so follow a binomial distribution, thus:
FO.glm <- glm(FO ~ species * year,
data = dat, family=binomial())
summary(FO)
For num.eaten, data are counts so follow a Poisson distribution, thus:
num.eaten.glm <- glm(num.eaten ~ species * year,
data = dat, family=poisson())
summary(num.eaten)
For mass.eaten, data are also follow a Poisson distribution, thus:
mass.eaten.glm <- glm(mass.eaten ~ species * year,
data = dat, family=poisson())
summary(mass.eaten)
In the output from these 3 GLM's, I am getting p-values that range from 0.992 to 1.000 for each factor and interactions. I know there is a significant difference between some of my data (maybe not in this reproduced example, but in my real data). So I'm trying to determine what error I am making here.
In terms of questions 4-6, I cannot figure out how to run a GLM that will assess only one species at a time, and will test the difference of FO (then num.eaten, then mass.eaten) between sexes in year 2000 (then 2001, then 2011).
I am relatively new to R, and also new to GLM's. Any help/clarification would be appreciated.