Playing with data

There is a very interesting dataset available on Mammalian Trophic Levels and Body Sizes that is available on figshare (click the link to go to the data). I would also link to the paper the data is from, Tucker and Rodgers (no date), but I cannot seem to find it (the title and authors are given on the figshare site). Given that I just wrote about a paper that discussed body size, ratios, and trophic levels, I thought it would be a good time to mess around with these data.

troph <- read.csv(paste(filepath, "TrophicLevel_Appendix1.csv", sep = ""))

The dataset is 211 rows by 12 columns (dim(troph)). The first column gives us the name of the taxa, in what I think is a fairly simply formatted and consistent style (Genus_species). For each taxon we are given the trophic level, mass, prey mass, and predator-prey mass ratio. We are also given information about their diet choices (carnivore/omnivore), what kind of prey they prefer (e.g., fish, zooplankton, benthic inverts. mammals, etc.), and their habitat. The last three rows specifies source information for the diet and mass information.

For my purposes I did need to clean the data up a bit as in some parts a “-” was used as the null character instead of the preferable “NA”. This means that when you use read.csv R will think that all of the data are factors.

I simply changed it to numeric and pulled out the variables I wanted to use into a new dataframe:

trophlev <- as.numeric(troph$Trophic.level)
predmass <- as.numeric(troph$
preymass <- as.numeric(as.character(troph$
ppratio <- as.numeric(as.character(troph$Predator.Prey.ratio..log10.))

troph2 <- data.frame(Diet = troph$Diet, Hab = troph$Environment, TL = trophlev,
Pred = predmass, Prey = preymass, Ratio = ppratio)

Now, if you recall from the last paper review, Riede et al had three major findings:

  1. Predator mass and prey mass were positively correlated

  2. Predator mass increases with increasing trophic level

  3. Predator-prey mass ratio declines with increasing trophic level

I want to use this publicly available and easily accessible dataset to test their findings. Note that this dataset is much narrower in scope than theirs, which spanned several taxa type including invertebrates and ectotherms, while this dataset is focused solely on mammals. To analyze the data I am going to use two packages, lmodel2 for standard major axis regression, and ggplot2 for visualization.


So, given the data, how are predator and prey mass related?

g1 <- ggplot(troph2, aes(x = Pred, y = Prey)) + geom_point() + geom_smooth(method = "lm")
g1 + xlab("Log10 Predator Mass") + ylab("log10 Prey Mass")


There seems to be little to no relationship between the two.

There seems to be little to no relationship between the two.

With the linear model based trendline in there, it seems as if prey and predator mass are negatively related if anything, rather than the positive relationship found by Riede et al, and definitely not the same as the greater than unity relationship. In fact we can do some quick stats to double check.

In their paper, Riede et al. used model II regression, which for those who have long been away from (or yet to get to stats) means that we expect some error in both the x and y variables. Alternatively you can think of it as neither variable being set by the researcher (no independent variable). Ordinary least squares (OLS, or model I) regression (what is often meant when one says “regression”) assumes no error in the x variable. Anyway, we can use the package lmodel2 to do model II regression:

lmodel2(Prey~Pred, data = troph2)

Giving the output:


I haven’t gotten into too much detail about the output, but in this case what we are interested in is the Regression Results and Confidence Intervals for method 3, and mostly the slope parameter. Here we see that there is a slope of -1.28, with a 95%CI between -1.55 and -1.06. Far from the slope of 1 we were expecting.

Although, in their paper they split the data up by habitat type. We can do the same with the Tucker and Rodgers data.

g2 <- ggplot(troph2, aes(x = Pred, y = Prey)) + geom_point() + geom_smooth(method = "lm")
g2 + facet_grid(.~Hab) + xlab("Log10 Predator Mass") + ylab("log10 Prey Mass")


There is an apparent positive relationship across terrestrial pairs, but not in marine.

So when the data is split, we do get the expected positive slope from the terrestrial side. And by using lmodel2 and subsetting by troph$Hab == "Terrestrial,

lmodel2(Prey~Pred, data = troph2[troph2$Hab == "Terrestrial",])

you can see that the slope is 2.18, right in the range of what we expect based on Riede et al.’s results. On the other hand, there still does not seem to be a relationship with marine mammals.

What about the second point? Does predator mass increase with increasing trophic level?


g3 <- ggplot(troph2, aes(x = TL, y = Pred)) + geom_point() + geom_smooth(method = "lm")
g3 + xlab("Trophic Level") + ylab("log10 Prey Mass")

There certainly does seem to be a positive relationship.

There certainly does seem to be a positive relationship.

It is fairly clear that mass is increasing with trophic level, but does the pattern hold when the two habitat types are split?



When we split the data by habitat, the trend of increasing body size with trophic level disappears, something that holds true whether or not we include herbivores (herbivores are excluded in the graph on the right). It seems that in this case what was driving the pattern was the combination of habitats, and that on average marine mammals are both larger and on a higher trophic level than terrestrial mammals.

Now lets test the predictions of body mass ratios

In the first case we saw that while there was no relationship in the aggregate data, some appeared in the split data. In the last case the opposite was true. Will body mass ratio decline with trophic level, or will the pattern depend on how we look at the data? Note that in this case the herbivores will be excluded due to a lack of “prey size” data (no ratios).

g6 <- ggplot(troph2, aes(x = TL, y = Ratio)) + geom_point() + geom_smooth(method = "lm")
g6 + xlab("Trophic Level") + ylab("log10 Predator-Prey Mass Ratio")

Increasing body mass ratio with increasing trophic level.

Increasing body mass ratio with increasing trophic level.

When the data is aggregated we get the opposite of what we expected to see. From Riede’s paper, the Eltonian viewpoint should be that the body mass ratio should be independent of trophic level. The new view proposed by Riede et al. is that the ratio should decline with trophic level. The aggregated data from Tucker and Rodgers shows that there is an increasing ratio with increasing trophic level. This means that at higher trophic levels organsims are consuming comparably smaller organisms. Splitting the data by habitat type:

Again the opposite trend emerges, decreasing ratio with increasing trophic level

Again the opposite trend emerges, decreasing ratio with increasing trophic level

Based on the split data, it seems as if the positive trend in the previous plot was being driven by the fact that on average terrestrial mammals occupy a lower trophic level, and have smaller mass ratios. Likely the larger mass ratios are being driven by the inclusion of whales in the Tucker and Rodgers dataset. Terrestrial mammals have relatively few species of comparable size, coupled with the fact that whales also tend to eat small organisms (e.g., krill), which is a potential explanation for the discrepancy.

All in all, it seems that the data provided by Tucker and Rodgers may support the findings of Riede et al., if viewed in the proper context. I do wonder if there is any overlap in the datasets, although I am doubtful. The paper by Riede et al. based their analyses on data derived from a food web context, and I do not think that Tucker and Rodgers used similar methods. Without reading the original paper I can only speculate, but my guess would be that for this dataset, trophic levels came from stable isotope data or derived from the literature. Hopefully their paper (Predictors of predator-prey body size, trophic level and body mass in mammals) will come out soon as I am sure it will be interesting to see what they’ve done with it.

This entry was posted in Coding, Fun. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s