# Neural Network-Informed Lotka-Volterra Dynamics for Cryptocurrency Market Analysis
## 4 Hybrid Neural Network--ODE Framework for Parameter Estimation and Forecasting
### Mathematical Formulation  
As we see in Algorithm 1, the neural network is trained to approximate the time evolution of the system by learning the mapping from time to the observed data [30]. After predicting the trajectories, we numerically compute the derivatives and fit them to a generalized Lotka-Volterra (GLV) model using nonlinear least squares optimization. The system of ODEs used to model the interactions among the three components (e.g., BTC, ETH, and ALTs) is given as follows:  
\[\frac{du_{1}}{dt} = u_{1}\big{(}p_{1}+p_{2}u_{1}+p_{3}u_{2}+p_{4}u_{3}\big{)},\] \[\frac{du_{2}}{dt} = u_{2}\big{(}p_{5}+p_{6}u_{1}+p_{7}u_{2}+p_{8}u_{3}\big{)}, \tag{12}\] \[\frac{du_{3}}{dt} = u_{3}\big{(}p_{9}+p_{10}u_{1}+p_{11}u_{2}+p_{12}u_{3}\big{)}.\]  
```
1:Input: Crypto market share data from Excel file, time vector \(t\_data=[0,1,\dots,N-1]^{T}\)
2:Read and preprocess data \([BTC,ETH,ALT]\) into data
3:Split data into 70% training (\(train\_data\), \(train\_time\)) and 30% testing (\(test\_data\), \(test\_time\))
4:Define a Feedforward Neural Network with 3 hidden layers (\(\mathtt{tanh}\) activation) and linear output
5:Initialize best weights and minimum validation cost
6:for each bootstrap iteration \(b=1\) to 5 do
7: Generate moving block bootstrap indices (block length = 10) for training data
8: Select resampled training data \(train\_data^{(b)}\), \(train\_time^{(b)}\)
9: Train DNN to predict \(\hat{U}\), i.e., the derivatives of market shares (\(\hat{U}=\frac{d\hat{U}}{dt}\)), on \(train\_time^{(b)}\), \(train\_data^{(b)}\)
10: Integrate \(\hat{U}_{pred}\) to obtain \(U_{pred}\), i.e., reconstruct predicted market shares from predicted derivatives
11: Evaluate on out-of-bag (OOB) data to compute validation cost
12:ifOOB cost is minimum then
13: Store best weights
14:endif
15:endfor
16:Use best weights to compute \(U_{pred}\) and derivatives \(\frac{du_{1}}{dt},\frac{du_{2}}{dt},\frac{du_{3}}{dt}\) analytically
17:Define ODE system: \(\dot{u}_{i}=u_{i}\cdot(p_{i1}+p_{i2}u_{1}+p_{i3}u_{2}+p_{i4}u_{3})\), \(i=1,2,3\)
18:Use nonlinear least squares to estimate parameters \(p_{1}\) to \(p_{12}\)
19:Print estimated parameters
20:Numerical solution fo the Lotka-Volterra equations over the \(test\_time\) interval using the Runge-Kutta method To estimate the parameters \(p_{1},\ldots,p_{12}\), we define a residual function that quantifies the mismatch between the model's predicted derivatives and the ones obtained from the neural network output. This residual function is given as follows:

\[r(p) = \left[ \begin{array}{c}\frac{du_{1}}{dt}-u_{1}\big{(}p_{1}+p_{2}u_ {1}+p_{3}u_{2}+p_{4}u_{3}\big{)}\\ \frac{du_{2}}{dt}-u_{2}\big{(}p_{5}+p_{6}u_{1}+p_{7}u_{2}+p_{8}u_{3}\big{)}\\ \frac{du_{3}}{dt}-u_{3}\big{(}p_{9}+p_{10}u_{1}+p_{11}u_{2}+p_{12}u_{3}\big{)} \end{array} \right] \tag{13}\]

In Equation (13), the derivatives are obtained from the neural network. Because the network is trained to output \(u_{i}(t)\) only, each time derivative \(\frac{du_{i}}{dt}\) must be computed by analytically differentiating the trained network with respect to \(t\) (using the chain rule through every hidden layer). Likewise, when forming \(r(p)\) for the lsqnonlin call, we should state explicitly that the input \({}^{\omega}\frac{du_{i}}{dt}\)' is this analytic network derivative, rather than a numerical finite difference. The optimal parameters are obtained by minimizing the sum of squared residuals:

\[\min_{p}\,\big{\|}r(p)\big{\|}_{2}^{2}. \tag{14}\]

This optimization aligns the dynamics of the GLV model with the data-driven derivatives, effectively capturing the underlying interactions among the system components. ### Numerical Integration via Runge-Kutta

Numerous numerical methods have been developed to solve ordinary differential equations. Among the most widely used for the integration of first- and second-order ODEs are the Runge-Kutta (-Nystrom) schemes and linear multistep methods (e.g., see [31; 32; 33; 34; 35; 36]).