How to test whether there is a significant (general) within group trend with data from many groups I am having trouble identifying the correct statistical method for the following problem:
I have data on a characteristic (e.g. body length) from several individuals per species, distributed in an altitudinal gradient. Just looking at the data, I can see that for most species body length gets bigger with altitude (alas with different slopes), while for a few it decreases. The question is, is there a significant "general" trend? I would expact a result such as: On average body length significantly increases within species with a slope of 1 (by 1mm per 1 km altitude). The species don't belong to different groups, i.e. I don't want to test for differences in slopes of different groups, but rather if the "average" slope I get is significant.
Concerning my data structure, I have a total of about 40 spieces, whereby no species was found in the full altitudinal gradient (and some had a bigger and others a smaller extend). For about 30 species I have very limited data (only about 4 - 5 individuals per species), while for about 10 species I have more data (10 - 30 individuals). Thus it would be helpfull if the model would give more confidence to slopes of species were more individuals were meassured.
I am thinking of using a linear mixed model with randome slope, but I am having trouble understanding it in detail, so I am unsure... What would the appropiate model be, and why? To make this point very clear: This is a question about interpretation: Which model can I use to be able to interprete the output as an within species trend?
Also, should I rather exclude the species with limited data and only focus the inference on the species with more data (but having many species is in itself a kind of replication, right)? I am asking this, because I am unsure if the model can handle slopes that are based on little data, or if there is any other statistical reason not to include it.
Here is an example of how the data looks like (simplified: the altitude is contiouse, and I have more species):

Thanks!
 A: I'm not sure of a statistical method, however, in cases where you're looking at a ton of different features and you're exploring, you might start with plotting it using a multiplot/pair grid/facet grid. Comparing each feature to each other with scatterplots and histograms before you search for a method - you mentioned LMM but your data may not be linear. Below is an example of a multi-plot used to plot pairwise relationships (in this case for species of flowers).

As for exclusion of species, that depends on what features are important or if the species themselves are important. Are the species part of a group that has a common trait? Is the missing data going to skew that trait or will the omission skew other traits? Do you make them null or fill in the missing information somehow?
If you do find that your data are linear, then LMM may be appropriate.
A: HMaximus brilliant mention of the Simpson's paradox helped me figure out what term I need to use to search for an answer to my own question. So, for those who might stumble upon this question, you might want to have a look at this very well written paper by Pol & Wright 2009:
A simple method for distinguishing within- versus between-subject
effects using mixed models
Basically, using linear mixed models with randome intercept, the within- and between-species effect have to be seperated by performing 'within group centering' (substracting the average x of each group from each observation of x in that group), and by subsequently including these, as well as the group mean, as new predictor variables. The paper does explain it a lot better, so have a look there for details.
