Different grouping factors (populations, species, sites, …)
Sample sizes may be small …
… especially if we try to fit complicated models with many parameters
Data points might not be truly independent
is useful
but how do we use it?
but: decrease sample size
and: multiple comparisons
m <- glm(y ~ x + species)
m <- glm(y ~ x + species)
We just want to account for average differences among species
i.e., control for the variation coming from species
Allow us to
deal with messy data
use all our data, even when we have low sample sizes, structured data, and many covariates to fit
include these random effects
It depends …
the data
the question/a
Variables can be either, or both!
Not totally agreed on: see here
variables that we expect will have a direct effect on the dependent/response variable
categorical
usually grouping factors for which we are trying to control
not specifically interested in their impact or value
usually need >5 levels
What are you trying to do?
What are you trying to make predictions about?
What is just variation (a.k.a “noise”) that you need to control for?
https://ourcodingclub.github.io/2017/03/15/mixed-models.html
http://scs.math.yorku.ca/index.php/Mixed_Models_with_R/Introduction_to_Mixed_Models
https://www.jaredknowles.com/journal/2014/5/17/mixed-effects-tutorial-2-fun-with-mermod-objects
https://www.jaredknowles.com/journal/2015/8/12/announcing-mertools
Gelman & Hill (2007) Data Analysis Using Regression and Multilevel/Hierarchical Models. webpage
Pinheiro, José C., and Douglas M. Bates. 2000. Mixed-Effects Models in S and S-PLUS. New York: Springer.
Zuur, Alain F., Elena N. Ieno, Neil J. Walker, Anatoly A. Saveliev, and Graham M. Smith. 2009. Mixed Effects Models and Extensions in Ecology with R. Springer.
Dobson, Annette J., and Adrian Barnett. 2008. An Introduction to Generalized Linear Models, Third Edition. 3rd ed. Chapman; Hall/CRC.
Faraway, Julian J. 2006. Extending Linear Models with R: Generalized Linear, Mixed Effects and Nonparametric Regression Models. Chapman & Hall/CRC.
McCullagh, P., and J. A. Nelder. 1989. Generalized Linear Models. London: Chapman; Hall.