Skip to content

wds15/minimal_maudfail

 
 

Repository files navigation

A small example to illustrate when our model fails

We have been trying to fit Bayesian models of metabolic networks with Stan - check out our progress here. Our models' speed is limited by the need to solve ODEs with large numbers of parameters compared to the number of state variables, so we are hopeful of being able to achieve a speedup using Stan's new adjoint ODE solver.

However, starting with cmdstan version 2.27.0-rc1 we began to see some errors that were not occurring before, and the sampler started to behave strangely. This repository provides an example that reproduces this error.

Requirements

  • wget
  • tar
  • make
  • C++ toolchain
  • Python 3.7+

Instructions:

  1. Fresh python 3 environment
python -m venv venv_maudfail
source venv_maudfail/bin/activate
  1. Install cmdstanpy, cmdstanv versions cmdstan-ode-adjoint-v2, cmdstan-2.27.0-rc1 and cmdstan-2.27.0 (the cmdstans go in the directory cmdstan)
make stan-environment
  1. run the script
python script.py
  1. Check out the results
ls output/linear/*

The python file script.py is quite lightweight - it just sets the version of cmdstan that cmdstanpy will use, deletes any model files, compiles a new model using cmdstanpy and samples with it using the input data json file, inits json file and sampler configuration toml file from the folder data/methionine_cycle.

To change the sampler configuration, edit the table sample_kwargs in the file data/methionine_cycle/config.toml.

To change the ode tolerances, edit the file data/methionine_cycle/stan_input_data.json.

To change the initial parameter values, edit the file data/methionine_cycle/inits.json.

To remove all cmdstan folders, run make clean-cmdstan.

to remove all Stan output files, run make clean-results.

About

Troubleshooting a kinetic model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Stan 78.2%
  • R 9.4%
  • Python 6.8%
  • Makefile 4.8%
  • Shell 0.8%