1
$\begingroup$

Is there some guide or GitHub repository that shows how to program numerical version of IO models? I would like to learn how to simulate the general $n$-firm Cournot competition model, but I can accept an answer that will point towards tutorials that do even just simple Cournot duopoly.

I do not have any specific assumptions on demand and cost function in mind. I want to see some toy examples I can use to learn how to do this. In case the answer tries to present example you can assume simple constant cost and downward sloping linear demand with some reasonable parameters.

$\endgroup$
5
  • $\begingroup$ Can you please clarify what you mean by general $n$-firm Cournot model? I mean what assumptions are there on the demand and cost functions regarding monotonicity and convexity? $\endgroup$
    – Giskard
    Commented Dec 11, 2023 at 13:03
  • $\begingroup$ @Giskard by that I mean that the model will work with any natural number n firms. Any standard downward sloping demand function will do. Costs can be linear. I just need some example of how to solve such model using python and then I can change parameters $\endgroup$
    – csilvia
    Commented Dec 11, 2023 at 15:16
  • $\begingroup$ Sorry, it is probably my ignorance, but I am not sure what you are looking for: some library with general IO functionality (not sure what this means), or a Python implementation of an algorithm that converges to an/the equilibrium? In the latter case it would strongly depend on the model assumption whether the algorithm works/is efficient? $\endgroup$
    – Giskard
    Commented Dec 11, 2023 at 15:20
  • $\begingroup$ @Giskard I am total novice in numerical methods I just want to see some example which with I can play and learn. $\endgroup$
    – csilvia
    Commented Dec 11, 2023 at 15:42
  • $\begingroup$ @Giskard also, I am looking for a guide or tutorial or GitHub, but if someone can provide some example in answer I now specified some assumptions. $\endgroup$
    – csilvia
    Commented Dec 11, 2023 at 15:45

1 Answer 1

4
$\begingroup$

Here is a program on Cournot competition on Github:

http://janboone.github.io/competition_policy_and_regulation/Collusion_Cournot/Collusion_Cournot.html

It encompasses both numerical aspects and graphical aspects, and makes clear that SciPy, Numpy and Matplotlib are needed ( of course, what you need depends on your specific model) .

SciPy and Numpy are scientific and numerical libraries of Python. Matplotlib is the graphical library, and enables you to plot graphs and represent numerical solutions as graphs.

Changing parameters in the equations of the program you can plot the relevant solution as graphs, as in the following simulation of a Cournot model:

https://www.kaggle.com/code/hrishitabapuram/cournot-model-simulation

Below, some examples of programs for Cournot’s model I found, without graphical representations:

https://data88e.org/textbook/content/07-game-theory/cournot.html

Here is another program on Github, that includes also the case of n companies:

https://ispanos.github.io/CournotGame/

Adapting some of the program above to your needs, you can write down your simulation (of course, nothing ensures that the programs above are completely correct).

But, of course, the first step is to write down your equations.

Maybe the most complicated part is the graphical part, if you need it. In this case you have to know a little Matplotlib, if you don’t already know it.

Have you a Python editor? I suppose you have, but I give a reference:

You can download Anaconda, a free software with several applications as Phyton and R, the name of the Python editor on Anaconda is Spider.

There are in it, of course, Scipy, Numpy and Matplotlib.

If you need a good reference as a guide for numerical and scientific Python, Matplotlib included, you can look at Robert Johansson, Numerical Phyton-Scientific Computing and Data Science Applications with Numpy, SciPy and Matplotlib, Apress, 2019.

But there is a lot of documentation for Python online, not very easy to search in, though, very wide.

Post Scriptum. If you are a beginner in Phyton and you want to learn it, you need or a course or a book as guide for general Python (not scientific and numeric Python alone), documentation online drives you crazy.

I studied, some years ago, Python on lectures notes, but they are not in English, and on Downey, Think Phyton, a wide-spread book, but I don't like it very much, there is a new book Hunt, A Beginners Guide to Phyton 3, I don't know it, but it is published by Springer and should be reliable.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.