```python
import sympy as sm
from sympy import *
```

**Analytical solution**

The model project concerns the Stackelberg duopoly model (later extended to an oligopoly).

The opening model is a sequential move model, where two firms compete over quantities of some good. Firm 1 chooses a quantity, *$q_1\geq0$*, of the good. Firm 2 then observes this quantity and sets their own quantity, *$q_2\geq0$*, accordingly.

The model has complete information.

Each firm want to maximize profits w.r.t. quantity supplied using the profit function, known to both parties:
$$\pi_i(q_i,q_j)=q_i[P(Q)-c]$$
*c* is the marginal cost of production, identical for both firms, and *P(Q)* is the market clearing price for the good:
$$P(Q)=a-Q$$
*$Q=q_1+q_2$* is the total production of the good in the economy.

Profit function:

$$
\pi_2(q_1, q_2) = q_2(a - q_1 - q_2 - c)
$$

This must be maximized w.r.t. the quantity of firm 2, q_2

$$
\max_{q_{2\ge0}} \pi_2(q_1, q_2)
$$


```python
# Define the symbols
q_1 = sm.symbols('q_1')
q_2 = sm.symbols('q_2')
a = sm.symbols('a')
c = sm.symbols('c')
```

The model is solved using backwards induction, first firm 2 maximize their profit and find their response function $R_2(q_1)$ that way.


```python
# Define the profit function for firm 2.
profit_2 = q_2 * (a - q_1 - q_2 - c)
```

To get the reaction function for $q_1$, the derivative is taken w.r.t. $q_2$ and isolating for $q_2$


```python
R_2 = sm.solve(format(Derivative(profit_2, q_2).doit()),q_2)[0]
print(f"R_2 = {R_2}")
R_2
```

    R_2 = a/2 - c/2 - q_1/2





$\displaystyle \frac{a}{2} - \frac{c}{2} - \frac{q_{1}}{2}$



Now having found firm 2's response function for a quantity set by firm 1, firm 1 is now able to input this into their profit function

$$\pi_1(q_1, R_2(q_1)) = q_1(a - q_1 - R_2(q_1) - c)$$

$$\max_{q_{1\ge0}} \pi_1(q_1, R_2(q_1))=q_1(a - q_1 - (a/2 - c/2 - q_1/2) - c)$$


```python
profit_1 = q_1 * (a - q_1 - R_2 - c)
```

Again, the derivative is is taken and isolated:


```python
q_1_max = sm.solve(format(Derivative(profit_1, q_1).doit()),q_1)[0]
print(f"q_1* = {q_1_max}")
q_1_max
```

    q_1* = a/2 - c/2





$\displaystyle \frac{a}{2} - \frac{c}{2}$



Now that we have the optimal q_1, we can insert it in the optimal q_2 (the reaction function):

$$R_2(q_1) = a/2 - c/2 - q_1/2$$

$$
R_2(q_1) = a/2 - c/2 - (a/2 - c/2)/2
$$

This gives the optimal q_2:


```python
q_2_max = a/2 - c/2 - (a/2 - c/2)/2
print(f"q_2* = {q_1_max}")
q_2_max
```

    q_2* = a/2 - c/2





$\displaystyle \frac{a}{4} - \frac{c}{4}$



The takeaway from this result is that in the firm 1 have a first mover advantage over firm 2 in the Staceklberg competition.
This is due to the fact, that it is a sequential move model with full information, therefore firm 2's only credible action is to commit to whatever quantity firm 1 sets. Knowing this firm 1 can set their quantity with the response from firm 2 as given.

This is a different result from the Cournot model where both firm would move at the same time and therefore split the production evenly.

Now that the optimal q_1 and q_2 are found, they can be inserted in the respective profit functions for firm 1 and firm 2:


```python
profit_1 = q_1_max * (a - q_1_max - q_2_max - c)
profit_1
```




$\displaystyle \left(\frac{a}{4} - \frac{c}{4}\right) \left(\frac{a}{2} - \frac{c}{2}\right)$




