0
$\begingroup$

I need some help with a mixed effects model in R. I want to know if there is any effect of month on home range size. The following is my set-up and an idea of how it is laid out in an excel sheet: I have 2 parks that I have home range estimates from (labeled parks 1 and 2). There are 6 individuals in each park (individuals 1-6 in park 1 and individuals 7-12 in park 2). There are 2 years worth of data (years 1 and 2), so for each month, each individual should have two home range estimates (one for year 1 and one for year 2).

I know "ID" should be a random effect, and I currently have "park","year", and "month" as fixed effects. My first thought is that "Park", "year" and "month" should all be crossed, but I am lost as to where "ID" is nested.

I have the following in R:

lme4(Homerangesize~(park/year/month)+(1/ID))

How do i "fix" this bit of code so that it represents my experimental set up?

$\endgroup$
1
$\begingroup$

I think your issue comes from not using |

for example, it seems like it should be 1|ID in your case. / should only be used after the | in your line of code. I'm using this for reference and extra detail. https://stats.stackexchange.com/questions/228800/crossed-vs-nested-random-effects-how-do-they-differ-and-how-are-they-specified

To further answer actually, I think this might work for you to keep park year and month crossed.

lme4(Homerangesize~(1|park/year/month)+(1|ID))
| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

Within the "nlme" package there is a function entitled lme(). This function contains a "random" argument which allows you specify the random effect. Seems to me that your code could easily be manipulated to...

lme(Homerangesize~park+year+month, random = ~1|ID)
| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks! In your code though, are park, year, and month considered as crossed effects? $\endgroup$ – StephD Jun 20 '18 at 19:39
  • $\begingroup$ No but the syntax would be the same in the lme() function. lme(Homerangesize~(park/year/month), random = ~1|ID) Hope that solves the issue. $\endgroup$ – Malcolm Wells Jun 20 '18 at 19:47
  • $\begingroup$ I'm pretty sure nlme::lme doesn't do crossed random effects very well - that was one of the motivations for lme4::lmer. I found this post stackoverflow.com/questions/36643713/… where Ben Bolker describes a method to "trick" lme into crossed random effects, but if you're looking for crossed, I'd stick with lme4. $\endgroup$ – Melissa Key Jun 20 '18 at 20:12

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.