Author: Willem Bonnaffé (w.bonnaffe@gmail.com)
This repository introduces a novel method, Bayesian neural gradient matching (BNGM), to improve the speed and accuracy of fitting neural ordinary differential equations (NODEs).
NODEs can be used to nonparametrically learn dynamical coupling between variables from time series data (Bonnaffe et al. 2021). However, NODEs are slow to train because we need to numerically solve the ODE system at every step of the optimisation. BNGM interpolates the time series with neural networks and fits NODEs directly to the interpolated dynamics, hence bypassing the numerical integration step.
The two main advantage of NODEBNGM are:
- faster to fit than standard NODEs
- no parametric assumptions required to estimate interactions between variables
The method involves two steps:
- interpolating the time series data with neural networks (observation model), which provides interpolated states and dynamics of the variables
- approximating the interpolated dynamics of the variables with neural networks (process model) that take as input the interpolated states
The method requires time series data, which should have one time series per variable in the system.
The outputs of the approach are:
- interpolations of the state and dynamics of the variables
- effects and contributions of each variables to the dynamics of other variables
The folder data
contains several datasets used in the manuscript:
TS_3DLV.csv
contains an artificial time series generated by a tri-trophic Lotka-Volterra ODE systemTS_AFR1-3.csv
contains experimentally replicated time series of a system with an algae, flagellate, and rotifer (Hiltunen et al. 2013)TS_HL.csv
contains the hare-lynx pelt count time series (Bonnaffe et al. 2021)TS_Ushio
contains time series of the 15 dominant species of the Maizuru bay community (Ushio et al. 2018)TS_RPS.csv
contains a rock-paper-scissor time series generated by NetLogo (https://ccl.northwestern.edu/netlogo/)
The folder manuscripts
contains all the files necessary for the manuscript and the preprint:
preprint/
folder with the latex files, figures, and scripts to compile the arXiv preprintmanuscript/
folder with the latex files to compile the manuscript, figures, and referencesmanuscript/figures/
folder with the latex files to compile the figuresmanuscript/figures/scripts/
folder with the R scripts that generate the results used for the figures of the manuscript
The folder scripts
contains template repositories for fitting NODE by BNGM to new time series datasets:
RStudio
folder contains scripts to run NODEBNGM in RStudio
R
(v4.0.0 or later) is required to run the scriptsLaTeX
(TeX live 2022) is required to compile the latex files of the manuscript and figures
Detailed instructions on how to implement NODEBNGM can be found in the folder scripts/RStudio/b1_0_0/
.
Bonnaffé, W., Sheldon, B.C. and Coulson, T., 2021. Neural ordinary differential equations for ecological and evolutionary time‐series analysis. Methods in Ecology and Evolution, 12(7), pp.1301-1315.
Hiltunen, T., Jones, L.E., Ellner, S.P. and Hairston Jr, N.G., 2013. Temporal dynamics of a simple community with intraguild predation: an experimental test. Ecology, 94(4), pp.773-779.
Ushio, M., Hsieh, C.H., Masuda, R., Deyle, E.R., Ye, H., Chang, C.W., Sugihara, G. and Kondoh, M., 2018. Fluctuating interaction network and time-varying stability of a natural fish community. Nature, 554(7692), pp.360-363.