SOLVING COURNOT, STACKELBERG AND COLLUSION GAMES USING R GIACOMO FRANCHINI AND MATTEO BONFANTI 1. Introduction The issue we would like to cover in this brief guide is how to run Cournot, Stackelberg Games and collusions using the R software and find the equilibrium values for such games. Cournot, Stackelberg and collusion are the most common models of oligopoly used in undergraduate Microeconomics. In this note we follow a game theoretic approach. In particular, we focus the attention on duopoly situations, where there are only two firms on the market, and consider only the case in which firms play only once. These are the cases covered in the first year Microeconomics course. The reason for doing so is that in this way we are allowed to develop a R model that is not necessarily taking into consideration cooperation among firms, indeed if we extend the model to more than one period what happened on the first round of the game becomes observable and punishment tools are available for firms. In our case on the other hand such punishment tools are not available because firms play simultaneously and just for one round. For each model, we first describe the associated game (and the special case we re considering), then we develop an analytical solution of a game and finally we provide the scripts necessary to obtain such results using R. The same is done for the other two models taken into consideration.. Cournot game A Cournot game is a model aimed to find equilibrium values in an Oligopoly (Oligopoly) situation in which firms play simultaneously and take a decision on how much to produce. 3. Analytical solution of a one-stage Cournot game for a duopoly 3.1. Introducing Cost, Price and Profit functions: We assume that firms in this model are identical, i.e. they have the same cost function given by: C(q i ) = c q i where i = 1, on the top of that we assume that they are experiencing constant return to scale and, for the sake of simplicity, that MC = c. The question then is how much are the firms taken into consideration going to produce? We start by assuming that each firm is taking the other firm s behavior as given in choosing what to do (as in the prisoners dilemma example). 1
GIACOMO FRANCHINI AND MATTEO BONFANTI To find the solution we consider the profit maximizing condition, and hence profit and price functions have to be introduced: π i = P qi c q i P = a b(q 1 + q ) then if we plug the price function into profit we get: π i = [a b(q 1 + q )]q i c q i This function can be used to find the profit of both firms (that are by assumption symmetric) Firm 1: π 1 = [a b(q 1 + q )]q 1 c q 1 that, after computations are performed gives: π 1 = aq 1 bq 1 bq 1q cq 1 symmetrically for firm two such function will be: π = aq bq bq 1q cq 3.. Applying the first order condition for profit maximizing: The first order condition for profit maximizing is: δπ δq i = 0 i.e. MR = MC If we apply such condition to firms profit functions we get each firm s reaction function: that in turn gives: { q 1 (q ) = a c b q q (q 1 ) = a c b q 1 q1, q = a c (that are Cournot equilibrium quantities for firms 1 and ) 3b Once quantities are computed plug them into the price function to find the equilibrium price: P = a b(q1 + q) = a + c (that is the Cournot equilibrium price) 3 and finally use q1, q and P to find profits for the single firm: π i = P q i cq i = (a c) 9b
SOLVING COURNOT, STACKELBERG AND COLLUSION GAMES USING R 3 4. Solving the problem using R In this section we want to solve a typical problem regarding the Cournot model previously developed, for instance: 4.1. Data: The market demand for the belts industry is given by P = 100 q 1 q, where q 1 is the amount of output Firm 1 produces and q is firm s level of output. The marginal cost of each firm is 10 4.. Problem: A) What is Firm 1 s profit-maximising output when firm produces an arbitrary output q (i.e. what is the equation of Firm 1 s reaction function)? B) Compute the Cournot equilibrium quantities and price in the belts market. 4.3. Solution : A) We know that: P = 100 1(q 1 + q ) Since we know from the previous section that the reaction function for Firm 1 is given by: q 1 (q ) = a c q b and that a = 100, b = 1 and c = 10 we substitute into the function to get: q 1 (q ) = B) We apply the previous result: 100 10 q = 45 q { q 1 (q ) = a c b q q (q 1 ) = a c b q 1 and using the numbers provided by the exercise: { q 1 (q ) = 100 10 q q (q 1 ) = 100 10 q 1 ( 45 q 1 ) ( 1 ) + 45 q1 q 1 4 =, 5 q 1 = 30 then the Cournot equilibrium quantities are: q 1, q = 100 10 3 = 30
4 GIACOMO FRANCHINI AND MATTEO BONFANTI Finally the Cournot equilibrium price can be determined by plugging the values of a, c, q1 and q into the Price function: P = a b(q 1 + q ) = 100 1 (30 + 30) = 40 4.4. R script: To compute the equilibrium values of the problem using R we ll need just two item provided by the program: an assignment operator the function command (to use such command you ve to type: name function( variables of the function ) ( body of the function ) A)As first step assign values to the parameters a,b,c: a 100 b 1 c 10 and define the reaction function for firm 1 as follow: reaction.function.f1 < function(q) (a c)/ b q/ finally compute q1 and q using the theoretical result obtained in section 3: q1 function (a,b,c) (a-c)/3*b q function (a,b,c) (a-c)/3*b B)To find the equilibrium price we use a function command exploiting as before the theoretical result previously obtained: equilibrium.price < function (a,c) (a+*c)/3 5. Stackelberg game As with the Cournot game, Stackelberg model is aimed to find equilibrium values in an Oligopoly where firms take a decision on how much to produce. Stackelberg game is used to model a sequential game ( recall that the Cournot game was a simultaneous one) so now we have a Leader, i.e. a firm that moves first and grabs much of the industry profit and a Follower, i.e. a firm that moves after the leader. As in the Cournot game we stick to a situation in which we have just two firms, that we call Leader and Follower that are assumed to be identical, i.e., with the same cost function. 6. Analytical solution of a one-stage Stackelberg game for a duopoly 6.1. Introducing Cost and Price functions: As in the Cournot game the cost function is assumed to be: C(q i ) = c q i where i = L, F so that MC = c. On the top of that we re assuming rationality, i.e. that firms behave in order to maximize their profit. The Price function will be the same as the one used in the Cournot Game:
SOLVING COURNOT, STACKELBERG AND COLLUSION GAMES USING R 5 P = a b(q L + q F ) (6.1) 6.. Problem solution: Problem solution will be found through backward induction and is going to be structured like this: find the reaction function of the Follower as a function of Leader s optimal quantity value assuming that the Leader will maximize its profit; take into consideration such reaction function in the Leader s decision of how much to produce; plug the Leader s optimal quantity value into the Follower s reaction function in order to find the optimal quantity for the Follower. 6.3. Evaluate the Follower s reaction function: Follower s reaction function is evaluated in the same way as it was evaluated in the Cournot Game, here is a refresh: π i = P q i c q i π F = [a b(q L + q F )]q F c q F Then applying the First order condition: we have: δπ F δq F = 0 i.e. MR = MC q F (q L ) = a c b q L (6.) 6.4. Evaluate Leader s optimal quantity: Now that we know the Follower s reaction function we can pretend to be the Leader and use it to find out which is the optimal quantity of output to produce. Recall that the profit function for the Leader is given by: π L = P q L c q L if then we plug (6.1) and (6.) into the Leader s profit function we get: π L (q L ) = [a b (q L + q F )] q L c q L = { a b [q L + ( a c b q )]} L ql c q L finally we apply the First order condition to get: ql = a c b 6.5. Evaluate Follower s optimal quantity: As the last step we ve to determine the level of output that the Follower is going to produce. In order to do so we just plug ql into (6.) and we get: q F (q L ) = a c b q L = a c ( a c 1 ) = a c b b 4b
6 GIACOMO FRANCHINI AND MATTEO BONFANTI 6.6. Evaluate equilibrium price and Leader and Follower s profit: Once we know both the quantity produced by the Leader and by the Follower we can compute straight away the price that will be charged and the profit of each firm just by plugging ql and qf into the price function (to find the price) and respectively in the Leader and and the Follower s profit functions to compute profits for both firms P = a b(q L + q F ) = a b ( a c a c ) π i = [ a b ( a c b a c 4b b )] q i c q i where i = L, F 7. solving the problem using r We now want to solve the same problem as before (the one introduced in the Cournot game) using the Stackelberg model, so in this case we ll assume that there are a Leader and a Follower. 7.1. Data: The market demand for the belts industry is given by P = 100 q L q F, where q L is the amount of output the Leader produces and q F is Follower s level of output. Marginal costs are equal to 10 (i.e., MC = 10). 7.. Problem: Find q L and q F. 7.3. Solution: We use the same backward induction method of section 6 to solve the problem so: find the Follower s reaction function as a function of Leader s quantity; exploit Follower s reaction function to find Leader s optimal quantity ql ; paste it into the Follower s reaction function to find Follower s optimal value. Note they if you want to solve the exercise using R you just need to assign values to a,b,c and then evaluate ql and q F as we did with the previous problem. A detailed solution is provided in the next subsection. 1) The Follower s reaction function is evaluated starting from the Follower s profit function, and then setting its derivative w.r.t. qf equal to zero: 4b δπ F δq F : [[a b(q L + q F )]q F c q F ]] = 0 that using numbers provided by exercise gives: q F (q L ) = 100 10 q L = 45 q L
SOLVING COURNOT, STACKELBERG AND COLLUSION GAMES USING R 7 ) Now that we have the reaction function of qf as a function of q L we plug such expression into the Leader s profit function and apply the first order condition: π L (q L ) = [a b (q L + q F )] q L c q L = { a b [q L + ( 45 q )]} L ql c q L then set the derivative w.r.t. ql equal to 0 δπ [ ( F : [a b(q L + 45 q ] L )]q F c q F ] = 0 δq F that using numbers provided by the exercise ql = 100 10 = 45 3) The final step consists just in using ql to find q F q F (q L ) = 45 q L 45 = 45 =, 5 7.4. R script: The R script needed is very similar to the one needed to solve the Cournot problem: a) Use the arrow to assign the values given by the problem to the parameters a,b,c: a 100 b 1 c 10 b) Define Leader and Follower s quantity functions using the command function ql (a-c)/*b qf (a-c)/4*b and R will compute ql and q F. 8. Collusion,a special case Collusion is not, strictly speaking, a competitive game; indeed in this situation firms that compose the Oligopoly decide not to compete and create a fake Monopoly in order to rise the price charged for the product through underproduction. Then, once the total level of production for the industry has been settled Firms divide the total production according to some proportions. In this section we assume that there are just two firms (so a theoretical Duopoly) that share the same cost function. 9. Analytical solution of a Collusion problem The framework in which we develop the solution of the Collusion situation is the same as the one we used both for Cournot and Stackelberg games. We define a Price function and a Cost function: P = a b q t C(q t ) = c q t
8 GIACOMO FRANCHINI AND MATTEO BONFANTI The problem will be solved by applying directly the first order condition the usual profit function: π(q t ) = P q t c q t after taking the derivative with respect to q t and solving for q t we get: q t = a c b that is the total quantity of output that will be produced in the industry. Finally by assumption we have that the two firms split the market in equal parts so each firm has a 50% market share: q 1 = q = a c b 1 n = a c b 1 = a c 4b (where n is the number of firms participating to the collusion ) 10. solving the problem using R We now want to solve the usual problem, rearranged to fit with the collusion situation. We first solve it analytically and then we provide the R script to quick check that the result is correct. 10.1. Data: In a particular industry the market demand is defined as: P = 100 1 q t moreover we know that in the industry there are only two Firms that share the same market structure: C(q t ) = 10 q t 10.. Problem: find out q 1 and q 10.3. Solution: Using the proof developed above we know that q t = 100 10 = 45 Once we knowq t just divide it by 1 n i.e. 1 to get: q1 = q =, 5 10.4. R script: the R script needed to solve a collusion problem is very similar to the one we used for Cournot and Stackelberg games. The only difference is that we ve to define one more parameter, i.e. the number of firms participating to the collusion: a 100 b 1 c 10 n then we define the total quantity function exploiting the theoretical result obtained above as: qt function(a,b,c) ((a-b)/b) and the single firm s quantity function as: q1. function(a,b,c,n) ((a-b)/b))*(1/n)
SOLVING COURNOT, STACKELBERG AND COLLUSION GAMES USING R 9 11. appendix The aim of this appendix is to provide a R script that can be used to solve the previously introduced exercises without using the main theoretical results. In order to do so we are going to use four R commands: Expression: such command builds an expression in R. D: this command provides the general derivative with respect to the specified variable of an expression. Function: this command builds a function of some variables. Uniroot: this command looks for the zeros of a function in a given interval. For our purposes Expression and Function commands are practically identical; we use both just because D requires an expression and uniroot a function. For any other explanation or example the Help page can be useful. Such page can be reached by typing??expression and??function. 11.1. Cournot: As a first step we have to provide R with a profit function for both firms profit1 expression(100 q 1 q 1 q 1 q 10 q 1 ) profit expression(100 q q q 1 q 10 q ) then in order to compute the derivative we use the command D d.profit1 D(profit1, q1 ) d.profit D(profit, q ) As usual once the object has been created, in order to visualize it we have to call it by typing its name: d.profit1 d.profit Once we have the general derivative for the profit of both firms we have to make q 1 and q explicit respectively in the first and in the second expression; after such rearrangement has been performed we paste the q function into the q 1 one (this passage cannot be performed using R,anyway is trivial). Once we have a function of only one variable, namely q 1 we transfer it into R using the command function: f 1 function(q1)(100 10)/ 0.5 (45 0.5 q1) q1 as a final step we use the command uniroot: sol uniroot(f1, c(0, 100)) The root we find using such command is the equilibrium quantity for firm 1,and by symmetry also for firm. 11.. Stackelberg: the procedure for solving the Stackelberg exercise is very similar to the one used for Cournot. We first derive the reaction function of the follower then such function is used to evaluate the leader optimal quantity. As a final step the quantity of the leader is plugged into the previously defined follower s reaction function in order to find out its optimal quantity. Though the problem is a little bit more complex than the Cournot one, once we have
10 GIACOMO FRANCHINI AND MATTEO BONFANTI established the procedure the commands that we need to solve the problem are the same as before. Here is the script: profit.follower expression((100 1 (q l + q f )) q f 10 q f ) d.profit.follower D(profit.follower, q f ) d.profit.follower profit.leader expression((100 1 (q l + 45 0.5 q l )) q l 10 q l ) d.profit.leader D(profit.leader, q l ) d.profit.leader f.l function(q l )(100 1 (q l + 45 0.5 q l )) (1 0.5) q l 10 sol.l uniroot(f.l, c(0, 100)) sol.l f.f function(q f )(100 1 (45 + q f )) q f 10 sol.f uniroot(f.f, c(0, 100)) sol.f 11.3. Collusion. Collusion is the easiest among the three exercises. In order to make the script more elegant we introduce one more command: as.numeric ; this command translates the chosen object into a numeric item. Such command is used when extracting from the uniroot result the total quantity of the industry in order to divide it by two. Here is the script: profit.ind expression((100 qt) qt 10 qt) d.profit.ind D(profit.ind, qt ) d.profit.ind f.t function(qt)((100 qt) qt 10) sol.f or.f irm (as.numeric((uniroot(f.t, c(0, 100)))[1]))/ 11.4. Final remark: The R scripts used in this appendix can be safely downloaded via dropbox at: http://dl.dropbox.com/u/59846111/cournot