```python
profit_2 = q_2_max * (a - q_1_max - q_2_max - c)
profit_2
```




$\displaystyle \left(\frac{a}{4} - \frac{c}{4}\right)^{2}$



Obviously as the two firms sell their good at the same price, and both have the same marginal cost of production, firm 1 will have a higher profit than firm 2 due to their first mover advantage.

**Extension**

In the following we extend the model to allow more firms than just 2, going from a duopoly to an oligopoly. The new entrant, firm 3, will follow firm 2 in choosing their quantity.


```python
q_3 = sm.symbols('q_3')
```


```python
profit_3 = q_3 * (a - q_1 - q_2 - q_3 - c)
```


```python
R_3 = sm.solve(format(Derivative(profit_3, q_3).doit()),q_3)[0]
R_3
```




$\displaystyle \frac{a}{2} - \frac{c}{2} - \frac{q_{1}}{2} - \frac{q_{2}}{2}$




```python
profit_2_new = q_2 * (a - q_1 - q_2 - R_3 - c)
```


```python
R_2_new = sm.solve(format(Derivative(profit_2_new, q_2).doit()),q_2)[0]
R_2_new
```




$\displaystyle \frac{a}{2} - \frac{c}{2} - \frac{q_{1}}{2}$



This again can be inserted in R_3_new:


```python
R_3_new = a/2-c/2-q_1/2-(a/2-c/2-q_1/2)/2
```


```python
profit_1_new = q_1 * (a - q_1 - R_2_new - R_3_new - c)
```


```python
q_1_max_new = sm.solve(format(Derivative(profit_1_new, q_1).doit()),q_1)[0]
q_1_max_new
```




$\displaystyle \frac{a}{2} - \frac{c}{2}$




```python
q_2_max_new = a/2 - c/2 - (a/2 - c/2)/2
q_2_max_new
```




$\displaystyle \frac{a}{4} - \frac{c}{4}$




```python
q_3_max = a/2 - c/2 - (a/2 - c/2)/2 - (a/4 - c/4)/2
q_3_max
```




$\displaystyle \frac{a}{8} - \frac{c}{8}$




```python
profit_1_new = q_1_max_new * (a - q_1_max_new - q_2_max_new - q_3_max - c)
profit_1_new
```




$\displaystyle \left(\frac{a}{8} - \frac{c}{8}\right) \left(\frac{a}{2} - \frac{c}{2}\right)$




```python
profit_2_new = q_2_max_new * (a - q_1_max_new - q_2_max_new - q_3_max - c)
profit_2_new
```




$\displaystyle \left(\frac{a}{8} - \frac{c}{8}\right) \left(\frac{a}{4} - \frac{c}{4}\right)$




```python
profit_3_new = q_3_max * (a - q_1_max_new - q_2_max_new - q_3_max - c)
profit_3_new
```




$\displaystyle \left(\frac{a}{8} - \frac{c}{8}\right)^{2}$



This augmented model shows, that the later you get to pick your quantity the worse of you get. This is due to the same intuition as the case for 2 firms, the other firms knowing the strategy that there must be commited to hurts the firms going in the later stages.
Another way to exxapnd the amount of firms would be to still have two periods and let the remaining firms compete in a Cournot competition in stage 2.

995aa2c6ccb598cc1b61c26a7e748df02f0e0d89
ipynb
Jupyter Notebook
modelproject/theModelProject.ipynb
NumEconCopenhagen/projects-2020-group-16
714cfeae2f5783abc9789aabe0f2e6a324571e8a
MIT
modelproject/theModelProject.ipynb
NumEconCopenhagen/projects-2020-group-16
714cfeae2f5783abc9789aabe0f2e6a324571e8a
MIT
2020-04-07T16:14:54.000Z
2020-05-14T14:26:48.000Z
modelproject/theModelProject.ipynb
NumEconCopenhagen/projects-2020-group-16
714cfeae2f5783abc9789aabe0f2e6a324571e8a
MIT
Qwen/Qwen-72B
1. YES
2. YES