1
$\begingroup$

I've got a problem while trying to specify the 'right' nesting of the random effects of my dataset. The dataset registers hourly variations in temperature inside termite mounds:

  1. Sampling was performed in four localities, differing in soil composition.
  2. On each locality, ~20 termite mounds were sampled.
  3. The temperature of each termite mound was registered every hour during a day.

So, 24 data, per mound, in four localities. According to this previous question, to study how temperatures changes within mounds and among localities, I drew my model as:

Tmodel <- lmer(Temperature ~ Hour + Locality + (1|Locality/Mound/Hour), Tver, REML=FALSE)    

and I got this message:

Error in checkNlevels(reTrms$flist, n = n, control) : 
number of levels of each grouping factor must be < number of observations  

From this message, I get that I'm sort of 'constraining' my data, so that per grouping factor (hour, in mound, in locality), there is just one observation; am I right? But then, how should I specify the nestedness of my random factors?

$\endgroup$
8
  • 1
    $\begingroup$ What is "locality"? Are you interested in differences between localities (do you have a priori hypotheses about what these differences might be?), or is it just increasing your sample size from 20 mounds to 80 mounds? $\endgroup$
    – amoeba
    Commented Jun 14, 2017 at 20:42
  • 1
    $\begingroup$ Hi, amoeba, thanks for the input. The four localities in which the termite mounds were sampled differ in soil composition, what ultimately could modify the thermoregulatory properties of the mounds. So 'yes', we had the a priory hypothesis that "Locality" would affect mound temperature. $\endgroup$ Commented Jun 14, 2017 at 20:47
  • $\begingroup$ OK. Then locality is a fixed effect, as well as hour. You have only one random effect - mound, and so you don't have any "nested random effects" at all. Try Temperature ~ Hour + Locality + (1|Mound). This formula assumes that Mound is coded such that mounds from different localities have different ids. If this is not the case (e.g. you have mounds 1 to 20 in locality #1 and then again mounds 1 to 20 in locality #2), then you should use Temperature ~ Hour + Locality + (1|Locality:Mound). $\endgroup$
    – amoeba
    Commented Jun 14, 2017 at 20:52
  • $\begingroup$ (And it would probably make more sense to model the dependency on Hour via polynomials or splines, taking its circular nature into account, but this is another issue.) $\endgroup$
    – amoeba
    Commented Jun 14, 2017 at 20:56
  • $\begingroup$ Thank you very much by the interest you're taking in my problem. I get now that 'Locality' could be considered a fixed factor, but still... I don't see it clear: I'm using mixed models to account for the longitudinal nature of the hourly data. Then, I cannot see how my dataset is conceptually different of that of 'sleepstudy' (lme4.r-forge.r-project.org/lMMwR/lrgprt.pdf - page 57 onwards). There, days are nested within subjects (Days|Subject), so why shouldn't I nest hours within termite mounds (Hour|Mound)? $\endgroup$ Commented Jun 15, 2017 at 8:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.