1
$\begingroup$

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)).

$\endgroup$
  • 2
    $\begingroup$ It would be nice, if whoever downvoted this question would provide suggestions on specific aspects, which, in their opinion, require improvement. I don't think that this question is that badly formulated. $\endgroup$ – Aleksandr Blekh Apr 14 '15 at 9:07
  • $\begingroup$ I have still not figured this out. I guess I should take the average and condense the data to a single species per row, but then all the variation of the explanatory variables are excluded-for example, if the variation within species is high then I would expect that the models to explain much less variation? $\endgroup$ – AlexR Apr 16 '15 at 9:25
  • $\begingroup$ 1. How big is your data? 2. What is the convergence failure message you get? 3. What you mean by "I know this setup cannot be correct"? 4. Generally speaking: "(LME models) extend linear models by incorporating random effects which can be regarded as additional error terms to account for correlation among observations within the group" (Pinheiro & Bates, 2000), not because you have independent data for each speciment. (I am not the one who downvoted this but I can see his rationale...) $\endgroup$ – usεr11852 says Reinstate Monic Apr 16 '15 at 10:18
  • $\begingroup$ 1-10 specimen per species, 1-8 species per genus, 9 genera. $\endgroup$ – AlexR Apr 17 '15 at 10:50
  • $\begingroup$ 1. 10 specimen per species, 1-8 species per genus, 9 genera. 2. Model failed to converge: degenerate Hessian with 1 negative eigenvalues. 3. Response variable has no variation within species. 4. I see the misunderstanding, I mean that i have explanatory variables for each specimen but response variables only for each species- the random effects are included to account for the phylogenetic relationships (here species and genus) for these explanatory variables. Thanks for your response. $\endgroup$ – AlexR Apr 17 '15 at 11:04
1
$\begingroup$

I appreciate the school example, but for simplicity I stay with the original example, which was:

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

You make two comments

  1. 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

  2. Response variable has no variation within species

So, within each group of R1, despite variation in the fixed effects, there is no difference in the response. This may or may not be the reason why you get identifiability problems, in any case you have a very high chance to wrongly attribute variation in the response to either fixed / random effects.

To solve this issue, I would probably go with your comment 1 after all, i.e. averaging trait values. If the response doesn't change there is nothing to be learned from the within-species variability, so you are not loosing information.

However, note that then the averaged X1,X2,X3 are estimates from a distribution, and thus have an error. Error on the predictors can bias regression slopes. You should consider using a method that accounts for error-in-variable, such as a model II regression. I would think the most convenient way to do this is a Bayesian solution, see, e.g. http://mbjoseph.github.io/blog/2013/05/27/typeII/

Addition: if you desperately want to include phylogenetic information on the species-level, you could use a) PGLS (e.g. http://link.springer.com/chapter/10.1007%2F978-3-662-43550-2_5), which accounts for phylogenetic signal in the residuals, or b) some mixed model where phylogenetic distance informs the covariance structure of the random effects. An example of the latter (admittedly not exactly what you want) is Ives, A. R. & Helmus, M. R. (2011) Generalized linear mixed models for phylogenetic analyses of community structure. Ecological Monographs, Ecological Monographs, 81, 511-525.

$\endgroup$
  • $\begingroup$ Thanks for your response, I am not familiar with model II regressions but I will look into it. Is it possible to 'correct' the predictor variables for taxonomic effect prior to the modelling and then just drop the random effects while using the full dataset? $\endgroup$ – AlexR Apr 22 '15 at 12:01
  • $\begingroup$ See my modified answer $\endgroup$ – Florian Hartig Apr 22 '15 at 14:06
-1
$\begingroup$

My knowledge of mixed effects models (MEM) is rather fuzzy so far, so I will just share with you the following two nice blog post tutorials on MEM in R by Jared Knowles: "Getting Started with Mixed Effect Models in R" and "Mixed Effects Tutorial 2: Fun with merMod Objects". I hope that it's helpful.

$\endgroup$
  • $\begingroup$ Thanks for the answer, but it is not helpful. The response variable is not linked to the random effect in these example nor does it discuss this. I am still looking for an answer, it is quite a simple problem and i'm sure others have encountered it... $\endgroup$ – AlexR Apr 20 '15 at 7:42
  • $\begingroup$ @AlexR: You are welcome. Good luck with your search. $\endgroup$ – Aleksandr Blekh Apr 20 '15 at 21:35

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.