GLMM与LMER选择咨询:以时间为响应变量的动物行为研究
Hey there! Let's work through this to get you set up with the right model for your research question.
First, let's clarify a critical point for model alignment: your core question is "Do animals travel farther when they spend more time in a specific environment?" This suggests your response variable should be travel distance, with your key fixed predictor being the stay time (the minute-based variable you mentioned). If you originally framed stay time as the response, you might have the variables reversed—double-check this first, as it directly shapes how you build your model.
Now, onto the lmer vs GLMM question:
lmer()(from the lme4 package) is actually a subset of GLMMs! Specifically, it’s the linear mixed-effects model designed for when your response variable follows a normal (Gaussian) distribution. GLMM is the broader category that covers models for non-normal responses (like Poisson, Gamma, or binomial data).
Here’s how to decide which to use:
Check your response variable’s distribution
- If your response (whether stay time or travel distance) is continuous, roughly symmetric, and free of extreme right skew,
lmer()is ideal. It’s simpler to interpret and works great when assumptions hold. - If your response is heavily right-skewed (super common for time/distance data—most animals have short stays/travels, with a few long outliers), opt for a GLMM with a suitable distribution. For positive, continuous data like time, a Gamma distribution with a log link is usually a solid choice (e.g.,
glmer(your_response ~ your_predictor + (1|individual), data = your_data, family = Gamma(link = "log"))).
- If your response (whether stay time or travel distance) is continuous, roughly symmetric, and free of extreme right skew,
Your random effect is spot-on
Including individual animal as a random intercept ((1|individual)) is absolutely necessary here. It accounts for inherent behavioral differences across animals (e.g., one individual might consistently travel farther than others, regardless of stay time). If you suspect the relationship between your predictor and response varies across individuals (e.g., some animals’ travel distance increases more with stay time than others), you can add a random slope:(1 + your_predictor|individual). Start with the simpler random intercept model first, though, and only add the slope if model fit justifies it.Quick assumption checks
- For
lmer(): After fitting, plot residuals to check for normality (QQ plot) and constant variance (residuals vs fitted values). If these look off, that’s a sign to switch to a GLMM with a non-normal family. - For GLMMs: Use distribution-specific residual plots (e.g., for Gamma, check that residuals don’t show a pattern against fitted values) to ensure the model fits well.
- For
To wrap up: Start by confirming your response variable matches your research question. If it’s normally distributed, go with lmer(). If it’s skewed, use a GLMM with an appropriate distribution (like Gamma). Either way, keeping individual as a random effect is the right call to account for animal-specific variation.
内容的提问来源于stack exchange,提问作者Userbird14

