TrophicLevels {cheddar}R Documentation

Trophic levels


Functions that compute different measures of trophic level.


PreyAveragedTrophicLevel(community, include.isolated=TRUE)
FlowBasedTrophicLevel(community,, include.isolated=TRUE)
ShortestTrophicLevel(community, include.isolated=TRUE)
ShortWeightedTrophicLevel(community, include.isolated=TRUE)
LongestTrophicLevel(community, include.isolated=TRUE)
LongWeightedTrophicLevel(community, include.isolated=TRUE)
ChainAveragedTrophicLevel(community, include.isolated=TRUE)
TrophicHeight(community, include.isolated=TRUE)

TrophicLevels(community,, include.isolated=TRUE)



an object of class Community.


if TRUE then nodes for which IsIsolatedNode is TRUE are given a trophic level of 1; if FALSE then isolated nodes are given a trophic level of NA.

the name of a node property, either first-class or computed, by which to weight flow-based trophic level. Must satisfy the criteria of the properties parameters of NPS.


Trophic level is a measure of a node's ‘distance’ from the primary producers in the community and hence indicates how many steps matter, and hence energy, has been through to reach that node. Each function (with the exception of TrophicLevels) returns a vector containing a different measure of trophic level. These functions follow the definitions of Williams and Martinez (2004).

PreyAveragedTrophicLevel returns 1 plus the mean trophic level of the node's resources, using the matrix inversion method of Levine (1980) that is very fast and accounts for flow through loops. If this matrix inversion fails then there is an important problem with the network topology and the function will return a vector containing all NAs. For a food web to be energetically feasible, every node must be connected to a basal node. When the inversion fails it is because there is at least one node that has no connection to a basal node. FlowBasedTrophicLevel also implements the matrix inversion technique and uses the node property to provide an estimate of energy flow through each trophic link.

ShortestTrophicLevel, ShortWeightedTrophicLevel, LongestTrophicLevel, LongWeightedTrophicLevel and ChainAveragedTrophicLevel compute trophic level by examining the position of each node in every food chain in which it appears. ShortestTrophicLevel returns 1 plus the shortest chain length from a node to a basal species. ShortWeightedTrophicLevel returns the average of ShortestTrophicLevel and PreyAveragedTrophicLevel. LongestTrophicLevel is the longest chain length from each node to a basal species. LongWeightedTrophicLevel is the average of LongestTrophicLevel and PreyAveragedTrophicLevel. ChainAveragedTrophicLevel is 1 plus the average chain length of all paths from each node to a basal species. These five functions each enumerate every unique food chain (using TrophicChainsStats), which can be lengthy for complex food webs. If more than one of these five measures of trophic level is required, it will be faster to use the TrophicLevels convenience function, which enumerates unique food chains only once and returns a matrix containing every measure of trophic level in columns ‘ShortestTL’, ‘ShortWeightedTL’, ‘LongestTL’, ‘LongWeightedTL’, ‘ChainAveragedTL’, ‘PreyAveragedTL’ and, if is given, ‘FlowBasedTL’.

Jonsson et al (2005) defined ‘trophic height’ to be the same as Williams and Martinez' (2004) chain-averaged trophic level so TrophicHeight is a synonym for ChainAveragedTrophicLevel.

All methods will return a vector containing all NAs if no nodes are basal i.e., all nodes are cannibalistic or ‘community’ has no trophic links.


Either a vector of length NumberOfNodes or a matrix with NumberOfNodes rows.


Lawrence Hudson and Rich Williams


Jonsson, T. and Cohen, J. E. and Carpenter, S. R. (2005) Food webs, body size, and species abundance in ecological community description. Advances in Ecological Research 36, 1–84.

Levine, S (1980) Several measures of trophic structure applicable to complex food webs. Journal of Theoretical Biology 83, 195–207.

Williams, R. J. and Martinez, N. D. (2004) Limits to Trophic Levels and Omnivory in Complex Food Webs: Theory and Data. American Naturalist 163, 63, 458–468.

See Also

IsIsolatedNode, IsBasalNode, IsCannibal, NPS, TrophicChains, NumberOfNodes, NumberOfTrophicLinks, TrophicChainsStats, PredationMatrix



# Six different measures of trophic level

# The Benguela data contains diet.fraction

# Compare prey-averaged and flow-based

[Package cheddar version 0.1-636 Index]