fishflux logo


The fishflux package provides a tool to model fluxes of C (carbon), N (nitrogen) and P (phosphorus) in fishes. It combines basic principles from elemental stoichiometry and metabolic theory. The package offers a user-friendly interface to apply the model. fishflux is ideal for fish ecologists wishing to predict ingestion, egestion and excretion to study fluxes of elements.

Main assets:

  • Provides function to model fluxes of carbon, nitrogen and phosphorus for fishes
  • Allows for the estimation of uncertainty, dpending on the uncertainy of the input parameters
  • Provides some functions to help find parameters as inputs for the model
  • Provides functions to extract and illustrate results

Theoretical framework

For more information on the theoretical framework behind cnp_model_mcmc(), check out the paper.

Installing and loading fishflux

First, make sure your R version is 3.4 or higher and you have rtools installed.


fishflux is now available on CRAN:


Note that if you are using a linux operating system, you still need a c++ compiler to install the package from CRAN. If you are using Windows or Mac, you can install a pre-compiled binary version and thus don’t need a compiler.


Please follow these steps to install the development version of the package from Github. fishflux uses Markov Chain Monte Carlo simulations provided by stan. Therefore, the first step is to install rstan. It’s important to closely follow all the steps described on the page depending on your operating system, because rstan requires a functioning C++ compiler. Furthermore, fishflux depends on the package rstantools version 2.0.0 or higher. This means that if you already have an older version of rstantools installed, you will have to reinstall it, prior to the installation of fishflux.

Once you have your c++ compiler set up correctly, you are ready to install it from GitHub.

devtools::install_github("nschiett/fishflux", dependencies=TRUE)

Downloaded package file

Another option is to download the source file available on github here.

install.packages(path_to_fishflux_file, repos = NULL, type = "source")


See package vignette for an introduction and help pages. For more information on the theoretical model see here.


This R package is provided for use under the MIT License (MIT) by the author.


When using the bioenergetic model featured in this package, please cite:

Schiettekatte, NMD, Barneche, DR, Villéger, S, et al. Nutrient limitation, bioenergetics and stoichiometry: A new model to predict elemental fluxes mediated by fishes. Funct Ecol. 2020; 34: 1857– 1869.