# Stan can calculate System Dynamics models?

hi! i learn System Dynamics(using vensim).

I recognize that “Stan” is a tool especially focusing on bayes model (using MCMC). Where in System Dynamics regeion, “stella/ithink”, “vensim” is famous for calculating GUI tools, esepecially there two is capable to generate codes and calculate from a system diagram.

Stan can also calculate bathtub-model such as flow-stock-converter models in System Dynamics or models appear in this book “Jim Hines, Molecules of Structure Building Blocks for System Dynamics Models.” ?

Hi @Cartman0.

Systems dynamics models are (nearly always) models of ordinary differential equations. Stan can indeed estimate parameters from ordinary differential equation models, using the built in `integrate_ode_rk45`, `integrate_ode_bdf`, as well as other solvers (the manual has a chapter on ODEs).

In practice, estimating parameters from ODE models can be difficult. Systems dynamics models are also high-dimensional (hundreds of differential equations are possible), and involve non-differentiable functions (such as table ‘lookup’ functions, interpolation, if-else statements etc.), so you will need to significantly reduce the model and/or re-formulate the model to accommodate smooth functions (e.g. a sigmoid rather than a table function).

Ultimately, I think these large ODE systems are useful for simulating scenarios but are not the best for fitting to actual data sources, unless you have a lot of data available and the model is a good description of reality. In my experience, these models are include many non-identifiabilities (i.e. different parameter estimates can result in the same behaviour). While this is not a failing of the models themselves, it does make it substantially more difficult to estimate the parameters.

You might want to look at approximate Bayesian computation schemes as an intermediate approach for larger models.

2 Likes

@cgoold thx for good ans!

i have used ODE solver in `scipy`, is it different from ODE solver in Stan?

You might want to look at approximate Bayesian computation schemes as an intermediate approach for larger models.

i confuse about hierarchical bayes model and large ODE model…
are large (stochastic) ODE model (ex. any ODE with unknown parameter hypothesizing initial-prior distribution) included in hierarchical bayes model?
can deal both ODE as known-behavior(and element) and hierarchical bayes model as (unknown or unsmooth)-behavior? can Stan also deal the model?

I’m not sure of the `scipy` ODE solver, unfortunately.

I’m not sure I follow your question here. ODE models can be hierarchical, because hierarchical just means that parameters vary across units/clusters.

1 Like