A frequentist estimation approach for a MNP model in python stan


I have been coding in python for a while now and recently decided to use stan python interface for optimization. I have my MNP code written in Python and was wondering if someone can help me with how to modify the code so that I can use pystan package optimizing module to optimize my model.

Being a frequentist we write the likelihood and first order conditions ourselves and pass it to the optimizer. However, in pystan I can’t seem to figure out how to do the same as one would do in Scipy or Gauss or any other software.

If someone can even provide an example of how to even do a basic MNL in pystan using frequentist approach, I can then modify my codes.

Any help is appreciated.

P.S. Being a new user it’s not allowing me to upload more than one file. If someone needs my code, feel free to drop their email id.


You can not directly call Stan optimizer from PyStan for Python objects / functions.

What you should do is to write your model in Stan and transfer data though PyStan interface. If you do that then nothing is really stopping you to do full Bayesian inference on your model. To start your journey with Stan see Documentation (Manual, Tutorials) http://mc-stan.org/users/documentation/index.html

If you really need to use Stan optimizer, you could wrap it with Cython, but that is an advanced level of coding. And probably quite hard.

Scipy has L-BFGS-B method for mimimize function. Stan optimizer uses L-BFGS. So I’m not sure if would have any benefit over Scipy implementation.