0
$\begingroup$

I want to run a GLM to answer a few questions about differences in diet between sex and calendar year.

Questions:

  1. Does frequency of occurrence (FO) of pieces eaten differ between sex or year?
  2. Does number of pieces eaten (num.eaten) differ between sex or year?
  3. 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.

$\endgroup$
1
$\begingroup$

It's a good start with the hypotheses and models. The choice of model really boils down to what we know a priori about the distributions. But two important things to keep in mind:

  1. We don't choose GLM specifications deterministically based on the probability model of the response. For instance, if a response is binary, we can fit any model we choose. If I choose a logistic regression, my effect estimate is an odds ratio. If I fit a quasipoisson regression to a binary response, the effect estimate is a risk ratio (a more conservative and accurate effect to report). If I fit a linear regression, or a binomial model with identity link, my effect estimate is a risk difference.

  2. It's useless to inspect the univariate distribution of the response and conclude what the distribution is. In other words, the point of regression modeling is to "subtract off" the conditional effects of regressors and characterize the residuals in a useful way...

So where does that leave us? Focusing on the data and the questions you are trying to answer. Everything you propose is reasonable and would be acceptable in a journal. The only comment I have is that for "mass eaten" when the animal eats nothing, the mass is set to NA and not to 0. It's important to mention that "conditional" when interpreting the results.

$\endgroup$
1
  • $\begingroup$ Thank you! I will change the NA values to zeros for mass eaten, they should be zeros in this case. 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. $\endgroup$ – jl748795 Jan 28 '20 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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