The trophic R package is a set of tools to connect trophic interaction networks with primary production estimates to predict production and biomass at all nodes in a trophic network.

key features

  • modular – develop custom model structures by linking different model components, all isolated in distinct modules

  • flexible – run multiple scenarios simultaneously using your choice of parallel architecture

  • stochastic – incorporate stochasticity into any model component, with additional modules for sensitivity analysis

more information

The examples has a set of example trophic analyses. If you’d like to contribute, check out the contributions page.

basic example

Here’s a simple example with the sample data sets included in trophic:

# load the package
library(trophic)

# create a food web object from a pre-defined interaction matrix
food_web_object <- build_food_web(interaction_matrix = food_web)

# create an efficiency object that captures transfer efficiencies among nodes
efficiency_object <- build_efficiency_matrix(efficiency_mean = efficiency_mean,
                                             efficiency_sd = 0.01)

# create a dominance object that determines the outcomes of competition for resources
dominance_object <- build_dominance_matrix(dominance = dominance_matrix)

# set some primary production values (inputs to trophic model)
primary_producers_example <- build_primary_producers(production_mean = production_mean,
                                                     production_sd = production_sd)

# collate trophic information into a single trophic_dynamics object
trophic_dynamics_object <- build_trophic_dynamics(food_web = food_web_object,
                                                  efficiency_matrix = efficiency_object,
                                                  dominance_matrix = dominance_object)

# Estimate production values from constructed trophic_dynamics object, allowing
#   stochasticity in the food web and the transfer efficiencies
production_estimates <- estimate_production(trophic_dynamics_object,
                                            primary_producers_example,
                                            stochastic = c("food_web", "efficiency"))
                                            
# estimate biomass from production using a deterministic or stochastic production-
#   biomass ratio
test_pb_ratio <- build_pb_ratio(range = c(0.25, 5.75),
                                type = "fixed")
biomass_estimates <- estimate_biomass(production_estimates,
                                      test_pb_ratio)