Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three/Four level nested random effects #68

Open
GitTFJ opened this issue May 21, 2021 · 1 comment
Open

Three/Four level nested random effects #68

GitTFJ opened this issue May 21, 2021 · 1 comment

Comments

@GitTFJ
Copy link

GitTFJ commented May 21, 2021

Is there a way to include multi-level nested random effects e.g. (in lme4 syntax) (1|time/species/site/region)?

@rdinnager
Copy link
Collaborator

I don't think the / syntax is supported in phyr (am I right on that @daijiang ?), but (1|time/species) is equivalent to (1|time) + (1|time:species). An interaction in the grouping term is also not supported by phyr I don't think (?), but you could easily construct a factor that is equivalent to time:species and use that as your grouping term, e.g (1|time) + (1|time_species), where time_species has a unique value for each combination of time and species. Likewise this could be done for each nesting level that you need, e.g. (1|time) + (1|time_species) + (1|time_species_site) + (1|time_species_site_region). In each case the variable has a single unique factor value for each combination of the grouping terms being nested. Here is a good blog post that shows three ways to code nested random effects (where the method I suggest, which should definitely work with phyr, is the third way: "implicit nesting"): https://www.muscardinus.be/2017/07/lme4-random-effects/

Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants