0

this is a fairly basic question, but I have spent all day trying to figure it out (including reading other questions on this page), and I could really use some help.

I am trying to run a simple mixed model with one random effect nested under a one fixed effect. In short, I have two study sites with multiple activity measurements (i.e., repeated measures) for individuals at each site. So "activity" is my response, "site" is a fixed effect factor, and "individual" is a random effects factor that is nested under site (i.e., each individual is present at only one site, but I have multiple data points for each individual). I have tried to use the following line of code, but I am not convinced that I am doing it correctly.

result <- lme(activity~site+individual,data=table1,random=~1|individual/site)

Specifically, my questions are as follows:

First, do I need to specify individual both in the second term of the model and in the final term? If I am understanding correctly, the second term specifies the fixed effects, and the final term specifies the random effects, so listing "individual" in both places seems incorrect, but if I don't do that, then I do not get any output for individual.

Second, for nesting terms, my initial impression was that you always started with the higher order terms (e.g., "site/individual" would nest individual within site), but if I do that with these data, I get error messages and NaN values. So, do I list individual/site or site/individual?

Third, since the nesting term is listed as the random term, will that make the model run with both individual and site as random effects? I need to make sure that the model retains site as a fixed effect, while including individual as a random effect.

Thank you for the help

Edit: it was pointed out to me that my question may be a duplicate of a previous question (Order of nested random effects in lme4); however, that question ended up not using a nested design, thus the nesting issues that I am asking about were never resolved. Thanks again.

yt1300
  • 1
  • 2
  • Did tou try result –  Oct 25 '15 at 07:36
  • fcop, I'm not sure that I understand exactly what your lines of code do. Could you please elaborate for me? They produce identical P values, errors, etc. to the code that I have been trying. I guess my main concerns here are really just how do I keep site as a fixed effect while specifying individual as a random effect, and what order I need to use to specify that individual is nested under site. Thanks. – yt1300 Oct 26 '15 at 04:03

0 Answers0