*I have added a new example here for clarity, see original question below*

Eg. I have 10 schools in 5 countries, ten students from each school is sampled.

Prediction variables: student test marks for Language, Math and Science
 Response variable: school fee

I want to know what subject (ie Math) correlates with the schools fees.

lmer(fees~math+language+science+(1|country/school)) \*each row is a student

But now I have the same fees for students within the same school, and school is added as a random effect. Is this allowed? Should I just take the average subject marks per school and drop the school random effect? *See original question below*

---

I have a dependent variable that depends on one of my random effects, as such:

```
Dep   R1   R2   X1   X2   X3
30    a    g    4    43   21
30    a    g    7    46   18
20    b    g    5    31   22
20    b    g    4    37   17
60    c    h    9    50   26
60    c    h    7    34   21

lmer(Dep~X1+X2+X3+(1|R2/R1))   (R2=Genus, R1=Species)

```

I need the random effect, as I have independent data for each specimen, but I know this setup cannot be correct. Plus some of my models fail to converge. I can use the average values of traits for each R1 and then drop the R1 random effect, but then I lose lots of data.

Can I use a linear mixed effects model for this? or should I be using another technique?

---

I have since decided to use a phylogeny with a PGLS, because taxonomic level random effects are too rough.

At the moment I am looking into pgls.Ives in phytools to account for within species level variation (see **Helmus, M. R., Bland, T. J., Williams, C. K., & Ives, A. R. (2007). Phylogenetic measures of biodiversity. The American Naturalist, 169(3)**).