Matlab Programs for Last-In First-Out Oligopoly Dynamics

Jaap H. Abbring§Jeffrey R. Campbell

This document lists and describes the programs used for the calculations of Abbring and Campbell (2009).


We are grateful to R. Andrew Butters for his superlative research assistance.
§Tilburg University. e-mail: J.H.Abbring@uvt.nl
Federal Reserve Bank of Chicago. e-mail: jcampbell@frbchi.org


This document describes the Matlab computer programs used for the calculations described in Abbring and Campbell (2009) in detail. These calcualte the value functions from the “pencil-and-paper” example in Figure 2, the value functions from the example of an equilibrium without threshold-based strategies in Figure 3, the equilibrium thresholds reported in Table I, and the “static” ordered-probit estimates of thresholds and producers' surplus per customer in Table II. For each of these, the relevant program embeds the calculated results in LaTeX code and writes the results to text files for direct inclusion in the paper's document.

Literate Programs

To facilitate the replication and extension of our work by others, we have written this in a style like that advocated by Knuth (1984).

Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.

He called instructions written in this way literate programs. The concept is familiar to anyone who has read Press, Teukolsky, Vetterling, and Flannery (1992) or any other volume of the Numerical Recipes series. To create this, we have embedded this text into the comments of the Matlab programs and processed the result with the Comments++ tool of Campbell and Peters (2010). This reads logical formatting commands similar to those of LaTeX in the comments of its source files and produces an X-HTML page with associated .png image files containing any mathematics. The result freely intersperses code with formatted comments and places relevant mathematics in proximity to the code implementing it.

Viewing This

This is an image.

Figure 1: An Example of Displayed Code from this Document

Below, working code is displayed in areas formatted with “bars” similar to those on “old-style” computer paper for dot-matrix printers. Figure 1 shows a screen shot of a few lines of code from this document. The source file name is to the left, and the line number from the source file preceeds each line. In this example, Line 18 is highlighted blue because the mouse was hovering over it when screen shot was taken.

This is an image.

Figure 2: Switching Styles in Firefox

If you find our explanation tiresome, you can change this document to show only the working code. Figure 2 shows how to do this for Firefox.1 The default value for Page Style is Display All. Changing this to Display Only Code hides our comments.

Printing This

So that the displayed line numbers match with the actual line numbers, your browser preserves all line breaks in the displayed source code. That is, a long line cannot break into multiple lines after you resize your browser window. The same principle applies to printing. If a line of code is too long to be displayed on the page, its right end will be cut off. For this reason, this document is best printed in landscape mode.2

Road Map

The remainder of this document proceeds as follows. The next section covers pencil.m, the program we use to calculate the value functions from the pencil-and-paper example plotted in Figure 2. Of course, this really can be done with pencil and paper. Nevertheless, find it useful to automate the figure's construction to ensure that its content really is consistent with the theory. We start with this file because it works alone to produce results included in the text. As such, it provides a good introduction to our workflow strategy. Section 2B presents the programs we use to calculate the unique LIFO equilibrium that defaults to inactivity, and Section contains the code that applies these to create the results in Figure 3 and Tables I and II. Section 4D lists possible exercises for the interested student. Several appendices contain material necessary for our undertaking but nevertheless of secondary interest.

1APencil-and-Paper Example

Section 2.2 of the paper coinsiders the model's unique LIFO equilibrium that defaults to inactivity in the special case where small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image with probability small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and equals a draw from a uniform distribution over small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image with the complementaryu probability. Since the equilibrium continuation thresholds are solutions to quadratic equations, we call this the “pencil-and-paper example.” The Matlab program pencil.m calcualtes the equilibrium value functions, continuation thresholds, and exit thresholds for particular parameter values. We use the following ones.

pencil.m7beta=1.05^(-5); Firms' common discount factor.
pencil.m8kappa=1.25; Per period fixed cost of production.
pencil.m9phi=@(N) 1; Sunk cost of entry, which we set to equal a trivial function of the number of incumbent firms.
pencil.m10pi = @(N) 2-2*(N>2); Per customer producer surplus, which is zero when three more more firms are active.
pencil.m11chat=0.1; Lower bound of demand state.
pencil.m12ccheck=2.5; Upper bound of demand state.
pencil.m13lambda=0.1; Probability of the demand state changing.

The calculated results are used by the LaTeX code in Appendix 3C to create Figure 2. The calculations proceed as outlined in the text. We first solve the dynamic programming problem of a firm that enters the market with a single incumbent in place. We then use the entry and continuation decisions of such a firm to specify and solve the dynamic programming problem of a firm that is the oldest incumbent.

Second Firm's Dynamic Programming Problem

Recall from the text that value function for a firm with rank 2 is piecewise linear and satisfies

(1)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

where

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

Since the value function is uniquely characterized by small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image we can construct a contraction mapping on this scalar “average continuation value” and iterate on it to calculate small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . For this, we first write the optimal choice of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image as a function of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Define small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image as the value of demand that exactly sets the value of continuation to zero.

(2)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

If small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , then optimality requires that small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . If small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , then continuation is always optimal and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Similarly, exit is always optimal and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image if small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image Putting these results together, we get the desired function.

(3)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

With small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image so defined, we can use Equation (1) and the definition of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to write the mapping of interest.

(4) small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

The right-hand side of Equation (4) implicitly defines a mapping from the interval small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image into itself. This is monotone and, since small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image satisfies Blackwell's definition of discounting.See Theorem 3.3 of Stokey, Lucas, and Prescott (1989). Hence, it is a contraction mapping. We can calculate its unique fixed point to arbitrary precision by iterating on it from an arbitrary initial starting value.

To implement this in Matlab, we define three inline functions, One calculates small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image from the intial guess at small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image (which we denote with vtilde in the code), one which uses this to calculate small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image from small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and one that uses both of these to calculate the nex trival value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image (vtildeprime) using Equation (4).

pencil.m55cstar2 = @(vtilde2) (kappa-lambda*vtilde2/(1-lambda))*2/pi(2); small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image from (2).
pencil.m56cunderbar2 = @(vtilde2) min(max(chat,cstar2(vtilde2)),ccheck); small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image from (3).
pencil.m57vtildeprime2 = @(vtilde2) 0.25*(ccheck+chat)*pi(2)-kappa + ...
pencil.m58 +beta*((1-lambda)*(ccheck^2*pi(2)*0.25 - ccheck*kappa)...
pencil.m59 +lambda*ccheck*vtilde2)/((1-beta*(1-lambda))*(ccheck-chat))...
pencil.m60 -beta*((1-lambda)*(cunderbar2(vtilde2)^2*pi(2)*0.25 - cunderbar2(vtilde2)*kappa)...
pencil.m61 +cunderbar2(vtilde2)*lambda*vtilde2)/((1-beta*(1-lambda))*(ccheck-chat));

With these inline functions defined, calculating small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to any desired accuracy requires only a simple iteration. We know that the contraction mapping has modulus small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , so iterating

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

guarantees that the final calculated small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is within small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image of the actual value.

pencil.m67epsilon=1e-5;
pencil.m68T = (log(epsilon)-log(ccheck*pi(1)/(1-beta)))/log(beta)+1;
pencil.m69
pencil.m70vtilde2=0;
pencil.m71t=0; Used to count the number of iterations
pencil.m72
pencil.m73while t<T
pencil.m74 vtilde2=vtildeprime2(vtilde2);
pencil.m75 t=t+1;
pencil.m76end

With the approximate fixed point in hand, we can calculate the entry and exit thresholds. For the exit threshold, we just use the inline function cunderbar.

Just as with the exit threshold, three possible cases govern the entry threshold. Although this is computational overkill, we maintain presentational symmetry wiith the calculation of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image by defining here two functions for its calculation.

pencil.m82cstarstar2 = @(vtilde2) (phi(2)*(1-beta*(1-lambda))/(beta*(1-lambda))...
pencil.m83 + kappa-lambda*vtilde2/(1-lambda))*2/pi(2);
pencil.m84coverbar2 = @(vtilde2) min(max(chat,cstarstar2(vtilde2)),ccheck);

First Firm's Dynamic Programming Problem

The dynamic programming problem for a firm with rank 1 has an additional state indicating the presence or absence of a competitor. In the text, we noted that the equilibrium value function has a simple piecewise linear structure. The value of beginning the period without a competitor at the demand state small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

If the firm begins the period instead with a younger rival, the value function equals

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

Here, the exit threshold small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is the greatest value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image such that small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and the expected values following a change in small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for a monopolist and a duopolist are

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

The entry and exit thresholds for a younger firm ( small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image ) are already in hand. With these, we mimic the calculation of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to compute small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . For any small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , we define small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image as the solution to

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

Define the mapping from vtilde to cunderbar

pencil.m125cstar1= @(vtilde1) (kappa-lambda*vtilde1(1)/(1-lambda))/pi(1);

Since vtilde1(1) weakly exceeds vitilde2, we know that cstar1(vtilde1) cannot exceed cunderbar2(vtilde2). Therefore,

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

pencil.m131cunderbar1 = @(vtilde1) max(chat,cstar1(vtilde1));

Deriving the mapping from small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image proceeds just as it did above.

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

To keep the inline function implementing this manageable, we write each of its two elements as a separate inline function and then concatinate them. Since vectors in Matlab have a unit offset, vtilde(1) and vtilde(2) refer to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image respectively.

pencil.m149vtildeprime10 = @(vtilde1) ((chat+ccheck)/2)*pi(1) - kappa + beta/((1-beta*(1-lambda))*(ccheck-chat))...
pencil.m150 *((1-lambda)*(coverbar2(vtilde2)^2*pi(1)/2-kappa*coverbar2(vtilde2))...
pencil.m151 +lambda*vtilde1(1)*coverbar2(vtilde2)...
pencil.m152 -((1-lambda)*(cunderbar1(vtilde1)^2*pi(1)/2-kappa*cunderbar1(vtilde1))...
pencil.m153 +lambda*vtilde1(1)*cunderbar1(vtilde1)) ...
pencil.m154 +(1-lambda)*(ccheck^2*pi(2)/4-kappa*ccheck)...
pencil.m155 +lambda*vtilde1(2)*ccheck ...
pencil.m156 -((1-lambda)*(coverbar2(vtilde2)^2*pi(2)/4-kappa*coverbar2(vtilde2))...
pencil.m157 +lambda*vtilde1(2)*coverbar2(vtilde2)));
pencil.m158
pencil.m159vtildeprime11 = @(vtilde1) ((chat+ccheck)/2)*pi(2)/2 - kappa + beta/((1-beta*(1-lambda))*(ccheck-chat))...
pencil.m160 *((1-lambda)*(cunderbar2(vtilde2)^2*pi(1)/2-kappa*cunderbar2(vtilde2))...
pencil.m161 +lambda*vtilde1(1)*cunderbar2(vtilde2)...
pencil.m162 -((1-lambda)*(cunderbar1(vtilde1)^2*pi(1)/2-kappa*cunderbar1(vtilde1))...
pencil.m163 +lambda*vtilde1(1)*cunderbar1(vtilde1)) ...
pencil.m164 +(1-lambda)*(ccheck^2*pi(2)/4-kappa*ccheck)...
pencil.m165 +lambda*vtilde1(2)*ccheck ...
pencil.m166 -((1-lambda)*(cunderbar2(vtilde2)^2*pi(2)/4-kappa*cunderbar2(vtilde2))...
pencil.m167 +lambda*vtilde1(2)*cunderbar2(vtilde2)));
pencil.m168
pencil.m169vtildeprime1 = @(vtilde1) [vtildeprime10(vtilde1) vtildeprime11(vtilde1)];

With the Bellman operator suitably defined, we iterate beginning with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image As shown in the appendix, this produces a monotone increasing sequence of expected continuation values that converge to the fixed point of interest.

pencil.m173vtilde1=[vtilde2 vtilde2];
pencil.m174t=0;
pencil.m175while t<T
pencil.m176
pencil.m177 vtilde1=vtildeprime1(vtilde1);
pencil.m178 t=t+1;
pencil.m179
pencil.m180end

With the value function calculated, we tidy up the loose end of calculating small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

pencil.m184cstarstar1 = @(vtilde1) (phi(1)*(1-beta*(1-lambda))/beta/(1-lambda) ...
pencil.m185 + kappa-lambda*vtilde1(1)/(1-lambda))/pi(1);
pencil.m186coverbar1 = @(vtilde1) min(max(chat,cstarstar1(vtilde1)),ccheck);

Value Function Figure

This is an image.

Figure 3: The Equilibrium Value Functions

The paper's text presents the results of this equilibrium calculation in Figure 2, which is reproduced here as Figure 3. It consists of two panels. The top one plots small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image as functions of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Since these overlap over most of their domains, we present these as two “branches”. The monopoly branch gives the value of a firm with rank small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image that begins as a monopolist and will remain so, and the duopoly branch gives the same firm's value when beginning as and remaining a duopolist. We denote the entry and exit of a younger rival with gray vertical arrows above small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . The panel also includes a legend to label these branches. The second panel plots the much simpler value function for a duopolist with rank 2. Both panels include gray horiontal lines at a height equal to the sunk cost of entry for a firm of that rank.

Creating these elements requires the following information.

We implement the figure's creation within the LaTeX document using the pgfplots package of and the pgf/TikZ package of Tantau (2008). Appendix 3C presents the relevant LaTeX code in more detail. It requires appropriately named macros to return the values of interest. We write the LaTeX code to create them into compute/pgfTikZ/ac2apencilConstants.tex. The next line opens this file for output and assigns it the file handle f1.

pencil.m213f1=fopen('pgfTikZ/ac2aPencilConstants.tex','w');

All of the macros' names begin with “pencil”.3 We write the LaTeX code creating them using Matlab's fprintf command, which has very similar syntax to C's printf function.

Start with the x-axis tick mark locations.

pencil.m219fprintf(f1,'\\def\\pencilChat{%3.2f}\n',chat);
pencil.m220fprintf(f1,'\\def\\pencilCcheck{%3.2f}\n',ccheck);
pencil.m221fprintf(f1,'\\def\\pencilCunderbarOne{%3.2f}\n',cunderbar1(vtilde1));
pencil.m222fprintf(f1,'\\def\\pencilCoverbarOne{%3.2f}\n',coverbar1(vtilde1));
pencil.m223fprintf(f1,'\\def\\pencilCunderbarTwo{%3.2f}\n',cunderbar2(vtilde2));
pencil.m224fprintf(f1,'\\def\\pencilCoverbarTwo{%3.2f}\n',coverbar2(vtilde2));

Add the two values of the entry costs.

pencil.m228fprintf(f1,'\\def\\pencilPhiTwo{%3.2f}\n',phi(2));
pencil.m229fprintf(f1,'\\def\\pencilPhiOne{%3.2f}\n',phi(1));

Calculate and write small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

pencil.m233v11coverbar2=beta*((1-lambda)*(coverbar2(vtilde2)*pi(1)-kappa)...
pencil.m234 +lambda*vtilde1(1))/(1-beta*(1-lambda));
pencil.m235fprintf(f1,'\\def\\pencilVOneOneCoverbarTwo{%3.2f}\n',v11coverbar2);

Calculate and write small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

pencil.m239v12cunderbartwo=beta*((1-lambda)*(cunderbar2(vtilde2)*pi(2)/2-kappa)...
pencil.m240 +lambda*vtilde1(2))/(1-beta*(1-lambda));
pencil.m241fprintf(f1,'\\def\\pencilVOneTwoCunderbarTwo{%3.2f}\n',v12cunderbartwo);

Calculate and write small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

pencil.m245v12ccheck=beta*((1-lambda)*(ccheck*pi(2)/2-kappa)...
pencil.m246 +lambda*vtilde1(2))/(1-beta*(1-lambda));
pencil.m247fprintf(f1,'\\def\\pencilVOneTwoCcheck{%3.2f}\n',v12ccheck);

Calculate the highest point of the second entrant's value function

pencil.m251v2ccheck=beta*((1-lambda)*(ccheck*pi(2)/2-kappa)...
pencil.m252 +lambda*vtilde2)/(1-beta*(1-lambda));
pencil.m253fprintf(f1,'\\def\\pencilVTwoCcheck{%3.2f}\n',v2ccheck);

Write the value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and close the output file.

pencil.m257fprintf(f1,'\\def\\pencilPiOne{%3.2f}\n',pi(1));
pencil.m258fclose(f1);

Quit Matlab

We only wish to quit if we are running this from the makefile. Since this probelm arises repeatedly, we place the code for such a conditional exit in the script makequit.

pencil.m264makequit

The code detects whether or not Matlab has ben started by make by importing the MAKELEVEL environment variable. If we are running this from within make, this will be nonempty. Since we do not run make under Windows, this function does nothing unless the operating system is either Unix or Mac.

makequit.m7if ( isunix || ismac )
makequit.m8
makequit.m9 makelevel=getenv('MAKELEVEL');
makequit.m10
makequit.m11 if ~strcmp(makelevel,'') && ~exist('stay','var')
makequit.m12 quit
makequit.m13 end
makequit.m14
makequit.m15end

2BLIFO Model

This section presents programs for calculating the LIFO equilibrium of interest in the general model without imposing the pencil-and-paper specificationfor the demand process. Section 4.1 of the text outlines our approach to equilibrium computation. We begin with approximating the given demand process with a Markov chain and calculating an uper bound on the number of active firms, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and we then proceed to recursively calculate the equilibrium continuation values and continuation strategies for firms with ranks small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . These computations also yield the strategies of potential entrants that would take on those ranks. With the equilibrium strategies in hand, we can simulate the model from any initial market structure. Alternatively, the ergodic distribution of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image might be calculated if that is the object of interest.

The approximation of a given demand process with a Markov chain is routine. For the examples in this section, we do so by hand. Some of the experiments described in Section 3C use the approximation to an autoregression described in the text. Appendix 1A presents the code for its implementation.

We break the code for the equilibrium calculation given the Markov chain into two parts, the solution of an optimal stopping problem, and the use of these solutions to calculate the equilibrium continuation values and strategies. We finish this section with the code for calculating the equilibrium's ergodic distribution.

2B.1Optimal Stopping Problems

Calculating the LIFO model's unique equilibrium that defaults to inactivity requires us to solve a sequence of optimal stopping problems, each corresponding to the exit decision of an incumbent firm of a particular rank. For this task, we develop a general procedure for calculating optimal stopping problems values and optimal rules.

In the general formulation of an optimal stopping problem, a decision maker faces an exogenous and payoff-relevent state small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . A Markov process governs its evolution, and the integer small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is the problem's dimensionality. The decision maker always begins the problem in the “active” state, which yields the flow payoff small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . At the end of the period the decision maker must choose between “continue” and “stop”. Continuing preserves the option to stop in the future, while stopping is irreversible. The one-time payoff to stopping is small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . The decision maker discounts future payoffs with the discount rate small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , so this problem's corresponding Bellman equation is

(5)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

Under well-known regularity conditions for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , Equation 5 defines a contraction mapping. The most conceptually straightforward method for calculating its unique fixed point is iteration on the Bellman operator implicitly defined by its right-hand side, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . The iteration terminates when the sup norm of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image falls below a prespecified tolerance, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

An optimal stopping problem has a discrete state space if small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image has a finite number of distinct values, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . In this case, the Markov process governing the evolution of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is a Markov chain with transition matrix small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Its typical element small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image gives small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

The function solveOptimalStoppingProblem implements Bellman equation iteration for this solution for optimal stopping problems with discrete state spaces. Its single input, ARG is a structure with fields corresponding to the problem's primitives.

stateSpace
An small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image matrix. Each row represents a distinct element of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
transitionMatrix
The small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image Markov transition matrix small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
flowPayoff
An anonymous function handle yielding the flow payoff function small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . This accept a vector of vector-valued inputs and return a vector of function values.
outsideValue
An anonymous function handle containing the value of stopping, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . This should also accept a vector of vector-valued inputs.
discountFactor
The decision maker's discount factor, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
convergenceTolerance
The tolerance for measuring convergence of the value-function iteration, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
valueFunction
An small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image vector. Its small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image 'th element contains a prospective value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

The function uses ARG.valueFunction as an initial value for the Bellman equation iteration. The function's single output, OUT, contains exactly the same fields. On return, OUT.valueFunction will equal the value function at the termination of the Bellman equation iteration.

solveOptimalStoppingProblem.m44function OUT = solveOptimalStoppingProblem(ARG)
solveOptimalStoppingProblem.m45

Start by setting the output structure to the input structure.

solveOptimalStoppingProblem.m47OUT=ARG;
solveOptimalStoppingProblem.m48

Assign the problem's primitives to variables with conventional names.

solveOptimalStoppingProblem.m50calX = ARG.stateSpace;
solveOptimalStoppingProblem.m51Pi = ARG.transitionMatrix;
solveOptimalStoppingProblem.m52f = ARG.flowPayoff;
solveOptimalStoppingProblem.m53S = ARG.outsideValue;
solveOptimalStoppingProblem.m54beta = ARG.discountFactor;
solveOptimalStoppingProblem.m55eps = ARG.convergenceTolerance;
solveOptimalStoppingProblem.m56V = ARG.valueFunction;
solveOptimalStoppingProblem.m57

Next, evaluate the flow payoffs and stopping values over the entire state space.

solveOptimalStoppingProblem.m61fX = f(calX);
solveOptimalStoppingProblem.m62SX = S(calX);
solveOptimalStoppingProblem.m63

Initialize an indicator for the distance between small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to exceed small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

solveOptimalStoppingProblem.m67vDistance=eps+1;
solveOptimalStoppingProblem.m68

Everything is now in place for the Bellman-equation iteration.

solveOptimalStoppingProblem.m71while vDistance>eps
solveOptimalStoppingProblem.m72
solveOptimalStoppingProblem.m73 Vprime=max([SX beta*(Pi*(fX+V))],[],2);
solveOptimalStoppingProblem.m74 vDistance=max(abs(Vprime-V));
solveOptimalStoppingProblem.m75 V=Vprime;
solveOptimalStoppingProblem.m76
solveOptimalStoppingProblem.m77end
solveOptimalStoppingProblem.m78

All that remains is to replace OUT.valueFunction with V and end the function.

solveOptimalStoppingProblem.m82OUT.valueFunction=V;
solveOptimalStoppingProblem.m83end
solveOptimalStoppingProblem.m84

Our test of solveOptimalStoppingProblem applies it to the dynamic programming problem of the firm with rank 2 in the pencil and paper example from the text. Start this by creating the discrete state space small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and the associated Markov transition matrix.

solveOptimalStoppingProblemTest.m6chat=0.1;
solveOptimalStoppingProblemTest.m7ccheck=2.5;
solveOptimalStoppingProblemTest.m8step=0.01;
solveOptimalStoppingProblemTest.m9omega=(chat:step:ccheck)';
solveOptimalStoppingProblemTest.m10N = length(omega);
solveOptimalStoppingProblemTest.m11
solveOptimalStoppingProblemTest.m12lambda=0.1;
solveOptimalStoppingProblemTest.m13Pi=(1-lambda)*eye(N)+lambda*ones(N,N)/N;

Next, create the anonymous function handles for the flow payoff and outside value.

solveOptimalStoppingProblemTest.m17pi=2;
solveOptimalStoppingProblemTest.m18kappa=1.25;
solveOptimalStoppingProblemTest.m19f = @(x) x*pi/2-kappa;
solveOptimalStoppingProblemTest.m20S = @(x) zeros(size(x,1),1);

Set the discount factor

solveOptimalStoppingProblemTest.m24beta=1.05^(-5);

Choose a convergence tolerance

solveOptimalStoppingProblemTest.m28eps=1e-7;

Choose an initial value function.

solveOptimalStoppingProblemTest.m32V=zeros(N,1);

Place the problem's primitive's into the required structure, which we call PENCIL to remind us of its source.

solveOptimalStoppingProblemTest.m36PENCIL.stateSpace = omega;
solveOptimalStoppingProblemTest.m37PENCIL.transitionMatrix = Pi;
solveOptimalStoppingProblemTest.m38PENCIL.flowPayoff = f;
solveOptimalStoppingProblemTest.m39PENCIL.outsideValue = S;
solveOptimalStoppingProblemTest.m40PENCIL.discountFactor = beta;
solveOptimalStoppingProblemTest.m41PENCIL.convergenceTolerance = eps;
solveOptimalStoppingProblemTest.m42PENCIL.valueFunction = V;

Solve the stopping problem.

solveOptimalStoppingProblemTest.m46PENCIL = solveOptimalStoppingProblem(PENCIL);

We inspect the results with a plot of the calculated value function. Its horizontal axis marks small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the exit threshold small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and the associated entry threshold small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . We also include a horizontal line at the entry cost small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

solveOptimalStoppingProblemTest.m52cunderbarIndex=find(PENCIL.valueFunction==0,1,'last');
solveOptimalStoppingProblemTest.m53cunderbar=PENCIL.stateSpace(cunderbarIndex);
solveOptimalStoppingProblemTest.m54
solveOptimalStoppingProblemTest.m55coverbarIndex=find(PENCIL.valueFunction<1,1,'last');
solveOptimalStoppingProblemTest.m56coverbar=PENCIL.stateSpace(coverbarIndex);
solveOptimalStoppingProblemTest.m57plot(PENCIL.stateSpace,ones(length(PENCIL.stateSpace),1),'-','LineWidth',1.5,'Color',[0.8 0.8 0.8]);
solveOptimalStoppingProblemTest.m58hold
solveOptimalStoppingProblemTest.m59plot(PENCIL.stateSpace,PENCIL.valueFunction,'-k','LineWidth',2);
solveOptimalStoppingProblemTest.m60
solveOptimalStoppingProblemTest.m61set(gca,'box','off','FontSize',14,'Xtick',[chat cunderbar coverbar ccheck]);
solveOptimalStoppingProblemTest.m62xlim([chat ccheck]);
solveOptimalStoppingProblemTest.m63set(gcf,'Color',[1 1 1]);

Save the figure to a .jpg file.

solveOptimalStoppingProblemTest.m67set(gcf,'Position',[-3 5 1280 950],...
solveOptimalStoppingProblemTest.m68 'PaperUnits','in','PaperSize',[5 3],...
solveOptimalStoppingProblemTest.m69 'PaperPositionMode','manual',...
solveOptimalStoppingProblemTest.m70 'PaperPosition',[0 0 5 3]); Set the figure to the desired size.
solveOptimalStoppingProblemTest.m71print -djpeg -painters solveOptimalStoppingProblemTest.jpg
solveOptimalStoppingProblemTest.m72makequit;

This is an image.

Figure 4: Value Function calculated by solveOptimalStoppingProblem

Figure 4 presents the resulting value function. As we can see, it is piecewise linear as expected. Furthermore, the entry and exit thresholds exactly equal their counterparts from the pencil and paper example above; which used a continuous state space instead of using a grid.

2B.2LIFO Equilibrium

With the procedure for solving optimal stopping problems in place, we can proceed with the equilibrium calculation as outlined in the text. The function calculateLifoEquilibrium carries this out. The fields of its single argument are

pi
A handle for an anonymous function that returns small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the per consumer producers' surplus earned when small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image firms are active.
kappa
The scalar per period fixed cost of production, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
phi
A handle for an anonymous function that returns small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the sunk cost of entry of a firm with prospective rank small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
omega
An small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image vector, the discrete state space for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
Pi
The Markov transition matrix for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
beta
Firms' common discount factor.
convergenceTolerance
A convergence tolerance for Bellman-equation iteration. Passed through to solveOptimalStoppingProblem.
nCheck
Either empty or an upper bound on the number of firms possibly active in the market.
V
Either empty or an small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image array. Its (i,j,k) element gives the value of an incumbent firm with rank i before the period's continuation and entry decisions are made when small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image equals omega(j) and there are k firms active this period.
nPrime
Either empty or an small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image array. Its small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image element gives the number of active firms at the beginning of the next period if small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image equals omega(j) and there are k firms active this period.

calculateLifoEquilibrium.m24function OUT = calculateLifoEquilibrium(ARG)
calculateLifoEquilibrium.m25

Begin by assigning the fields of ARG to variables.

calculateLifoEquilibrium.m28pi = ARG.pi;
calculateLifoEquilibrium.m29kappa = ARG.kappa;
calculateLifoEquilibrium.m30phi = ARG.phi;
calculateLifoEquilibrium.m31omega = ARG.omega;
calculateLifoEquilibrium.m32Pi = ARG.Pi;
calculateLifoEquilibrium.m33beta = ARG.beta;
calculateLifoEquilibrium.m34eps = ARG.convergenceTolerance;
calculateLifoEquilibrium.m35nCheck = ARG.nCheck;
calculateLifoEquilibrium.m36
calculateLifoEquilibrium.m37

We begin by assembling the per period producer surplus function. The resulting anonymous function f accepts a matrix as input. Its first column is the demand state, and the second column is the number of firms active in the period.

calculateLifoEquilibrium.m45f = @(x) x(:,1).*pi(x(:,2))./x(:,2)-kappa;
calculateLifoEquilibrium.m46

If nCheck is empty, then calculate the upper bound on the number of active firms

calculateLifoEquilibrium.m50if isempty(nCheck)
calculateLifoEquilibrium.m51 nCheck=1;
calculateLifoEquilibrium.m52 cCheck=max(omega);
calculateLifoEquilibrium.m53 while f([cCheck nCheck])>0
calculateLifoEquilibrium.m54 nCheck=nCheck+1;
calculateLifoEquilibrium.m55 end
calculateLifoEquilibrium.m56 ARG.nCheck=nCheck-1;
calculateLifoEquilibrium.m57 nCheck=ARG.nCheck;
calculateLifoEquilibrium.m58end
calculateLifoEquilibrium.m59

Set up storage for V and nPrime.

calculateLifoEquilibrium.m61n=length(omega);
calculateLifoEquilibrium.m62V = zeros(nCheck,n,nCheck);
calculateLifoEquilibrium.m63nPrime = ones(n,1)*(1:1:nCheck);
calculateLifoEquilibrium.m64
calculateLifoEquilibrium.m65

Cycle through the dynamic programming problems.

calculateLifoEquilibrium.m67for i=nCheck:-1:1
calculateLifoEquilibrium.m68
calculateLifoEquilibrium.m69

Calculate the state space and transition matrix for this firm's problem.

calculateLifoEquilibrium.m71ARG_TRANSITION.transitionMatrixForC = Pi;
calculateLifoEquilibrium.m72ARG_TRANSITION.supportForC = omega;
calculateLifoEquilibrium.m73ARG_TRANSITION.minimumN = i;
calculateLifoEquilibrium.m74ARG_TRANSITION.maximumN = nCheck;
calculateLifoEquilibrium.m75ARG_TRANSITION.nextN = nPrime(:,i:nCheck);
calculateLifoEquilibrium.m76
calculateLifoEquilibrium.m77TRANSITION=calculateLifoTransitionMatrix(ARG_TRANSITION);
calculateLifoEquilibrium.m78

Set up the argument for solveOptimalStoppingProblem and call it.

calculateLifoEquilibrium.m80STOPPING.stateSpace = TRANSITION.supportForCandN;
calculateLifoEquilibrium.m81STOPPING.transitionMatrix = TRANSITION.transitionMatrixForCandN;
calculateLifoEquilibrium.m82STOPPING.flowPayoff = f;
calculateLifoEquilibrium.m83STOPPING.outsideValue = @(x) zeros(size(x,1),1);
calculateLifoEquilibrium.m84STOPPING.discountFactor = beta;
calculateLifoEquilibrium.m85STOPPING.convergenceTolerance= eps;
calculateLifoEquilibrium.m86STOPPING.valueFunction = zeros(length(TRANSITION.supportForCandN),1);
calculateLifoEquilibrium.m87
calculateLifoEquilibrium.m88STOPPING=solveOptimalStoppingProblem(STOPPING);
calculateLifoEquilibrium.m89

Reshape the value function so that each row corresponds to a value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and each column to a value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

calculateLifoEquilibrium.m92vMatrix=reshape(STOPPING.valueFunction,n,nCheck-i+1);
calculateLifoEquilibrium.m93

Adjust nPrime for the exit of the firm with rank small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

calculateLifoEquilibrium.m95nPrime(:,i:nCheck)=nPrime(:,i:nCheck)-(vMatrix==0);
calculateLifoEquilibrium.m96

Adjust nPrime for the entry of the firm with rank small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

calculateLifoEquilibrium.m98nPrime(:,1:i-1)=nPrime(:,1:i-1)+(vMatrix(:,1)*ones(1,i-1)>phi(i));
calculateLifoEquilibrium.m99

Save the value function

calculateLifoEquilibrium.m101if i>1
calculateLifoEquilibrium.m102 V(i,:,:)=[NaN(n,i-1) vMatrix];
calculateLifoEquilibrium.m103else
calculateLifoEquilibrium.m104 V(i,:,:)=vMatrix;
calculateLifoEquilibrium.m105end
calculateLifoEquilibrium.m106
calculateLifoEquilibrium.m107end
calculateLifoEquilibrium.m108

Create the first column of nPrime, that associated with an initially empty industry.

calculateLifoEquilibrium.m111nPrimeZero=zeros(n,1);
calculateLifoEquilibrium.m112
calculateLifoEquilibrium.m113for j=1:nCheck;
calculateLifoEquilibrium.m114 vj=squeeze(V(j,:,j))'; This call to squeeze returns a column vector.
calculateLifoEquilibrium.m115 nPrimeZero=nPrimeZero+(vj>phi(j));
calculateLifoEquilibrium.m116end
calculateLifoEquilibrium.m117nPrime = [nPrimeZero nPrime];
calculateLifoEquilibrium.m118
calculateLifoEquilibrium.m119

Assemble the final output.

calculateLifoEquilibrium.m122OUT=ARG;
calculateLifoEquilibrium.m123OUT.nCheck=nCheck;
calculateLifoEquilibrium.m124OUT.valueFunction=V;
calculateLifoEquilibrium.m125OUT.equilibriumFirmCount=nPrime;
calculateLifoEquilibrium.m126

The test of calculateLifoEquilibrium uses the parameter values from the pencil-and-paper example.

calculateLifoEquilibriumTest.m6chat=0.1;
calculateLifoEquilibriumTest.m7ccheck=2.5;
calculateLifoEquilibriumTest.m8step=0.01;
calculateLifoEquilibriumTest.m9omega=(chat:step:ccheck)';
calculateLifoEquilibriumTest.m10N = length(omega);
calculateLifoEquilibriumTest.m11lambda=0.1;
calculateLifoEquilibriumTest.m12Pi=(1-lambda)*eye(N)+lambda*ones(N,N)/N;
calculateLifoEquilibriumTest.m13kappa=1.25;
calculateLifoEquilibriumTest.m14pi = @(x) 2*ones(size(x,1),1);
calculateLifoEquilibriumTest.m15beta=1.05^(-5);
calculateLifoEquilibriumTest.m16phi = @(x) ones(length(x),1);
calculateLifoEquilibriumTest.m17

We use the convergence tolerance from solveOptimalStoppingProblemTest.m.

calculateLifoEquilibriumTest.m21eps=1e-7;

Assemble the input structure, and calculate the equilibrium

calculateLifoEquilibriumTest.m25ARG.pi = pi;
calculateLifoEquilibriumTest.m26ARG.kappa = kappa;
calculateLifoEquilibriumTest.m27ARG.phi = phi;
calculateLifoEquilibriumTest.m28ARG.omega = omega;
calculateLifoEquilibriumTest.m29ARG.Pi = Pi;
calculateLifoEquilibriumTest.m30ARG.beta = beta;
calculateLifoEquilibriumTest.m31ARG.convergenceTolerance = 1e-7;
calculateLifoEquilibriumTest.m32ARG.nCheck = [];
calculateLifoEquilibriumTest.m33ARG.V = [];
calculateLifoEquilibriumTest.m34ARG.nPrime = [];
calculateLifoEquilibriumTest.m35
calculateLifoEquilibriumTest.m36OUT=calculateLifoEquilibrium(ARG);

We examine the equilibrium calculations by plotting the value functions. The resulting figure has one panel for each of the small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image continuation values.

calculateLifoEquilibriumTest.m40nCheck=OUT.nCheck;
calculateLifoEquilibriumTest.m41V=OUT.valueFunction;
calculateLifoEquilibriumTest.m42
calculateLifoEquilibriumTest.m43figure(1)
calculateLifoEquilibriumTest.m44for i=1:nCheck;
calculateLifoEquilibriumTest.m45 subplot(nCheck,1,i)

Place a horizontal line at the sunk cost of entry.

calculateLifoEquilibriumTest.m49 plot(omega,phi(i)*ones(size(omega)),'LineWidth',2,'Color',[0.8 0.8 0.8]);

Set the axes' limits so that all panels are on the same scale.

calculateLifoEquilibriumTest.m53 xlim([min(omega) max(omega)]);
calculateLifoEquilibriumTest.m54 ylim([0 ceil(max(V(1,:,1)))]);

Label this panel.

calculateLifoEquilibriumTest.m58 title(['R = ' int2str(i)],'FontSize',16,'Interpreter','latex');
calculateLifoEquilibriumTest.m59 hold;
calculateLifoEquilibriumTest.m60
calculateLifoEquilibriumTest.m61 for j=i:nCheck;

Since the value function is discontinuous at some points, we use no line and instead mark each value with a dot. Where the value function is continuous, these blend together to form the appereance of continuity.

calculateLifoEquilibriumTest.m66 plot(omega,V(i,:,j),'LineStyle','none','Marker','.');
calculateLifoEquilibriumTest.m67 end
calculateLifoEquilibriumTest.m68 set(gca,'box','off','FontSize',14)
calculateLifoEquilibriumTest.m69
calculateLifoEquilibriumTest.m70end
calculateLifoEquilibriumTest.m71set(gcf,'Color',[1 1 1])

Save the figure as a .jpg file.

calculateLifoEquilibriumTest.m75set(gcf,...
calculateLifoEquilibriumTest.m76 'PaperUnits','in','PaperSize',[5 10],...
calculateLifoEquilibriumTest.m77 'PaperPositionMode','manual',...
calculateLifoEquilibriumTest.m78 'PaperPosition',[0 0 5 10]); Set the figure to the desired size.
calculateLifoEquilibriumTest.m79
calculateLifoEquilibriumTest.m80print -djpeg -painters calculateLifoEquilibriumTest.jpg
calculateLifoEquilibriumTest.m81
calculateLifoEquilibriumTest.m82makequit;

This is an image.

Figure 5: Equilibrium Value Functions for the Calculated Example

Figure 5 presents the calculated equilibrium value functions. The format is the same as that used in Figure . The light-gray horizontal lines mark the sunk cost of entry for each potential competitor. The value functions' piecewise linearity arises from the same specification of the demand process that simplified the pencil and paper example. The value of a firm with rank 3 never equals or exceeds its cost of entry, so the simplifying assumption that at most two firms serve the industry was without loss of generality if we only concern ourselves with the industry's ergodic distribution.

2B.3The Ergodic Distribution

The calculation of the equilibrium's ergodic distribution over small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image has two steps.

  1. Create the Markov transition matrix for this pair.
  2. Calculate the eigenvector associated with its unit eigenvalue.

The functions calculateLifoTransitionMatrix and calculateLifoErgodicDistribution handle these tasks.

2B.3.1The Markov Transition Matrix

The function that calculates the LIFO equilibrium transition matrix for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image takes its input from a single structure, ARG, with the following fields.

transitionMatrixForC
The n small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image n Markov transition matrix governing the exogenous evolution of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
supportForC
A column vector with n elements, each giving one possible value for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
minimumN
The minimum value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
maximumN
The maximum value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
nextN
An n small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image |(nCheck-nHat+1) matrix of integers in nCat,...,nCheck. The small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image 'th element gives the number of firms active at the end of the period if the period starts with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image omega(i) and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image nHat+j-1.

The values for all of these can be easily constructed from the output structure of calculateLifoEquilibrium.

The function's output structure has two fields.

supportForCandN
The n(nCheck-nHat+1) small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image 2 matrix of all possible small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image pairs.
transitionMatrixForCandN
The n(nCheck-nhat+1) small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image n(nCheck-nHat+1) Markov transition matrix on supportForCandN

calculateLifoTransitionMatrix.m28function OUT = calculateLifoTransitionMatrix(ARG)
calculateLifoTransitionMatrix.m29
calculateLifoTransitionMatrix.m30Pi = ARG.transitionMatrixForC;
calculateLifoTransitionMatrix.m31omega = ARG.supportForC;
calculateLifoTransitionMatrix.m32n = length(omega);
calculateLifoTransitionMatrix.m33nHat = ARG.minimumN;
calculateLifoTransitionMatrix.m34nCheck = ARG.maximumN;
calculateLifoTransitionMatrix.m35nPrime = ARG.nextN;

First, construct the support for the small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . This vertically tiles nCheck-nHat+1copies of omega and concatinates it with nHat:1:nCheck small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image ones(n,1).

calculateLifoTransitionMatrix.m39OUT.supportForCandN = [repmat(omega,nCheck-nHat+1,1) kron((nHat:1:nCheck)',ones(n,1))];
calculateLifoTransitionMatrix.m40m = length(OUT.supportForCandN);

The transition matrix for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image simply distributes the elements of Pi across an m small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image m using the transition rule for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Except in the case where nHat equals nCheck, this matrix is sparse, so we set it up as such. Using a sparse matrix for this cuts computation time here and in calculateLifoEquilibrium tremendously.

The matrix of non-zero coefficients.

calculateLifoTransitionMatrix.m49nonZeroCoefficients = repmat(Pi,nCheck-nHat+1,1);

Matrix of row indices for the elements of nonZeroCoefficients.

calculateLifoTransitionMatrix.m53rowIndices=(1:1:m)'*ones(1,n);

Matrix of column indices for the elements of nonZeroCoefficients.

calculateLifoTransitionMatrix.m57columnIndices = ones(m,1)*(1:1:n) + (nPrime(:)-nHat)*ones(1,n)*n;
calculateLifoTransitionMatrix.m58
calculateLifoTransitionMatrix.m59OUT.transitionMatrixForCandN=sparse(rowIndices(:),columnIndices(:),nonZeroCoefficients(:),m,m);

2B.3.2Eigenvector Calcualtion

The eigenvalue calculation takes place within calculateLifoErgodicDistribution. It gets its input from the structure EQUILIBRIUM, which has the same fields as the output of calculateLifoEquilibrium. With this it constructs the required inputs for calculateLifoTransitionMatrix, calculates the eigenvector of interest, and scales the result so that its elements sum to one.

Its single output, the structure ERGODIC has three fields.

transitionMatrix
The calculated transition matrix for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
support
A vector with two columns. Each row is one possible combination of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
distribution
The ergodic distribution over support.

calculateLifoErgodicDistribution.m20function ERGODIC = calculateLifoErgodicDistribution(EQUILIBRIUM)

Start with the construction of the input structure for calculateLifoTransitionMatrix.

calculateLifoErgodicDistribution.m25TRANSITION_ARG.supportForC = EQUILIBRIUM.omega;
calculateLifoErgodicDistribution.m26TRANSITION_ARG.transitionMatrixForC = EQUILIBRIUM.Pi;
calculateLifoErgodicDistribution.m27TRANSITION_ARG.minimumN = 0;
calculateLifoErgodicDistribution.m28TRANSITION_ARG.maximumN = EQUILIBRIUM.nCheck;
calculateLifoErgodicDistribution.m29TRANSITION_ARG.nextN = EQUILIBRIUM.equilibriumFirmCount;
calculateLifoErgodicDistribution.m30
calculateLifoErgodicDistribution.m31TRANSITION=calculateLifoTransitionMatrix(TRANSITION_ARG);

Get the transition matrix for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and calculate the eigenvector associated with the unit eigenvalue.

calculateLifoErgodicDistribution.m35P = TRANSITION.transitionMatrixForCandN;
calculateLifoErgodicDistribution.m36
calculateLifoErgodicDistribution.m37[e,d] = eigs(P',1,1); The final “1” tells eigs to search around 1.
calculateLifoErgodicDistribution.m38if abs(d-1)>EQUILIBRIUM.convergenceTolerance
calculateLifoErgodicDistribution.m39 error(['Eigenvalue calculation failed. d = ' num2str(d,'%10.5f')]);
calculateLifoErgodicDistribution.m40end
calculateLifoErgodicDistribution.m41
calculateLifoErgodicDistribution.m42e = e/sum(e); This ensures that the majority of e's elements are positive.
calculateLifoErgodicDistribution.m43e(e<0) = 0; A few that are actually zero are numerically small and negative. Set these to zero.
calculateLifoErgodicDistribution.m44e = e/sum(e); Norm the eigenvector again. Now its elements represent probabilities.
calculateLifoErgodicDistribution.m45

Assemble the output structure and finish.

calculateLifoErgodicDistribution.m49ERGODIC.transitionMatrix=P;
calculateLifoErgodicDistribution.m50ERGODIC.support=TRANSITION.supportForCandN;
calculateLifoErgodicDistribution.m51ERGODIC.distribution = e;
calculateLifoErgodicDistribution.m52
calculateLifoErgodicDistribution.m53end

To test the calculation of the LIFO equilibrium's transition matrix and ergodic distribution, we apply the code to a model with very few demand states and inspect the output. Except for the reduced dimensionality of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the parameters used are the same as those in calculateLifoEquilibriumTest.

calculateLifoErgodicDistributionTest.m7chat=0.1;
calculateLifoErgodicDistributionTest.m8ccheck=2.5;
calculateLifoErgodicDistributionTest.m9step=1.2;
calculateLifoErgodicDistributionTest.m10omega=(chat:step:ccheck)'; This has three points.
calculateLifoErgodicDistributionTest.m11N = length(omega);
calculateLifoErgodicDistributionTest.m12lambda=0.1;
calculateLifoErgodicDistributionTest.m13Pi=(1-lambda)*eye(N)+lambda*ones(N,N)/N;
calculateLifoErgodicDistributionTest.m14
calculateLifoErgodicDistributionTest.m15kappa=1.25;
calculateLifoErgodicDistributionTest.m16pi = @(x) 2*ones(size(x,1),1);
calculateLifoErgodicDistributionTest.m17
calculateLifoErgodicDistributionTest.m18beta=1.05^(-5);
calculateLifoErgodicDistributionTest.m19phi = @(x) ones(length(x),1);
calculateLifoErgodicDistributionTest.m20
calculateLifoErgodicDistributionTest.m21eps=1e-7;
calculateLifoErgodicDistributionTest.m22
calculateLifoErgodicDistributionTest.m23ARG.pi = pi;
calculateLifoErgodicDistributionTest.m24ARG.kappa = kappa;
calculateLifoErgodicDistributionTest.m25ARG.phi = phi;
calculateLifoErgodicDistributionTest.m26ARG.omega = omega;
calculateLifoErgodicDistributionTest.m27ARG.Pi = Pi;
calculateLifoErgodicDistributionTest.m28ARG.beta = beta;
calculateLifoErgodicDistributionTest.m29ARG.convergenceTolerance = 1e-7;
calculateLifoErgodicDistributionTest.m30ARG.nCheck = [];
calculateLifoErgodicDistributionTest.m31ARG.V = [];
calculateLifoErgodicDistributionTest.m32ARG.nPrime = [];
calculateLifoErgodicDistributionTest.m33
calculateLifoErgodicDistributionTest.m34LIFO_EQUILIBRIUM = calculateLifoEquilibrium(ARG);
calculateLifoErgodicDistributionTest.m35LIFO_ERGODIC = calculateLifoErgodicDistribution(LIFO_EQUILIBRIUM);
calculateLifoErgodicDistributionTest.m36
calculateLifoErgodicDistributionTest.m37makequit;

Inspection of the results shows that the function is accurate in this case.

3CThe Experiments

3C.1Equilibrium without Threshold Rules

The paper's first substantial equilibrium calculation using the general model is the example of equilibrium without threshold rules in Section 3. For it, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is on an evenly spaced grid of 3000 points between -1.5 and 1.5. The probability of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image remaining unchanged is small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . With probability small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image it falls to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and with the same probability it rises to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . The model's other parameters in this example are small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

Equilibrium Calculation

Setting up the problem's parameters is straightforward. We place the support of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image into omega.

equilibriumWithoutThresholds.m15omega=exp(-1.5:0.001:1.5)';
equilibriumWithoutThresholds.m16N=length(omega);

For small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image omega(1)...omega(300), negative innovations bring small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to omega(1). This code could be cleaner if we calculated this index as a function of the grid step length, but it suffices for the purposes of a counterexample.

equilibriumWithoutThresholds.m21Pi=eye(length(omega));
equilibriumWithoutThresholds.m22for i=1:1:300
equilibriumWithoutThresholds.m23 Pi(i,i)=0.5;
equilibriumWithoutThresholds.m24 Pi(i,1)=Pi(i,1)+0.25;
equilibriumWithoutThresholds.m25 Pi(i,i+300)=0.25;
equilibriumWithoutThresholds.m26end

For small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image omega(N-299)...omega(N), positive innovations bring small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to omega(N).

equilibriumWithoutThresholds.m30for i=N-300+1:1:N;
equilibriumWithoutThresholds.m31 Pi(i,i)=0.5;
equilibriumWithoutThresholds.m32 Pi(i,i-300)=0.25;
equilibriumWithoutThresholds.m33 Pi(i,end)=Pi(i,end)+0.25;
equilibriumWithoutThresholds.m34end

For all other values of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the bounded state space does not constraint positive or negative innovations to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

equilibriumWithoutThresholds.m38for i=301:1:N-300
equilibriumWithoutThresholds.m39 Pi(i,i)=0.5;
equilibriumWithoutThresholds.m40 Pi(i,i-300)=0.25;
equilibriumWithoutThresholds.m41 Pi(i,i+300)=0.25;
equilibriumWithoutThresholds.m42end

Create the anonymous function handle for the producers' surplus per customer.

equilibriumWithoutThresholds.m46pi = @(x) 2*ones(size(x,1),1);

Set the per period fixed cost.

equilibriumWithoutThresholds.m50kappa=1.0;

Set the discount factor.

equilibriumWithoutThresholds.m54beta=1.05^(-1);

Create the anonymous function handle for the sunk cost of entry.

equilibriumWithoutThresholds.m58phi = @(x) 10*ones(length(x),1);

Choose a convergence tolerance.

equilibriumWithoutThresholds.m62eps=1e-7;

To calculate the equilibrium, we assemble the model's parameters into the required structure and call calculateLifoEquilibrium.

equilibriumWithoutThresholds.m66ARG.pi = pi;
equilibriumWithoutThresholds.m67ARG.kappa = kappa;
equilibriumWithoutThresholds.m68ARG.phi = phi;
equilibriumWithoutThresholds.m69ARG.omega = omega;
equilibriumWithoutThresholds.m70ARG.Pi = Pi;
equilibriumWithoutThresholds.m71ARG.beta = beta;
equilibriumWithoutThresholds.m72ARG.convergenceTolerance = eps;
equilibriumWithoutThresholds.m73ARG.nCheck = 2;
equilibriumWithoutThresholds.m74ARG.V = [];
equilibriumWithoutThresholds.m75ARG.nPrime = [];
equilibriumWithoutThresholds.m76
equilibriumWithoutThresholds.m77OUT=calculateLifoEquilibrium(ARG);
equilibriumWithoutThresholds.m78

Reporting

Figure 3 in the text plots the equilibrium value functions from this example. Just as with the pencil and papaer example, we save the relevant results to external files and use pgfTikz code in Appendix 3C to create the plot within the LaTeX file.

The horizontal axis plots small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image in logarithms, so we transform the state space accordingly.

equilibriumWithoutThresholds.m86omega=log(omega);

Just as with the pencil and paper example, the figure has two panels. The first gives the initial entrant's value function and the second gives value function of the later entrant. For the later, we require the entry and exit thresholds.

equilibriumWithoutThresholds.m91v2=squeeze(OUT.valueFunction(2,:,:));
equilibriumWithoutThresholds.m92v2=v2(:,2);
equilibriumWithoutThresholds.m93if min(v2)<=phi(2);
equilibriumWithoutThresholds.m94 overlineC=omega(find(v2<=phi(2),1,'last'));
equilibriumWithoutThresholds.m95else
equilibriumWithoutThresholds.m96 overlineC=omega(1);
equilibriumWithoutThresholds.m97end
equilibriumWithoutThresholds.m98
equilibriumWithoutThresholds.m99if min(v2)==0;
equilibriumWithoutThresholds.m100 underlineC=omega(find(v2==0,1,'last'));
equilibriumWithoutThresholds.m101else
equilibriumWithoutThresholds.m102 underlineC=omega(1);
equilibriumWithoutThresholds.m103end

The first entrant's value function crosses the cost of entry twice. We call the two non-overlapping segments of the state space where it exceeds small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . The plot requires both of these segments' boundaries.

equilibriumWithoutThresholds.m108v1=squeeze(OUT.valueFunction(1,:,:));
equilibriumWithoutThresholds.m109Alow=min(omega(v1(:,1)>=phi(1)));
equilibriumWithoutThresholds.m110Ahigh=min(omega(v1(:,1)<=phi(1) & omega>Alow));
equilibriumWithoutThresholds.m111Clow=min(omega(v1(:,1)>=phi(1) & omega>Ahigh));
equilibriumWithoutThresholds.m112Chigh=max(omega);

The LaTeX file uses these results by loading them into macros, which we store in the file equilibriumWithoutThresholdsConstants.tex.

equilibriumWithoutThresholds.m116f1=fopen('pgfTikZ/equilibriumWithoutThresholdsConstants.tex','w');
equilibriumWithoutThresholds.m117
equilibriumWithoutThresholds.m118fprintf(f1,'\\def\\ymax{%3.2f}\n',max(v1(:,1)));
equilibriumWithoutThresholds.m119fprintf(f1,'\\def\\cunderbartwo{%3.2f}\n',underlineC);
equilibriumWithoutThresholds.m120fprintf(f1,'\\def\\coverbartwo{%3.2f}\n',overlineC);
equilibriumWithoutThresholds.m121fprintf(f1,'\\def\\phione{%3.2f}\n',phi(1));
equilibriumWithoutThresholds.m122fprintf(f1,'\\def\\phitwo{%3.2f}\n',phi(2));
equilibriumWithoutThresholds.m123fprintf(f1,'\\def\\chat{%3.2f}\n',min(omega));
equilibriumWithoutThresholds.m124fprintf(f1,'\\def\\ccheck{%3.2f}\n',max(omega));
equilibriumWithoutThresholds.m125fprintf(f1,'\\def\\Alow{%3.2f}\n',Alow);
equilibriumWithoutThresholds.m126fprintf(f1,'\\def\\Ahigh{%3.2f}\n',Ahigh);
equilibriumWithoutThresholds.m127fprintf(f1,'\\def\\Clow{%3.2f}\n',Clow);
equilibriumWithoutThresholds.m128fprintf(f1,'\\def\\Chigh{%3.2f}\n',Chigh);
equilibriumWithoutThresholds.m129
equilibriumWithoutThresholds.m130fclose(f1);

The final task is to export the calculated value functions themselves. Since the first entrant's value function is quite choppy, the pgfTikZ code only places markers at each of the grid points. Nevertheless, we save the “monopoly” and “duopoly” values to separate files so that the code can give them separate colors. As always, we place a dummy variable at the end to overcome the table loading bug in pgfplots.

equilibriumWithoutThresholds.m136v11=[omega(omega<=overlineC) v1(omega<=overlineC,1)]; Note that fprintf spits out its input in column order.
equilibriumWithoutThresholds.m137
equilibriumWithoutThresholds.m138f1=fopen('pgfTikZ/equilibriumWithoutThresholdsV11.csv','w');
equilibriumWithoutThresholds.m139fprintf(f1,'C, v11, dummy\n');
equilibriumWithoutThresholds.m140fprintf(f1,'%3.3f, %3.3f, 1.0\n',v11');
equilibriumWithoutThresholds.m141fclose(f1);
equilibriumWithoutThresholds.m142
equilibriumWithoutThresholds.m143v12=[omega(omega>underlineC) v1(omega>underlineC,2)];
equilibriumWithoutThresholds.m144f1=fopen('pgfTikZ/equilibriumWithoutThresholdsV12.csv','w');
equilibriumWithoutThresholds.m145fprintf(f1,'C, v12, dummy\n');
equilibriumWithoutThresholds.m146fprintf(f1,'%3.3f, %3.3f, 1.0\n',v12');
equilibriumWithoutThresholds.m147fclose(f1);
equilibriumWithoutThresholds.m148
equilibriumWithoutThresholds.m149v2=[omega v2];
equilibriumWithoutThresholds.m150f1=fopen('pgfTikZ/equilibriumWithoutThresholdsV2.csv','w');
equilibriumWithoutThresholds.m151fprintf(f1,'C, v2, dummy\n');
equilibriumWithoutThresholds.m152fprintf(f1,'%3.3f, %3.3f, 1.0\n',v2');
equilibriumWithoutThresholds.m153fclose(f1);
equilibriumWithoutThresholds.m154
equilibriumWithoutThresholds.m155makequit;

This is an image.

Figure 6: Value Functions from the Example Equilibrium without Threshold Rules

Figure 6 presents the equilibrium plot. It is identical to that in the text. It would be desirable to scale this up for this document, but changing the scale of the tikzpicture environment does not properly change plots using points defined by the axis coordinate system provided by pgfplots.

3C.2Table of Equilibrium Thresholds

Table I in Section 4.3 of the text presents the equilibrium entry and continuation thresholds for four parameterizations of the model, each calculated with and without an artificial barrier to entry beyond the fourth firm. In each of these, the Markov chain of the demand process approximates a random walk, as described in Section . The parameterizations only differ in this process's innovation variance. The four values of interest are in the vector sigma

tableOfThresholds.m13sigma=[0 0.05 0.1 0.15];

We hold the model's remaining parameters constant across experiments. Since the calculations for Table II use these same values, we call the code for their assignment from a file accessible by both programs, lifoTableParameters.

tableOfThresholds.m18lifoTableParameters;

The model parameters held constant across experiments can be divided into two groups. The first is used only to construct the Markov chain. We place these into the structure markovChainARG, which has all of the fields required by the input to markovChain.

Set the parameters describe the Markov chain's support.

lifoTableParameters.m10markovChainARG.omega.center = 0;
lifoTableParameters.m11markovChainARG.omega.step = 0.005;
lifoTableParameters.m12markovChainARG.omega.width = 3;

Set the parameters that describe the underlying autoregression.

lifoTableParameters.m16markovChainARG.autoRegression.rho = 1.0;
lifoTableParameters.m17markovChainARG.autoRegression.sigma = sigma(1); This is a dummy argument that the loop below will replace.

Set the parameters describing the underlying innovation distribution and its approximation with a mixture of uniform distributions.

lifoTableParameters.m21approximate.F = @(x) (1+erf(x/sqrt(2)))./2;
lifoTableParameters.m22approximate.Frange = 4.0;
lifoTableParameters.m23approximate.k = 51;
lifoTableParameters.m24
lifoTableParameters.m25markovChainARG.uniformMixtureApproximation = approximate;

The second set of parameters describe payoffs. We place these into the structure lifoARG.

lifoTableParameters.m29lifoARG.beta = 1/1.05;
lifoTableParameters.m30lifoARG.pi = @(x) 4*ones(size(x,1),1);
lifoTableParameters.m31lifoARG.kappa = 1.75;
lifoTableParameters.m32lifoARG.phi = @(x) 0.25*lifoARG.beta/(1-lifoARG.beta)*ones(size(x,1),1);

Equilibrium calculation requires us to choose a convergence tolerance for the Bellman equation iteration.

lifoTableParameters.m37lifoARG.convergenceTolerance = 1e-7;

So that we can preallocate the matrices storing the equilibrium thresholds, we calculate here small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , an upper bound on the number of active firms. To do so, we set up an anonymous function that yields each firm's flow profit as a function of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and then search for the lowest number of firms that makes it negative. Since small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is constant in this exercise, we could just as easily have calculated small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image algebraically. We adopt this code so that our program can be more easily generalized.

lifoTableParameters.m44f = @(x) x(:,1).*lifoARG.pi(x(:,2))./x(:,2)-lifoARG.kappa;
lifoTableParameters.m45
lifoTableParameters.m46nCheck=1;
lifoTableParameters.m47cCheck=exp(markovChainARG.omega.width/2);
lifoTableParameters.m48while f([cCheck nCheck])>0
lifoTableParameters.m49 nCheck=nCheck+1;
lifoTableParameters.m50end
lifoTableParameters.m51nCheck = nCheck-1;
lifoTableParameters.m52lifoARG.nCheck = nCheck;

To construct the table, we cycle through the values in sigma. For each one, we first build the approximating Markov chain. Then, we calculate the equilibrium with and without the exogenous barrier to entry. We store the resulting threshold calculations in

tableOfThresholds.m27freeEntryThresholds = zeros(length(sigma),nCheck);
tableOfThresholds.m28freeContinuationThresholds = zeros(length(sigma),nCheck);
tableOfThresholds.m29fourEntryThresholds = zeros(length(sigma),4);
tableOfThresholds.m30fourContinuationThresholds = zeros(length(sigma),4);
tableOfThresholds.m31
tableOfThresholds.m32freeEntryExitRate = zeros(length(sigma),1);

Footnote 13 of the text reports the exit rates from three of the experiments. Accordingly, we calculate the barrier-free equilibrium's ergodic distribution over small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and use this and the Markov chain to calculate the ergodic distribution's exit rate.

tableOfThresholds.m38for i=1:length(sigma);
tableOfThresholds.m39
tableOfThresholds.m40 Construct the Markov Chain and use it to finish lifoARG.
tableOfThresholds.m41 markovChainARG.autoRegression.sigma = sigma(i);
tableOfThresholds.m42 MARKOVCHAIN = markovChain(markovChainARG);
tableOfThresholds.m43
tableOfThresholds.m44 lifoARG.Pi = MARKOVCHAIN.transitionMatrix;
tableOfThresholds.m45 lifoARG.omega = exp(MARKOVCHAIN.support');
tableOfThresholds.m46
tableOfThresholds.m47 Calculate the equilibrium without a barrier to entry.
tableOfThresholds.m48 lifoARG.nCheck = nCheck;
tableOfThresholds.m49 freeEntryEQUILIBRIUM = calculateLifoEquilibrium(lifoARG);
tableOfThresholds.m50
tableOfThresholds.m51 Calculate the entry and continuation thresholds.
tableOfThresholds.m52 THRESHOLDS = calculateThresholds(freeEntryEQUILIBRIUM);
tableOfThresholds.m53
tableOfThresholds.m54 Store the results.
tableOfThresholds.m55 freeEntryThresholds(i,:) = THRESHOLDS.entry;
tableOfThresholds.m56 freeContinuationThresholds(i,:) = THRESHOLDS.continuation;
tableOfThresholds.m57
tableOfThresholds.m58 Repeat the analysis with an exogenous barrier to entry.
tableOfThresholds.m59 lifoARG.nCheck = 4;
tableOfThresholds.m60 fourEntryEQUILIBRIUM = calculateLifoEquilibrium(lifoARG);
tableOfThresholds.m61 THRESHOLDS = calculateThresholds(fourEntryEQUILIBRIUM);
tableOfThresholds.m62 fourEntryThresholds(i,:) = THRESHOLDS.entry;
tableOfThresholds.m63 fourContinuationThresholds(i,:) = THRESHOLDS.continuation;
tableOfThresholds.m64
tableOfThresholds.m65 if sigma(i)>0
tableOfThresholds.m66 Calculate the barrier-free equilibrium's ergodic distribution.
tableOfThresholds.m67 ERGODIC=calculateLifoErgodicDistribution(freeEntryEQUILIBRIUM);
tableOfThresholds.m68 ERGODIC.nPrime=freeEntryEQUILIBRIUM.equilibriumFirmCount;
tableOfThresholds.m69
tableOfThresholds.m70 Use these results to calculate equilibrium statistics
tableOfThresholds.m71 STATS = tabulateEquilibriumStatistics(ERGODIC);
tableOfThresholds.m72 freeEntryExitRate(i) = STATS.exitRate;
tableOfThresholds.m73 end
tableOfThresholds.m74
tableOfThresholds.m75end

Now, we proceed with the reporting of the results. The entry and exit thresholds for a rank with zero probability in the ergodic distribution are left blank in the table. To indicate this, we replace them with NaN. We do this only for the barrier-free equilibrium, because it turns out to be unnecessary with a barrier.

tableOfThresholds.m83blankMask=(freeEntryThresholds==max(freeEntryEQUILIBRIUM.omega));
tableOfThresholds.m84freeEntryThresholds(blankMask)=NaN;
tableOfThresholds.m85freeContinuationThresholds(blankMask)=NaN;

Eliminate any columns beginning with NaN.

tableOfThresholds.m89keepColumns=find(blankMask(1,:)==0);
tableOfThresholds.m90freeEntryThresholds=freeEntryThresholds(:,keepColumns);
tableOfThresholds.m91freeContinuationThresholds=freeContinuationThresholds(:,keepColumns);

Export the results to LaTeX files for inclusion in the paper, using the code in tableOfThresholdsLaTeX. Appendix 4D presents that code in detail.

tableOfThresholds.m95tableOfThresholdsLaTeX;
tableOfThresholds.m96
tableOfThresholds.m97makequit;
tableOfThresholds.m98

3C.3Table of Ordered Probit Thresholds

The paper concludes by examining what a static analysis of market size and market structure, such as that of Bresnahan and Reiss (1991), would uncover if it used data drawn from the ergodic distribution of our model. For this, we suppose that the researcher renders the LIFO model essentially static using the following assumptions.

That is, the market begins with no incumbents, at which time the initial value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is drawn. This value never changes. In such an environment, there is no distinction between fixed and sunk costs, so we set the later to zero.

In equilibrium, all entry occurs in the first period, and there is no subsequent exit. Equilibrium requires that all entering firms earn a positive profit and that the potential entrant choosing to stay inactive would earn a nonpostive profit.

(6) small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
(7) small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

Suppose that we have observations of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image from a cross section of independent markets, and we wish to combine these observations with (6) and (7) to infer the values of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image scaled by small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Let small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image denote the market size at which small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image firms choose to enter and an small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image 'th entering firm would earn exactly zero profit. The free-entry conditions can be rearranged to yield

(8)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

In (8), small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . By observing the market size at which the number of active firms jumps from small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , we can determine small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and therefore small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

Of course, markets differ in unobservable ways from each other, so real data do not display such jumps. To make the model suitable for empirical use, we can follow and suppose that the fixed cost of production is stochastic across markets but the same for each potential participant in a given market. We denote this common cost with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , where small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . With this change, the free-entry conditions become

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

and

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

With these free-entry conditions, the probability that exactly small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image firms serve an industry with market-size small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

Here, the parameter vector small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . This is just the standard ordered-probit likelihood function.

Given any joint distribution of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the population likelihood function,

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

is concave in small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Therefore, we can always define small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image as the unique maximizer of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . It is with this tool in hand that we approach the problem of evaluating the consequences of actual dynamics for static market-size/market-structure analysis. Given the joint distribution of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image from the LIFO model, we calculate small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and thereby quantify the effects of dynamic model misspecification.

The function orderedProbitMaximumLikelihoodEstimation contains the code implementing these calculations. Appendix 2B describes this in detail. It has a single argument with three fields. The first two have identical names to those in the output structure of calculateLifoErgodicDistribution.

support
An small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image matrix. Each row gives one element of the support for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
distribution
A column vector of length small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Its small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image 'th element gives the probability of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image equaling the small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image 'th row of support
epsilon
A scalar close to zero. The function uses this to avoid problems with taking the logarithm of zero.

The fields of its single output are

sigma
The estimated value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
thresholds
A vector containing the estimated ordered-probit thresholds.
indices
A vector the same size as thresholds containing the number of firms corresponding to each threshold. Both this and thresholds are sorted in ascending order.

To construct the table of ordered probit thresholds, we cycle through the non-zero elements of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image used for Table I and calculate the LIFO equilibrium without a barrier to entry.

tableOfOrderedProbitThresholds.m71sigma=[0.05 0.1 0.15];

The other model parameters can be divided into two groups. The first is used only to construct the Markov chain. We place these into the structure markovChainARG, which has all of the fields required by the input to markovChain.

Set the parameters describe the Markov chain's support.

tableOfOrderedProbitThresholds.m80markovChainARG.omega.center = 0;
tableOfOrderedProbitThresholds.m81markovChainARG.omega.step = 0.005;
tableOfOrderedProbitThresholds.m82markovChainARG.omega.width = 3;

Set the parameters that describe the underlying autoregression.

tableOfOrderedProbitThresholds.m86markovChainARG.autoRegression.rho = 1.0;
tableOfOrderedProbitThresholds.m87markovChainARG.autoRegression.sigma = sigma(1); This is a dummy argument that the loop below will replace.

Set the parameters describing the underlying innovation distribution and its approximation with a mixture of uniform distributions.

tableOfOrderedProbitThresholds.m91approximate.F = @(x) (1+erf(x/sqrt(2)))./2;
tableOfOrderedProbitThresholds.m92approximate.Frange = 4.0;
tableOfOrderedProbitThresholds.m93approximate.k = 51;
tableOfOrderedProbitThresholds.m94
tableOfOrderedProbitThresholds.m95markovChainARG.uniformMixtureApproximation = approximate;
tableOfOrderedProbitThresholds.m96

The second set of parameters describe payoffs. We place these into the structure lifoARG.

tableOfOrderedProbitThresholds.m100lifoARG.beta = 1/1.05;
tableOfOrderedProbitThresholds.m101lifoARG.pi = @(x) 4*ones(size(x,1),1);
tableOfOrderedProbitThresholds.m102lifoARG.kappa = 1.75;
tableOfOrderedProbitThresholds.m103lifoARG.phi = @(x) 0.25*lifoARG.beta/(1-lifoARG.beta)*ones(size(x,1),1);

Equilibrium calculation also requires us to choose a convergence tolerance for % the Bellman equation iteration.

tableOfOrderedProbitThresholds.m107lifoARG.convergenceTolerance = 1e-7;

So that we can preallocate the matrices storing the equilibrium thresholds, we calculate here small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , an upper bound on the number of active firms. To do so, we set up an anonymous function that yields each firm's flow profit as a function of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and then search for the lowest number of firms that makes it negative. Since small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is constant in this exercise, we could just as easily have calculated small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image algebraically. We adopt this code so that our program can be more easily generalized.

tableOfOrderedProbitThresholds.m114f = @(x) x(:,1).*lifoARG.pi(x(:,2))./x(:,2)-lifoARG.kappa;
tableOfOrderedProbitThresholds.m115
tableOfOrderedProbitThresholds.m116nCheck=1;
tableOfOrderedProbitThresholds.m117cCheck=exp(markovChainARG.omega.width/2);
tableOfOrderedProbitThresholds.m118while f([cCheck nCheck])>0
tableOfOrderedProbitThresholds.m119 nCheck=nCheck+1;
tableOfOrderedProbitThresholds.m120end
tableOfOrderedProbitThresholds.m121nCheck = nCheck-1;
tableOfOrderedProbitThresholds.m122lifoARG.nCheck = nCheck;

To construct the table, we cycle through the values in sigma. For each one, we first build the approximating Markov chain. Then, we calculate the equilibrium with and without the exogenous barrier to entry. We store the resulting threshold calculations in

tableOfOrderedProbitThresholds.m128probitThresholds = zeros(length(sigma),nCheck);
tableOfOrderedProbitThresholds.m129piRatios = zeros(length(sigma),nCheck);
tableOfOrderedProbitThresholds.m130
tableOfOrderedProbitThresholds.m131for i=1:length(sigma);

Construct the Markov Chain and use it to finish lifoARG.

tableOfOrderedProbitThresholds.m135 markovChainARG.autoRegression.sigma = sigma(i);
tableOfOrderedProbitThresholds.m136 MARKOVCHAIN = markovChain(markovChainARG);
tableOfOrderedProbitThresholds.m137
tableOfOrderedProbitThresholds.m138 lifoARG.Pi = MARKOVCHAIN.transitionMatrix;
tableOfOrderedProbitThresholds.m139 lifoARG.omega = exp(MARKOVCHAIN.support');

Calculate the equilibrium.

tableOfOrderedProbitThresholds.m143 lifoARG.nCheck = nCheck;
tableOfOrderedProbitThresholds.m144 freeEntryEQUILIBRIUM = calculateLifoEquilibrium(lifoARG);

Calculate the equilibrium's ergodic distribution.

tableOfOrderedProbitThresholds.m148 ERGODIC=calculateLifoErgodicDistribution(freeEntryEQUILIBRIUM);

Use the ergodic distribution to calculate the ordered-probit thresholds.

tableOfOrderedProbitThresholds.m152 ERGODIC.epsilon=1e-7;
tableOfOrderedProbitThresholds.m153 PROBIT=orderedProbitMaximumLikelihoodEstimation(ERGODIC);

Store the estimated thresholds.

tableOfOrderedProbitThresholds.m157 probitThresholds(i,PROBIT.indices)=PROBIT.thresholds;

Calculate estimates of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image (up to scale).

tableOfOrderedProbitThresholds.m161 piHat=PROBIT.indices./PROBIT.thresholds;

Calculate the implied values of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

tableOfOrderedProbitThresholds.m165 piHatChange=piHat(2:end)./piHat(1:end-1);

Accumulate these changes to get the implied values of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

tableOfOrderedProbitThresholds.m169 piHatRatio=cumprod(piHatChange);

Pad piHatRatio with a one on the left-hand side and save it.

tableOfOrderedProbitThresholds.m173 piRatios(i,PROBIT.indices)=[1 piHatRatio];
tableOfOrderedProbitThresholds.m174
tableOfOrderedProbitThresholds.m175end

Following the construction of Table I, we place NaN's in probitThresholds and piRatios in the positions corresponding to blank elements in the two panels, and we then remove columns containing only NaN's

tableOfOrderedProbitThresholds.m180probitThresholds(probitThresholds==0)=NaN;
tableOfOrderedProbitThresholds.m181piRatios(piRatios==0)=NaN;
tableOfOrderedProbitThresholds.m182
tableOfOrderedProbitThresholds.m183keepColumns=find(~isnan(probitThresholds(1,:)));
tableOfOrderedProbitThresholds.m184probitThresholds=probitThresholds(:,keepColumns);
tableOfOrderedProbitThresholds.m185piRatios=piRatios(:,keepColumns);

This completes the required calculations for Table II. The file tableOfOrderedProbitThresholdsLaTeX.m contains the code for creating the table itself. See Appendix 4D for its description.

tableOfOrderedProbitThresholds.m190tableOfOrderedProbitThresholdsLaTeX;
tableOfOrderedProbitThresholds.m191
tableOfOrderedProbitThresholds.m192makequit;

4DExercises for the Student

  1. Footnote 7 in the text notes that the requirement that small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image be weakly increasing is not necessary for the LIFO equilibrium and (essential) uniqueness results of Propositions 1 and 2 to go through. Show with an example that Proposition 3, which gives sufficient conditions for the entry and continuation decisions of all firms to follow threshold-based rules, does require this assumption.
  2. Show with a counterexample that the Assumption 3 in the text is not necessary for firms of all ranks to use threshold rules for their entry and continuation decisions. (Hint, modify the demand process from the Pencil-and-paper example.)
  3. The specification underlying Tables I and II sets small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image equal to a constant, so entry does not change producers' surplus per customer. Recalculate these tables using a different specification arising from an oligopoly model where markups fall with entry. Explain how the results do and do not change.
  4. Consider a version of the paper's game in which all play ends after small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image periods. Because all actions in this game occur sequentially, the subgame perfect equilibrium of this game in strategies that default to inactivity is unique. Show that for a fixed small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the equilibrium payoffs and strategies converge to those of the infinite horizon game's LIFO equilibrium as small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
  5. The theory of industrial organization is filled with two-period models of entry deterrence. In the first period, an incumbent can take an action that changes the payoffs and incentives in the second-stage game. If these actions credibly lower the payoff to entry enough, then a firm with the option to enter between the periods might not choose to exercise it. This exercise asks you to use the LIFO oligopoly dynamics model to explore this in a dynamic environment with uncertainty. Using the parameters underlying Tables I and II, calculate the equilibrium continuation value to an incumbent monopolist as a function of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for a grid of values for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Plot the results. Use this plot and similar ones created with alternative parameter values to discuss the effects of dynamics and uncertainty on the incentives to lower small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
  6. For this exercise, we suppose that incumbent producers make their continuation decisions sequentially, youngest first, and we look for a Markov-perfect equilibrium in which an incumbent producer rationally expects to outlive any competitor with a lower name. We call this a First-In First-Out (FIFO) equilibrium. This exercise also requires the following assumptions.
    • The stochastic process governing the evolution of demand is that from the Pencil-and-paper example.
    • At most two firms can serve the industry.
    Characterize the set of FIFO equilibria with the following steps.
    1. Sketch a portion of the game tree for this game. (See Figure 1 in the text.)
    2. Define a symmetric FIFO equilibrium that defaults to inactivity.
    3. Write the Bellman equation that necessarily characterizes the equilibrium payoff to a duopolist facing a rival with a higher rank, and show that its solution is piecewise linear in small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
    4. Suppose that a potential entrant to the market expects all future potential entrants facing a single incumbent to enter if and only if small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for some arbitrary entry set small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Write the Bellman equation that necessarily characterizes the equilibrium payoff to the potential entrant from actually entering.
    5. Use the Bellman equation to show that the potential entrant actually enters if small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , where this entry threshold is a function of the presupposed entry set small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
    6. Show that if small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and the Lebegue measure of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is strictly less than that of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , then small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
    7. Use the previous results to prove that there exists a unique FIFO equilibrium that defaults to inactivity. Characterize its equilibrium survival and entry sets.
  7. The paper's introduction claims

    Modifying our model to make fixed costs decline deterministically with age is straightforward, and we obtain the LIFO equilibrium as the limit of the sequence of “natural” (in Cabral's sense) equilibria to our model as we send the learning curve's slope to zero.

    This exercise consists of the verification of this claim. For it, we suppose that

    • The fixed cost of production for firm small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image after it has produced for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image periods is small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , where small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Since fixed costs decline exogenously over time, this is a “learning-by-ageing” technology. We make the fixed costs of earlier entrants decline faster than those of later entrants so that no two firms that entered in the same period have the same costs.
    • Incumbent producers make their continuation decisions simultaneously. Potential entrants then make their entry decisions, as in the LIFO model.
    Cabral (1993) defines a “natural” equilibrium as

    Natural equilibrium definition here.

    1. Sketch the game tree of the modified model.
    2. Define a natural Markov-perfect equilibrium that defaults to inactivity. (Note: Since each player has different fixed costs of production, we have no interest in symmetric equilibria.)
    3. Constructively prove the existence of a natural Markov-perfect equilibrium that defaults to inactivity. (For this, you can adapt the proof of Proposition 1. Be careful to define each player's strategy.)
    4. Demonstrate the uniqueness of the natural Markov-perfect equilibrium that defaults to inactivity constructed above.
    5. Consider a sequence of values for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image that converge to zero. The unique natural Markov-perfect equilibrium that defaults to inactivity defines corresponding sequences of equilibrium payoffs and strategies. Show that these converge to the LIFO equilibrium payoffs and strategies.
  8. This exercise modifies the model to include a once-and-for-all investment at the time of entry. Denote a firm's level of investment with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , so the total cost at entry is small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . The producers' surplus per customer for a monopolist is small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , while that for a duopolist facing a rival with investment small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image is small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . We make the following assumptions.
    • small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
    • small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
    • small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image are concave and twice differentiable in small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for any given small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image with

      small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
      small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

    This last restriction requires two firms' investments to be strategic substitutes in a static game.
    1. Sketch the game tree of the modified model.
    2. Define a Markovian strategy and a LIFO strategy for this game.
    3. Constructively prove the existence of a symmetric Markov-perfect equilibrium in a LIFO strategy.
    4. Following , decompose the derivative of a first-entrant's continuation value with respect to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image into direct and strategic effects.
    5. Write a Matlab program for calculating the Markov-perfect equilibrium constructed above. For a particular specification of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , calculate the equilibrium and the direct and strategic effects of investment on the first-mover's continuation value. Plot these as a function of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and interpret the results.
  9. This exercise extends the LIFO model to study optimal merger policy. For this extension, we suppose that small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Before firms continuation decisions are made, a high-ranked firm can make a take-it-or-leave-it offer to buy out a lower ranked rival. (Assume that the rival accepts if the offer exactly equals the payoff from continuation.) The buy-out results in the acquired firm's closure.
    1. Sketch the game tree of the modified model.
    2. Define a Markovian strategy and a LIFO strategy for this game.
    3. Show that the higher ranked firm will make an offer worth accepting only if small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
    4. Constructively prove the existence of a symmetric Markov-perfect equilibrium in a LIFO strategy.
    5. Write a Matlab program for calculating the Markov-perfect equilibrium constructed above. Suppose that each consumer has a linear demand curve small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and that duopolists compete in quantities. Use your program to calculate the equilibrium for given values of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
    6. Modify the game further by adding a competition authority, with the authority to impede a proposed merger. Suppose that the authority's policy is to approve a merger if and only if small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Modify your Matlab program to calculate this model's LIFO equilibrium. Use it to compare welfare in the unregulated equilibrium with that from the regulated equilibrium for various values of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . (This will be a function of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the initial demand state.) Interpret the results.

1AApproximating an Autoregressive Demand Process

For the experiments generating Tables I and II, we specify small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to approximate a first-order autoregression with a normally-distributed error.

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . For this, we begin with the approximation of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image as a mixture of uniform random variables all centered at zero.

Distribution Approximation with Mixtures of Uniform Random Variables

We denote the random variable to be approximated with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and its c.d.f. with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . The function uniformMixtureApproximation contains the code for producing a uniform-mixture approximation to a given distribution. Its single input, ARG, is a structure with three fields.

F
A handle to an anonymous function that equals small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
Frange
A scaler, half of the width of the symmetric support for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
k
An integer, the number of uniform distributions to use in the approximation.

Its output is also a structure, OUT, with three fields

ranges
A small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image vector. Each element gives half of the width of an approximating uniform distribution's support.
mixingProbabilities
A small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image vector of mixing probabilities over the distributions defined by OUT.ranges.
uniformCDF
A handle to an anonymous function that evaluates the uniform distribution's c.d.f..

uniformMixtureApproximation.m23function OUT = uniformMixtureApproximation(ARG)
uniformMixtureApproximation.m24
uniformMixtureApproximation.m25F=ARG.F;
uniformMixtureApproximation.m26Frange=ARG.Frange;
uniformMixtureApproximation.m27k=ARG.k;

The approximation's construction proceeds by first selecting the uniform distriubtions to be employed. These are all centered on zero and have ranges from an evently spaced grid on [0,Frange].

uniformMixtureApproximation.m32r=(Frange/k):(Frange/k):Frange;

Denote the c.d.f. of a uniform distribution on small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Our approximation proceeds by choosing the vector of mixing probabilities small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image so that small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image on an evenly spaced grid of points small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . This calculation requires us only to solve a set of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image linear equations. For their construction, we require only small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and an anonymous function to return small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

uniformMixtureApproximation.m38x=-Frange*(k-1)/k:Frange/k:0;
uniformMixtureApproximation.m39x=x'; Turn x into a column vector.

Below, it will be helpful to let the anonymous function representing small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to accept matrix-valued arguments. In the implementation here, arg.x is the c.d.f.'s argument and arg.r is half the width of its support.

uniformMixtureApproximation.m44G=@(arg) (-arg.r<arg.x).*(arg.x<arg.r)... The argument is within the variable's support
uniformMixtureApproximation.m45 .*(arg.x+arg.r)./(2*arg.r) ... So assign it the relevant value.
uniformMixtureApproximation.m46 +(arg.x>=arg.r); Otherwise, return one if the argument is to the right of r.

We write the system of linear equations as

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

where small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

uniformMixtureApproximation.m52f=F(x); Value of the true c.d.f. at the approximation points

The anonymous function G was carefully constructed to accept matrix-valued inputs, so we can form the matrix small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image with just one call to G.

uniformMixtureApproximation.m56arg.x=kron(x,ones(1,k));
uniformMixtureApproximation.m57arg.r=kron(ones(k,1),r);
uniformMixtureApproximation.m58A=G(arg);

We are now prepared to calculate the mixing probabilities, construct the output, and end the function.

uniformMixtureApproximation.m62p=A\f;
uniformMixtureApproximation.m63
uniformMixtureApproximation.m64OUT.ranges=r;
uniformMixtureApproximation.m65OUT.mixingProbabilities=p;
uniformMixtureApproximation.m66OUT.uniformCDF=G;
uniformMixtureApproximation.m67
uniformMixtureApproximation.m68end

Test of uniformMixtureApproximation

The program uniformMixtureApproximationTest.m tests this approxiation routine. For this, we calcuate several approximations to a normal distribution and plot the resulting c.d.f. with the original. The approximations use different numbers of uniform distributions, but they share the same support - 5 standard deviations to either side of zero.

Set the fields of ARG that are held fixed across approximations.

uniformMixtureApproximationTest.m11ARG.F=@(x) (1+erf(x/sqrt(2)))./2; Standard normal c.d.f.
uniformMixtureApproximationTest.m12ARG.Frange=5;

Initialize the figure with the exact c.d.f.. We evaluate it on a very fine grid covering the approximation's support. We call this x.

uniformMixtureApproximationTest.m16x=-ARG.Frange:0.001:ARG.Frange;
uniformMixtureApproximationTest.m17x=x';

Since ARG.F accepts vector-valued arguments, we can evaluate the exact c.d.f. on x with a single function call.

uniformMixtureApproximationTest.m21yExact=ARG.F(x);

The plot of the exact c.d.f. uses an extra thick gray line so that the finer approximations can be distinguished from it.

uniformMixtureApproximationTest.m25plot(x,yExact,'Color',[0.7 0.7 0.7],'LineWidth',8);

We will add the approximations' c.d.f's to this figure, so we wish to hold it.

uniformMixtureApproximationTest.m29hold;

Style the plot

uniformMixtureApproximationTest.m33set(gca,'Box','off','FontSize',14) Increase font size and turn off the box around the plot.
uniformMixtureApproximationTest.m34set(gcf,'Color',[1 1 1]); Set the background color to white.

Now we proceed to calculate each of the approximations and add them to the figure. The following vector stores the number of uniform distributions for each approximation.

uniformMixtureApproximationTest.m38kVec=[4 6 10];

To distinguish the approximations from each other, we assign them line styles and colors when plotting them.

uniformMixtureApproximationTest.m42lineStyles=cell(3,1);
uniformMixtureApproximationTest.m43lineStyles{1}='--r';
uniformMixtureApproximationTest.m44lineStyles{2}=':b';
uniformMixtureApproximationTest.m45lineStyles{3}='-k';

Cycle through the elements of kVec creating the approximations and adding them to the figure.

uniformMixtureApproximationTest.m49for i=1:length(kVec);
uniformMixtureApproximationTest.m50
uniformMixtureApproximationTest.m51 ARG.k=kVec(i);
uniformMixtureApproximationTest.m52
uniformMixtureApproximationTest.m53 OUT=uniformMixtureApproximation(ARG);

Evaluating the approximation merely requires us to evaluate the relevant uniform c.d.f.s and calcualte their weighted sums.

uniformMixtureApproximationTest.m57 G=OUT.uniformCDF;
uniformMixtureApproximationTest.m58 p=OUT.mixingProbabilities;
uniformMixtureApproximationTest.m59 r=OUT.ranges;
uniformMixtureApproximationTest.m60
uniformMixtureApproximationTest.m61 arg.x=kron(x,ones(1,ARG.k));
uniformMixtureApproximationTest.m62 arg.r=kron(ones(length(x),1),r);
uniformMixtureApproximationTest.m63
uniformMixtureApproximationTest.m64 yApproximate=G(arg)*p;
uniformMixtureApproximationTest.m65
uniformMixtureApproximationTest.m66 plot(x,yApproximate,lineStyles{i},'LineWidth',2); Add this approximation to the figure.
uniformMixtureApproximationTest.m67
uniformMixtureApproximationTest.m68end

Create a legend for the plot.

uniformMixtureApproximationTest.m72h1=legend('Original Distribution','k=4','k=6','k=10','Location','NorthWest');
uniformMixtureApproximationTest.m73set(h1,'box','off');

Finally export the figure to a .jpg file and quit if we are running this from make.

uniformMixtureApproximationTest.m77set(gcf,'Position',[-3 5 1280 950],...
uniformMixtureApproximationTest.m78 'PaperUnits','in','PaperSize',[5 3],...
uniformMixtureApproximationTest.m79 'PaperPositionMode','manual',...
uniformMixtureApproximationTest.m80 'PaperPosition',[0 0 5 3]); Set the figure to the desired size.
uniformMixtureApproximationTest.m81print -djpeg -painters uniformMixtureApproximationTest.jpg
uniformMixtureApproximationTest.m82makequit;

Figure 7 presents the resulting figure. As we can see, the approximation is very accurate even when mixing over 10 uniform distributions.

This is an image.

Figure 7: Original and Approximate c.d.f.s for a Standard Normal Distribution

In the paper, the process governing the evolution of demand is bounded and Markovian. To approximate this with a Markov chain, we begin with an eveny spaced grid

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

Given each small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , we approximate small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image with a mixture of uniformly distributed random variables. Each of these has a straightforward approximation over small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

Constructing the Markov Chain

The function markovChain takes care of constructing the actual Markov chain. Mimicing uniformMixtureApproximation, it takes a single input, ARG, which is a structure with the following fields.

omega
A structure with parameters describing the Markov chain's support. This is constructed as an evenly spaced grid over [omega.center-omega.width/2,omega.center+omega.width/2] with distance omega.step between each of the points.
sigma
A structure with parameters describing the autoregression to be approximated.
rho
The autoregressive parameter.
sigma
The innovation's standard deviation.
uniformMixtureApproximation
A structure with parameters describing the approximation of the innovation error with a mixture of uniform random variables. This is fed directly to the function of the same name.

The function's single output is a structure, OUT with fields

support
A vector containing the elements of the Markov chain's support.
transitionMatrix
The Markov chain's transition matrix. Its elements are conformable with those of support.

markovChain.m25function OUT=markovChain(ARG)

Begin by calling uniformMixtureApproximation to calculate the mixing probabilities and approximating uniform distributions used for the approximation of the autoregression's innovation.

markovChain.m30innovationApproximation=uniformMixtureApproximation(ARG.uniformMixtureApproximation);
markovChain.m31p=innovationApproximation.mixingProbabilities;
markovChain.m32r=innovationApproximation.ranges;
markovChain.m33k=ARG.uniformMixtureApproximation.k;

Set up state space, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

markovChain.m37omega=(ARG.omega.center-0.5*ARG.omega.width):ARG.omega.step:(ARG.omega.center+0.5*ARG.omega.width);
markovChain.m38nOmega=length(omega);

Construct the Markov chain.

markovChain.m42rho=ARG.autoRegression.rho;
markovChain.m43sigma=ARG.autoRegression.sigma;

Scale the uniform distributions' ranges by sigma.

markovChain.m47r=sigma*r;

Allocate the transition matrix.

markovChain.m51Pi=zeros(nOmega,nOmega);

Calculate the transition matrix conditional on the uniform mixing distribution chosen. For the small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image 'th element of r, we call this Pii. Their weighted sum over all small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image equals the Markov chain's transition matrix.

markovChain.m56for i=1:k
markovChain.m57 Pii=zeros(nOmega,nOmega);
markovChain.m58
markovChain.m59 for j=1:nOmega Calculate the transition probabilities for each state.

%Calculate the conditional mean and support of the underlying continuous distribution.

markovChain.m63 EC=rho*(omega(j)-ARG.omega.center)+ARG.omega.center;
markovChain.m64 lowlim=EC-r(i);
markovChain.m65 highlim=EC+r(i);

If the the random variable could leave small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , then adjust the lower or upper limit of the random variable's support accordingly. Since the maximum value of ri equals omega(end)-omega(1), we never need adjust both of them.

markovChain.m70 if lowlim<omega(1);
markovChain.m71 lowlim=omega(1);
markovChain.m72 highlim=omega(1)+2*r(i);
markovChain.m73 elseif highlim>omega(end);
markovChain.m74 lowlim=omega(end)-2*r(i);
markovChain.m75 highlim=omega(end);
markovChain.m76 end

Find the states with positive probability, count them, and set the appropriate elements of Pii

markovChain.m80 cindx=find((lowlim<=omega).*(highlim>=omega)); A vector of indices for omega of points between lowlim and highlim.
markovChain.m81 nMoves=length(cindx); The number of different possible values for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image given small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
markovChain.m82 Pii(j,cindx)=1/nMoves; Distribute the probability evenly over the possible values for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
markovChain.m83
markovChain.m84 end

Multiply Pii by the mixing probability and add it to Pi.

markovChain.m88 Pi=Pi+p(i)*Pii;
markovChain.m89
markovChain.m90end

The construction of the Markov transition matrix is now complete. All that remains is the output structure's assembly.

markovChain.m94OUT.support=omega;
markovChain.m95OUT.transitionMatrix=Pi;
markovChain.m96
markovChain.m97end

Test of markovChain

To test markovChain, we use it to approximate a random walk with normal innovation variance small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . The approximation lives on an evenly spaced grid of 301 points small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image The error distribution's uniform mixture approximation uses 10 distributions and extends three standard deviations to either side of zero.

markovChainTest.m9ARG.omega.center=0.0;
markovChainTest.m10ARG.omega.step=0.01;
markovChainTest.m11ARG.omega.width=3;
markovChainTest.m12
markovChainTest.m13ARG.autoRegression.rho=1;
markovChainTest.m14ARG.autoRegression.sigma=0.3;
markovChainTest.m15
markovChainTest.m16ARG.uniformMixtureApproximation.F=@(x) (1+erf(x/sqrt(2)))./2;
markovChainTest.m17ARG.uniformMixtureApproximation.Frange=3;
markovChainTest.m18ARG.uniformMixtureApproximation.k=10;
markovChainTest.m19
markovChainTest.m20OUT=markovChain(ARG);
markovChainTest.m21
markovChainTest.m22omega=OUT.support;
markovChainTest.m23Pi=OUT.transitionMatrix;

To examine the output, plot the 10th, 25th, 50th, 75th and 90th conditional percentiles of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image as functions of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Denote these with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . We begin with the calculation of the conditional c.d.f.

markovChainTest.m28cdf=100*cumsum(Pi,2); The “2” indicates summation along each row. Express the result in percentage points.

Since the approximate distribution is discrete, it typically has no exact percentiles for any given probability. Therefore, we set small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to the value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image with the value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image closest to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

markovChainTest.m33pvec = [10 25 50 75 90]; Put the probability values of interest (in percentage points) into a vector.
markovChainTest.m34Q = zeros(length(pvec),length(omega)); Allocate a matrix to hold the conditional quantiles.
markovChainTest.m35
markovChainTest.m36for i=1:length(pvec)
markovChainTest.m37
markovChainTest.m38 [F,indx]=min(abs(cdf-pvec(i)),[],2); Matlab syntax requires an empty matrix as the second argument to min when calculating minima across rows, as the “2” indicates.
markovChainTest.m39 Q(i,:)=omega(indx); The vector indx gives the index in omega of each percentile.
markovChainTest.m40
markovChainTest.m41end

For comparison, it is helpful to plot the exact conditional percentiles of the autoregression being approximated.

markovChainTest.m45QExact=zeros(length(pvec),length(omega));
markovChainTest.m46
markovChainTest.m47for i=1:length(pvec);
markovChainTest.m48
markovChainTest.m49 q=sqrt(2)*erfinv(2*pvec(i)/100-1); Calculate the innovation's percentile.
markovChainTest.m50 QExact(i,:) = ARG.autoRegression.rho*omega+ARG.autoRegression.sigma*q; Transform it into the conditional percentile.
markovChainTest.m51
markovChainTest.m52end

Since the percentiles are naturally ordered vertically, there is no need to visually distinguish one from the other. We first plot the approximation's percentiles and then the exact distribution's percentiles. The latter are gray and a little thick, so that they can be seen along with with the thin black lines representing the approximation's percentiles.

markovChainTest.m58plot(omega,QExact,'Color',[0.8 0.8 0.8],'LineWidth',3);
markovChainTest.m59hold
markovChainTest.m60plot(omega,Q,'Color','k','LineWidth',1);

All that remains is to style the plot and save it to a .jpg file.

markovChainTest.m64Chat=ARG.omega.center-0.5*ARG.omega.width;
markovChainTest.m65Ccheck=ARG.omega.center+0.5*ARG.omega.width;
markovChainTest.m66Cmiddle=ARG.omega.center;
markovChainTest.m67
markovChainTest.m68set(gca,'box','off','FontSize',14,'Xtick',[Chat Cmiddle Ccheck]);
markovChainTest.m69set(gcf,'Color',[1 1 1]);
markovChainTest.m70
markovChainTest.m71set(gcf,'Position',[-3 5 1280 950],...
markovChainTest.m72 'PaperUnits','in','PaperSize',[5 3],...
markovChainTest.m73 'PaperPositionMode','manual',...
markovChainTest.m74 'PaperPosition',[0 0 5 3]); Set the figure to the desired size.
markovChainTest.m75print -djpeg -painters markovChainApproximationTestPercentiles.jpg

This is an image.

Figure 8: The Markov Chain's Consitional Percentiles

The thick gray lines plot the 10th, 25th, 50th, 75th, and 90th conditional percentiles of an random walk, while the solid lines plot the analogous conditional quantiles of its Markov chain approximation produced by markovChain.m.

Figure 8 presents the plot. As expected, the approximation accurately reproduces the underlying random walk in the middle of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and deviates substantially towards the boundaries.

For a final test, we calculate the ergodic distribution associated with the Markov chain and plot it. This is a “test” only to the extent that we confirm the existence of a unit eigenvalue of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and an associated left eigenvector, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image which satisfies.

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

For the calculation, we use the eigs command, which accepts an optional integer argument i requesting the calculation of the i largest eigenvalues and their associated eigenvectors. Of course, we are interested in only the largest eigenvalue, which should equal one. In the output, p is the eigenvector, d is its associated eigenvalue, and flag is an indicator that should equal zero if the calculations of eigs converged.

markovChainTest.m98[p,d,flag]=eigs(Pi',1);
markovChainTest.m99
markovChainTest.m100if abs(d-1)>10e-10 || flag~=0
markovChainTest.m101 error('Calculation of ergodic distribution failed.')
markovChainTest.m102end
markovChainTest.m103

Normalize the eigen vector to have unit, plot it, and save the plot to a.jpg file.

markovChainTest.m106p=p/sum(p);
markovChainTest.m107
markovChainTest.m108figure(2)
markovChainTest.m109plot(omega,p','-k','LineWidth',2.5)
markovChainTest.m110set(gca,'FontSize',14)
markovChainTest.m111box off
markovChainTest.m112set(gcf,'Color',[1 1 1]);
markovChainTest.m113
markovChainTest.m114set(gca,'box','off','FontSize',14,'Xtick',[Chat Cmiddle Ccheck]);
markovChainTest.m115set(gcf,'Color',[1 1 1]);
markovChainTest.m116
markovChainTest.m117set(gcf,'Position',[-3 5 1280 950],...
markovChainTest.m118 'PaperUnits','in','PaperSize',[5 3],...
markovChainTest.m119 'PaperPositionMode','manual',...
markovChainTest.m120 'PaperPosition',[0 0 5 3]); Set the figure to the desired size.
markovChainTest.m121print -djpeg -painters markovChainApproximationTestErgodicDistribution.jpg
markovChainTest.m122makequit;

This is an image.

Figure 9: The Markov Chain's Ergodic Distribution

Figure 9 presents the resulting figure. In spite of using a reasonably fine grid for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the distribution has a “toothy” look. Nevertheless, it is roughly bell-shaped.

2BOrdered Probit Estimation

We enclose the code for calculating small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image given supports for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and a joint distribution over that support into the function orderedProbitMaximumLikelihoodEstimation.

orderedProbitMaximumLikelihoodEstimation.m8function OUT = orderedProbitMaximumLikelihoodEstimation(ARG)

Its single argument has three fields, as described above. The function begins with extracting these and assigning them convenient names.

orderedProbitMaximumLikelihoodEstimation.m12C = ARG.support(:,1);
orderedProbitMaximumLikelihoodEstimation.m13N = ARG.support(:,2);
orderedProbitMaximumLikelihoodEstimation.m14p = ARG.distribution;
orderedProbitMaximumLikelihoodEstimation.m15eps = ARG.epsilon;

The estimation requires repeated evaluation of the standard Gaussian c.d.f, so we place this in an inline function.

orderedProbitMaximumLikelihoodEstimation.m19Phi = @(x) 0.5*(x>=0).*(erf(abs(x)/sqrt(2))+1)+0.5*(x<0).*erfc(abs(x)/sqrt(2));

In any given application, some elements of the support for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image have zero or nearly zero probability of occuring. L'Hoptial's rule tells us that the contribution of a zero-probability event to the expected log likelhood function equals zero, but Matlab does not know anything of L'Hopital. Instead, it will dutifully try to calculate the logarithm of 0, yielding NaN, multiply this by 0, and add the result to the expected likelihood function. In this way, the calculated expected log likelihood function always equals NaN. To eliminate this problem, we remove near-zero probability events from the support. This is the first use of eps.

orderedProbitMaximumLikelihoodEstimation.m26C=C(p>eps); N=N(p>eps); p=p(p>eps); p=p/sum(p);

We seek the maximum likelihoood estimates of the k-1 thresholds corresponding to the elements of Noutcomes. Although the ordered-probit likelihood function is concave in these unknown paramters, good starting values make its optimization easier. Accordingly, we begin with estimating these thresholds using binary probit estimates with the events small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for values of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image in Noutcomes as the depenent variables. Given a trial threshold small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the likelihood function is

(0)

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

We implement this with an inline function with a single input, x. Its three elements are

x(1)
The trial threshold, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
x(2)
The trial value of the error variance, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
x(3)
small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the number of firms defining the dependent variable.

orderedProbitMaximumLikelihoodEstimation.m40lf = @(x) p'*((N>=x(3)).*log(Phi(log(C/x(1))/x(2))) ...
orderedProbitMaximumLikelihoodEstimation.m41 + (N<x(3)).*log(Phi(log(x(1)./C)/x(2))));

The following loop uses lf(x) to calcualte the binary probit maximum likelihood estimates we require. These get stored in startC and startSigma.

orderedProbitMaximumLikelihoodEstimation.m45Nlow=min(N);
orderedProbitMaximumLikelihoodEstimation.m46Nhigh=max(N);
orderedProbitMaximumLikelihoodEstimation.m47startC = zeros(Nhigh-Nlow,1);
orderedProbitMaximumLikelihoodEstimation.m48startSigma = zeros(Nhigh-Nlow,1);
orderedProbitMaximumLikelihoodEstimation.m49
orderedProbitMaximumLikelihoodEstimation.m50for R=Nlow+1:Nhigh;

Specialize the likelihood function for this event.

orderedProbitMaximumLikelihoodEstimation.m54 f = @(x) -lf([x R]);

Minimize the likelihood function. For the threshold's starting value,use the average value of C conditional on small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image firms being in the market. The choice of variance is arbitrary.

orderedProbitMaximumLikelihoodEstimation.m58 C0=p(N==R)'*C(N==R)/sum(p(N==R));
orderedProbitMaximumLikelihoodEstimation.m59 [x,fval,exitflag]=fminsearch(f,[C0 0.2]);
orderedProbitMaximumLikelihoodEstimation.m60 if exitflag~=1
orderedProbitMaximumLikelihoodEstimation.m61 error(['Binary probit maximization failed with fR=' int2str(R) ' and fval = ' num2str(fval,'%5.3f')])
orderedProbitMaximumLikelihoodEstimation.m62 end
orderedProbitMaximumLikelihoodEstimation.m63 startC(R-Nlow)=x(1);
orderedProbitMaximumLikelihoodEstimation.m64 startSigma(R-Nlow)=x(2);
orderedProbitMaximumLikelihoodEstimation.m65end

With the starting values in hand, it is time to create the full ordered-probit likelihood function. For this, we first create an inline function that calculates the probability of any given outcome as a function of the error variance and thresholds, logprobs(x). Its single argument contains

x(1)
The trial likelihood function variance.
x(2:end)
The ordered-probit thresholds. The first and last of these should be set to very small and large numbers, respectively. They stand-in for 0 and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

orderedProbitMaximumLikelihoodEstimation.m77logprobs = @(x) log(Phi(log(C./x(N-Nlow+2)')/x(1))... Note that indexing a vector with another vector always produces a row vector.
orderedProbitMaximumLikelihoodEstimation.m78 -Phi(log(C./x(N-Nlow+3)')/x(1)));

Calculating the likelihood function for a given variance and set of thresholds merely requires evaluating logprobs and calculating its expected value.

orderedProbitMaximumLikelihoodEstimation.m82lf = @(x) p'*logprobs([ x(1) 1e-10 x(2:end) 1e10]);

We are now prepared to maximize the ordered probit likelihood function. The maximization uses starting values for the thresholds calculated above. The starting value for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image equals the average estimate from the binary probits.

orderedProbitMaximumLikelihoodEstimation.m86f= @(x) -lf(x);
orderedProbitMaximumLikelihoodEstimation.m87[x,fval,exitflag]=fminsearch(f,[mean(startSigma) startC']);
orderedProbitMaximumLikelihoodEstimation.m88
orderedProbitMaximumLikelihoodEstimation.m89if exitflag~=1
orderedProbitMaximumLikelihoodEstimation.m90 error(['Ordered probit estimation failed at fval = ' num2str(fval,'%5.2f')])
orderedProbitMaximumLikelihoodEstimation.m91end

This complete's the required calculations, and all that remains is to package the required results into the output structure, OUT. It has three fields.

orderedProbitMaximumLikelihoodEstimation.m95OUT.sigma = x(1);
orderedProbitMaximumLikelihoodEstimation.m96OUT.thresholds = x(2:end);
orderedProbitMaximumLikelihoodEstimation.m97OUT.indices = Nlow+1:1:Nhigh;

Test of orderedProbitMaximumLikelihoodEstimation

We test this function using inputs created by running calculateLifoEquilibriumTest.

orderedProbitMaximumLikelihoodEstimationTest.m8stay=1; Defining stay overrides makequit.
orderedProbitMaximumLikelihoodEstimationTest.m9calculateLifoEquilibriumTest;
orderedProbitMaximumLikelihoodEstimationTest.m10clear stay;

Close the figure this program produces.

orderedProbitMaximumLikelihoodEstimationTest.m14close all;

Recall that this program leaves the equilibrium calculations in the structure OUT. To calculate the support of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and its accompanying ergodic distribution, we feed this to calculateLifoErgodicDistribution.

orderedProbitMaximumLikelihoodEstimationTest.m19ERGODIC=calculateLifoErgodicDistribution(OUT);

Adding the field epsilon to ERGODIC allows us to use it as input for orderedProbitMaximumLikelihoodEstimation.

orderedProbitMaximumLikelihoodEstimationTest.m23ERGODIC.epsilon=1e-7;
orderedProbitMaximumLikelihoodEstimationTest.m24ESTIMATES=orderedProbitMaximumLikelihoodEstimation(ERGODIC);
orderedProbitMaximumLikelihoodEstimationTest.m25makequit;

3CLaTeX Figure Code

3C.1Pencil-and-Paper Example

Figure 1A contains two panels, one for each firm's value function. To create it, we use the pgfplots package of Feuersänger (2008) to make an axis for each panel and then draw the value functions directly using the equilibrium entry thresholds, exit thresholds, and value functions calculated by pencil.m and saved in pgfTikZ/ac2apencilConstants.tex. The following TikZ code requires those constants to be defined, and atikzpicture environment must enclose it. For example

pgfTikZ/ac2apencilWrapper.tex25\begin{tikzpicture}[scale=1.4]
pgfTikZ/ac2apencilWrapper.tex26\input{ac2apencilColor}
pgfTikZ/ac2apencilWrapper.tex27\end{tikzpicture}

The code below resides within /compute/pgfTikZ.4

3C.1.1Top Panel

We begin with opening the first axis, which contains the value function for a firm with rank 1. We set several TikZ keys to control the axes appearance, including the location, style, and labeling of tick marks.

pgfTikZ/ac2apencilColor.tex10\begin{axis}[width=4.5in,height=2.5in,
pgfTikZ/ac2apencilColor.tex11 title=First Entrant's Value Function, Title placed over the axis.
pgfTikZ/ac2apencilColor.tex12 name=v1, An axis name used to place the next axis.
pgfTikZ/ac2apencilColor.tex13 ylabel={},
pgfTikZ/ac2apencilColor.tex14 axis x line=bottom, Place the x-axis at the bottom of the plotted area.
pgfTikZ/ac2apencilColor.tex15 every outer x axis line/.append style={-,color=gray,line width=0.75pt},
pgfTikZ/ac2apencilColor.tex16 axis y line=left, Place the y-axis at the left of the ploted area
pgfTikZ/ac2apencilColor.tex17 every outer y axis line/.append style={-,color=gray,line width=0.75pt},
pgfTikZ/ac2apencilColor.tex18 Place x-axis tick marks at small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
pgfTikZ/ac2apencilColor.tex19 xtick={\pencilChat,\pencilCunderbarOne,\pencilCoverbarOne,\pencilCcheck},
pgfTikZ/ac2apencilColor.tex20 Only label the middle two tick marks. Manually adjust the second one's vertical offset.
pgfTikZ/ac2apencilColor.tex21 xticklabels={$ $,\raisebox{-2.3mm}{$\underline{C}_1$},$\overline{C}_1$, $ $},
pgfTikZ/ac2apencilColor.tex22 Place y-axis tick marks at 0, small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .
pgfTikZ/ac2apencilColor.tex23 ytick={0,\pencilPhiOne,\pencilVOneOneCoverbarTwo},
pgfTikZ/ac2apencilColor.tex24 Only label the first two tick marks.
pgfTikZ/ac2apencilColor.tex25 yticklabels={$0$,\makebox[0pt][r]{$\varphi(1)$},$ $},
pgfTikZ/ac2apencilColor.tex26 Style the tick marks.
pgfTikZ/ac2apencilColor.tex27 major tick length=2.5mm,
pgfTikZ/ac2apencilColor.tex28 every tick/.append style={line width=0.75pt},
pgfTikZ/ac2apencilColor.tex29 Set the plotted area's horizontal and vertical limits.
pgfTikZ/ac2apencilColor.tex30 xmin=\pencilChat,
pgfTikZ/ac2apencilColor.tex31 xmax=\pencilCcheck,
pgfTikZ/ac2apencilColor.tex32 ymin=0,
pgfTikZ/ac2apencilColor.tex33 ymax=\pencilVOneOneCoverbarTwo]

The cost of entry

The next task at hand is to draw the horizontal line demarking the cost of the first firm's entry. We do this with the axis coordinate system, which selects points based on their locations in the Cartisian plane (See page 21 of Feuersänger (2008) ).

pgfTikZ/ac2apencilColor.tex36 \draw[color=gray,line width=0.75pt,dashed]
pgfTikZ/ac2apencilColor.tex37 (axis cs:\pencilChat,\pencilPhiOne) -- (axis cs:\pencilCcheck,\pencilPhiOne);

Plot of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

We now proceed to plot small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Each of these is piecewise linear with exactly one discontinuity. Since they overlap outside of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , it is useful to conceive of them as consisting of two branches. The “monopoly” branch plots small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image over small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . This is flat from small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and thereafter slopes up at the rate small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . To draw this, we simply connect two points on each line segments using the \path command. The line is colored black to distinguish it from the gray helper lines. We give two of these points names for later use using the coordinate directive.

pgfTikZ/ac2apencilColor.tex40 \path[draw,color=black,line width=0.75pt]
pgfTikZ/ac2apencilColor.tex41 (axis cs: \pencilChat,0) -- (axis cs: \pencilCunderbarOne,0) coordinate (monopolyMin)
pgfTikZ/ac2apencilColor.tex42 -- (axis cs: \pencilCoverbarTwo,\pencilVOneOneCoverbarTwo) coordinate (monopolyMax);

The “duopoly” branch, which gives small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image over small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image completes the two value functions. Its red color distinguishes it from the monopoly branch.

pgfTikZ/ac2apencilColor.tex44 \path[draw,color=red!75,line width=0.75pt]
pgfTikZ/ac2apencilColor.tex45 (axis cs: \pencilCunderbarTwo,\pencilVOneTwoCunderbarTwo) coordinate (duopolyMin)
pgfTikZ/ac2apencilColor.tex46 -- (axis cs: \pencilCcheck,\pencilVOneTwoCcheck) coordinate (duopolyMax);

Transition Arrows

As small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image passes through small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , the change in the potential entrant's actual entry decision causes small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image to drop discontinously. We denote this discontinuity with a gray vertical array from the monopoly branch to the duopoly branch. Its origin is at the point we denoted above with monopolyMax. Theoretically, its destination is where the duopoly branch crosses a vertical line from monopolyMax to the x axis. We calculate this point using the intersection coordinate system of TikZ. Practically, the arrow looks better if we end it just above this point.

pgfTikZ/ac2apencilColor.tex50 Find the intersection of interest.
pgfTikZ/ac2apencilColor.tex51 \path(axis cs:\pencilCoverbarTwo,0) coordinate (Xaxis1);
pgfTikZ/ac2apencilColor.tex52 \path(intersection cs:
pgfTikZ/ac2apencilColor.tex53 first line={(duopolyMin)--(duopolyMax)},
pgfTikZ/ac2apencilColor.tex54 second line={(monopolyMax) -- (Xaxis1)}) coordinate
pgfTikZ/ac2apencilColor.tex55 (duopolyEntry);
pgfTikZ/ac2apencilColor.tex56 Set the arrow's target slightly above this intersection.
pgfTikZ/ac2apencilColor.tex57 \path(duopolyEntry) ++ (0,5pt) coordinate(duopolyTarget);
pgfTikZ/ac2apencilColor.tex58 Draw the arrow.
pgfTikZ/ac2apencilColor.tex59 \draw[-stealth,dashed,line width=0.5pt,color=gray] (monopolyMax) -- (duopolyTarget);
pgfTikZ/ac2apencilColor.tex60

The analogous discontinuity in small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image associated with a younger rival's exit occurs at small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . Again, the arrow's source coordinate is in hand, duopolyMin. Its destination is at the intersection of the monopoly branch with a vertical line through duopolyMin. We place the arrow tip just below this point.

pgfTikZ/ac2apencilColor.tex63 Find the intersection of interest.
pgfTikZ/ac2apencilColor.tex64 \path(axis cs:\pencilCunderbarTwo,0) coordinate (Xaxis2);
pgfTikZ/ac2apencilColor.tex65 \path(intersection cs:
pgfTikZ/ac2apencilColor.tex66 first line={(monopolyMin)--(monopolyMax)},
pgfTikZ/ac2apencilColor.tex67 second line={(duopolyMin)--(Xaxis2)}) coordinate (monopolyExit);
pgfTikZ/ac2apencilColor.tex68 Set the arrow's target slightly below this intersection.
pgfTikZ/ac2apencilColor.tex69 \path(monopolyExit) ++ (0,-5pt) coordinate (monopolyTarget);
pgfTikZ/ac2apencilColor.tex70 Draw the arrow.
pgfTikZ/ac2apencilColor.tex71 \draw[-stealth,dashed,line width=0.5pt,color=gray] (duopolyMin) -- (monopolyTarget);
pgfTikZ/ac2apencilColor.tex72

The Legend

To aid the reader, we create a legend to label the two value-function branches. Rather than rely on the legend-creation capabilities of pgfplots, we create our own by placing a similar line next to a textual explanation. The first task is to calculate the beginning and end points for the line in the monopoly branch's legend entry. We place its start point 4/5 of the way up the vertical axis and half way from the origin to small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . To calculate these points, we use \pgfmathsetmacro and the axis coordinate system.

pgfTikZ/ac2apencilColor.tex76 \pgfmathsetmacro{\legendxOne}{0.5*(\pencilCunderbarOne-\pencilChat)}
pgfTikZ/ac2apencilColor.tex77 \pgfmathsetmacro{\legendyOne}{0.8*\pencilVOneOneCoverbarTwo}
pgfTikZ/ac2apencilColor.tex78 \path(axis cs: \legendxOne,\legendyOne) coordinate (legendStartMonopoly);
pgfTikZ/ac2apencilColor.tex79

The line rises at the slope small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , which is saved in \pencilPiOne, and ends just above small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

pgfTikZ/ac2apencilColor.tex82 \pgfmathsetmacro{\legendyTwo}{\legendyOne+\pencilPiOne*\pencilCunderbarOne*0.5}
pgfTikZ/ac2apencilColor.tex83 \pgfmathsetmacro{\legendxTwo}{\pencilCunderbarOne}
pgfTikZ/ac2apencilColor.tex84 \path(axis cs: \legendxTwo,\legendyTwo) coordinate(legendStopMonopoly);
pgfTikZ/ac2apencilColor.tex85

We place the text for the monopoly branch's legend entry to the right of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

pgfTikZ/ac2apencilColor.tex87 \pgfmathsetmacro{\legendxThree}{2*\pencilCunderbarOne}
pgfTikZ/ac2apencilColor.tex88 \pgfmathsetmacro{\legendyThree}{\legendyOne+\pencilPiOne*\pencilCunderbarOne*0.25}
pgfTikZ/ac2apencilColor.tex89 \path(axis cs: \legendxThree,\legendyThree) coordinate (legendTextMonopoly);
pgfTikZ/ac2apencilColor.tex90

With the coordinates in hand, we draw the legend entry and place its label text.

pgfTikZ/ac2apencilColor.tex92 \path[draw,color=black,line width=0.75pt]
pgfTikZ/ac2apencilColor.tex93 (legendStartMonopoly) -- (legendStopMonopoly)
pgfTikZ/ac2apencilColor.tex94 (legendTextMonopoly) node{Monopoly Branch};
pgfTikZ/ac2apencilColor.tex95

The duopoly branch's legend entry locations are just those from the monopoly branch shifted down by half a centemeter.

pgfTikZ/ac2apencilColor.tex98 \path(legendStartMonopoly) ++(0,-0.5cm) coordinate (legendStartDuopoly);
pgfTikZ/ac2apencilColor.tex99 \path(legendStopMonopoly) ++(0,-0.5cm) coordinate (legendStopDuopoly);
pgfTikZ/ac2apencilColor.tex100 \path(legendTextMonopoly) ++(0,-0.5cm) coordinate (legendTextDuopoly);
pgfTikZ/ac2apencilColor.tex101
pgfTikZ/ac2apencilColor.tex102 \draw[color=red!75,line width=0.75pt] (legendStartDuopoly) -- (legendStopDuopoly)
pgfTikZ/ac2apencilColor.tex103 (legendTextDuopoly) node[color=black]{Duopoly Branch};
pgfTikZ/ac2apencilColor.tex104

The words “Monopoly Branch” and “Duopoly Branch” are centered in their nodes. It would be great to left-justify them so that their left-ends were properly aligned. In any case, this panel and its corresponding axis environment are complete.

pgfTikZ/ac2apencilColor.tex107\end{axis}
pgfTikZ/ac2apencilColor.tex108

3C.1.2Bottom Panel

The bottom panel gives the value function of a firm with rank 2. This is considerably simpler to plot. We begin by calculating a point below the top panel for its location.

pgfTikZ/ac2apencilColor.tex111\path(v1.origin) ++(0,-2.50in) coordinate (v2 plot position);

As before, we use the axis environment to create the bottom panel.

pgfTikZ/ac2apencilColor.tex113\begin{axis}[width=4.5in,height=2.5in,
pgfTikZ/ac2apencilColor.tex114 title=Second Entrant's Value Function,
pgfTikZ/ac2apencilColor.tex115 name=v2,
pgfTikZ/ac2apencilColor.tex116 at = {(v2 plot position)},
pgfTikZ/ac2apencilColor.tex117 anchor={origin},
pgfTikZ/ac2apencilColor.tex118 ylabel={},
pgfTikZ/ac2apencilColor.tex119 axis x line=bottom,
pgfTikZ/ac2apencilColor.tex120 every outer x axis line/.append style={-,color=gray,line width=0.75pt},
pgfTikZ/ac2apencilColor.tex121 axis y line=left,
pgfTikZ/ac2apencilColor.tex122 every outer y axis line/.append style={-,color=gray,line width=0.75pt},
pgfTikZ/ac2apencilColor.tex123 We place x-axis tick marks at small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image , and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image
pgfTikZ/ac2apencilColor.tex124 xtick={\pencilChat,\pencilCunderbarTwo,\pencilCoverbarTwo,\pencilCcheck},
pgfTikZ/ac2apencilColor.tex125 All four x-axis tick marks get labels.
pgfTikZ/ac2apencilColor.tex126 xticklabels={$\hat{C} $,\raisebox{-2.3mm}{$\underline{C}_2$},
pgfTikZ/ac2apencilColor.tex127 $\overline{C}_2$, $\check{C}$},
pgfTikZ/ac2apencilColor.tex128 ytick={0,\pencilPhiTwo,\pencilVOneOneCoverbarTwo},
pgfTikZ/ac2apencilColor.tex129 yticklabels={$0$,\makebox[0pt][r]{$\varphi(2)$},$ $},
pgfTikZ/ac2apencilColor.tex130 major tick length=2.5mm,
pgfTikZ/ac2apencilColor.tex131 every tick/.append style={line width=0.75pt},
pgfTikZ/ac2apencilColor.tex132 ymin=0,
pgfTikZ/ac2apencilColor.tex133 ymax=\pencilVOneOneCoverbarTwo,
pgfTikZ/ac2apencilColor.tex134 xmin=\pencilChat,
pgfTikZ/ac2apencilColor.tex135 xmax=\pencilCcheck]
pgfTikZ/ac2apencilColor.tex136

The actual plotting of the cost of entry and the value function is very straightforward.

pgfTikZ/ac2apencilColor.tex138 \draw[color=gray,line width=0.75pt,dashed]
pgfTikZ/ac2apencilColor.tex139 (axis cs:\pencilChat,\pencilPhiOne) -- (axis cs:\pencilCcheck,\pencilPhiOne);
pgfTikZ/ac2apencilColor.tex140
pgfTikZ/ac2apencilColor.tex141 \draw[color=black,line width=0.75pt] (axis cs: \pencilChat,0)
pgfTikZ/ac2apencilColor.tex142 -- (axis cs: \pencilCunderbarTwo,0)
pgfTikZ/ac2apencilColor.tex143 -- (axis cs: \pencilCcheck,\pencilVTwoCcheck);
pgfTikZ/ac2apencilColor.tex144

The bottom panel is done, so close the axis environment

pgfTikZ/ac2apencilColor.tex146\end{axis}

3C.2Equilibrium without Thresholds

The plot of continuation values from the example equilibrium without threshold-based strategies uses the data created by equilibriumWithoutThresholds.m and saved in

Just as with the pencil-and-paper example, the code below resides in /compute/pgfTikZ and requires certain macros defined by this last file to be in place. 5

3C.2.1Top Panel

We place no labelled tick marks on the horizontal axis to make room for the illustration of the entry set. Otherwise, the formatting of the top panel is pretty similar to that from the pencil-and-paper example.

pgfTikZ/ac2aNoThresholdsColor.tex13 \begin{axis}[width=4.5in,height=2.5in,
pgfTikZ/ac2aNoThresholdsColor.tex14 title=First Entrant's Value Function,
pgfTikZ/ac2aNoThresholdsColor.tex15 name=v1,
pgfTikZ/ac2aNoThresholdsColor.tex16 ylabel={},
pgfTikZ/ac2aNoThresholdsColor.tex17 axis x line=bottom,
pgfTikZ/ac2aNoThresholdsColor.tex18 every outer x axis line/.append style={-,color=gray,line width=0.75pt},
pgfTikZ/ac2aNoThresholdsColor.tex19 axis y line=left,
pgfTikZ/ac2aNoThresholdsColor.tex20 every outer y axis line/.append style={-,color=gray,line width=0.75pt},
pgfTikZ/ac2aNoThresholdsColor.tex21 xtick={\chat,\ccheck},
pgfTikZ/ac2aNoThresholdsColor.tex22 xticklabels={},
pgfTikZ/ac2aNoThresholdsColor.tex23 ytick={0,\phione,\ymax},
pgfTikZ/ac2aNoThresholdsColor.tex24 yticklabels={$0$,\makebox[0pt][r]{$\varphi(1)=\phione$},$\pgfmathprintnumber{\ymax}$},
pgfTikZ/ac2aNoThresholdsColor.tex25 major tick length=2.5mm,
pgfTikZ/ac2aNoThresholdsColor.tex26 every tick/.append style={line width=0.75pt},
pgfTikZ/ac2aNoThresholdsColor.tex27 ymin=0,
pgfTikZ/ac2aNoThresholdsColor.tex28 ymax=\ymax,
pgfTikZ/ac2aNoThresholdsColor.tex29 scaled ticks=false,
pgfTikZ/ac2aNoThresholdsColor.tex30 scaled ticks=false,
pgfTikZ/ac2aNoThresholdsColor.tex31 /pgf/number format/precision=2,
pgfTikZ/ac2aNoThresholdsColor.tex32 /pgf/number format/set thousands separator={}]

Place the text describing the entry rule into the top panel.

pgfTikZ/ac2aNoThresholdsColor.tex34 \node[color=black] at (axis cs:0.65,6) {Enter if $\ln C\in \cal{A}\cup \cal{B}$};
pgfTikZ/ac2aNoThresholdsColor.tex35 Draw a horizontal line at the cost of entry
pgfTikZ/ac2aNoThresholdsColor.tex36 \draw[color=gray,line width=0.75pt,dashed] (axis cs:\chat,\phione) -- (axis cs:\ccheck,\phione);

Create the two value-function “branches” for an incumbent with rank 1.

pgfTikZ/ac2aNoThresholdsColor.tex38 \addplot[color=black,mark=square*,only marks,mark size=0.05mm] table[x=C,y=v11,col sep=comma]{equilibriumWithoutThresholdsV11.csv};
pgfTikZ/ac2aNoThresholdsColor.tex39 \addplot[color=red!75,mark=square*,only marks,mark size=0.05mm] table[x=C,y=v12,col sep=comma]{equilibriumWithoutThresholdsV12.csv};
pgfTikZ/ac2aNoThresholdsColor.tex40

This is complicated enough to merit a legend. Note that its location is hard-wired. Changing the example might make this poorly placed.

pgfTikZ/ac2aNoThresholdsColor.tex42 \draw[color=black,line width=0.75pt] (axis cs: -1.3,35) -- (axis cs: -1.05,39) (axis cs: -1.05,36)--(axis cs:-0.925,38) (axis cs: -0.5,38) node{Monopoly Branch};
pgfTikZ/ac2aNoThresholdsColor.tex43 \draw[color=red!75,line width=0.75pt] (axis cs: -1.3,30) -- (axis cs: -1.05,34) (axis cs: -1.05,31)--(axis cs:-0.925,33) (axis cs: -0.5,33) node[color=black]{Duopoly Branch};

Mark locations for drawing the entry set. We do the actual drawing below (outside of the axis environment) to avoid having our beautiful work being clipped.

pgfTikZ/ac2aNoThresholdsColor.tex45 \path(axis cs:\chat,0) coordinate (Chat);
pgfTikZ/ac2aNoThresholdsColor.tex46 \path(axis cs:\ccheck,0) coordinate (Ccheck);
pgfTikZ/ac2aNoThresholdsColor.tex47 \path(axis cs:\Alow,0) coordinate (Alow);
pgfTikZ/ac2aNoThresholdsColor.tex48 \path(axis cs:\Ahigh,0) coordinate (Ahigh);
pgfTikZ/ac2aNoThresholdsColor.tex49 \path(axis cs:\Clow,0) coordinate (Clow);
pgfTikZ/ac2aNoThresholdsColor.tex50 \path(axis cs:\Chigh,0) coordinate (Chigh);
pgfTikZ/ac2aNoThresholdsColor.tex51
pgfTikZ/ac2aNoThresholdsColor.tex52 \end{axis}

Draw the entry set.

pgfTikZ/ac2aNoThresholdsColor.tex54 \draw[color=green!20!white,line width=10pt] (Alow) -- node[midway,above,color=black]{$\cal A$} (Ahigh);
pgfTikZ/ac2aNoThresholdsColor.tex55 \draw[color=green!20!white,line width=10pt] (Clow) -- node[midway,above,color=black]{$\cal B$} (Chigh);

The entry set just covered the horizontal axis, so we need to redraw it and its tick marks.

pgfTikZ/ac2aNoThresholdsColor.tex57 \draw[color=gray,line width=0.75pt](Alow)--(Chigh);
pgfTikZ/ac2aNoThresholdsColor.tex58 Draw a tick mark at Ccheck and label it.
pgfTikZ/ac2aNoThresholdsColor.tex59 \draw[color=gray,line width=0.75pt](Ccheck) ++(0,1.25mm) -- ++ (0,-2.5mm) ++ (0,-3mm) node[color=black]{\makebox[0pt][r]{$\ln \check C = \ccheck$}};

Draw a tick mark at Chat and label it.

pgfTikZ/ac2aNoThresholdsColor.tex61 \draw[color=gray,line width=0.75pt] (Chat) ++ (0,1.25mm) -- ++ (0,-2.5mm) ++ (0,-2.5mm)
pgfTikZ/ac2aNoThresholdsColor.tex62 node[color=black]{\makebox[0pt][l]{$\ln \hat C = \chat$}};
pgfTikZ/ac2aNoThresholdsColor.tex63 Draw a tick mark at Ahigh and label it with its value.
pgfTikZ/ac2aNoThresholdsColor.tex64 \draw[color=gray,line width=0.75pt] (Ahigh) ++(0,1.25mm) -- ++ (0,-2.5mm) ++(0,-3mm) node[color=black]{$\pgfmathprintnumber{\Ahigh}$};
pgfTikZ/ac2aNoThresholdsColor.tex65

3C.2.2Bottom Panel

The bottom panel's construction involves considerably less coding. We begin by choosing its location.

pgfTikZ/ac2aNoThresholdsColor.tex68 \path(v1.origin) ++(0,-2.5in) coordinate (v2 plot position);

The formatting of the axis is straightforward.

pgfTikZ/ac2aNoThresholdsColor.tex70 \begin{axis}[width=4.5in,height=2.5in,
pgfTikZ/ac2aNoThresholdsColor.tex71 title=Second Entrant's Value Function,
pgfTikZ/ac2aNoThresholdsColor.tex72 name=v2,
pgfTikZ/ac2aNoThresholdsColor.tex73 at = {(v2 plot position)},
pgfTikZ/ac2aNoThresholdsColor.tex74 anchor={origin},
pgfTikZ/ac2aNoThresholdsColor.tex75 ylabel={},
pgfTikZ/ac2aNoThresholdsColor.tex76 axis x line=bottom,
pgfTikZ/ac2aNoThresholdsColor.tex77 every outer x axis line/.append style={-,color=gray,line width=0.75pt},
pgfTikZ/ac2aNoThresholdsColor.tex78 axis y line=left,
pgfTikZ/ac2aNoThresholdsColor.tex79 every outer y axis line/.append style={-,color=gray,line width=0.75pt},
pgfTikZ/ac2aNoThresholdsColor.tex80 xtick={\chat,\cunderbartwo,\coverbartwo,\ccheck},
pgfTikZ/ac2aNoThresholdsColor.tex81 xticklabels={\makebox[0pt][r]{},\raisebox{-2.8mm}{$\ln \underline C_2 = \pgfmathprintnumber{\cunderbartwo}$},\makebox[0pt][c]{$\ln \overline C_2 = \pgfmathprintnumber{\coverbartwo}$},\makebox[0pt][r]{}},
pgfTikZ/ac2aNoThresholdsColor.tex82 ytick={0,\phitwo,\ymax},
pgfTikZ/ac2aNoThresholdsColor.tex83 yticklabels={$0$,\makebox[0pt][r]{$\varphi(2)=\phitwo$},$\pgfmathprintnumber{\ymax}$},
pgfTikZ/ac2aNoThresholdsColor.tex84 major tick length=2.5mm,
pgfTikZ/ac2aNoThresholdsColor.tex85 every tick/.append style={line width=0.75pt},
pgfTikZ/ac2aNoThresholdsColor.tex86 ymin=0,
pgfTikZ/ac2aNoThresholdsColor.tex87 ymax=\ymax,
pgfTikZ/ac2aNoThresholdsColor.tex88 scaled ticks=false,
pgfTikZ/ac2aNoThresholdsColor.tex89 /pgf/number format/precision=2,
pgfTikZ/ac2aNoThresholdsColor.tex90 /pgf/number format/set thousands separator={}]

Draw a horizontal line at the cost of entry.

pgfTikZ/ac2aNoThresholdsColor.tex92 \draw[color=gray,line width=0.75pt,dashed] (axis cs:\chat,\phitwo) -- (axis cs:\ccheck,\phitwo);

Plot the value function for an incumbent with rank 2 and close the axis.

pgfTikZ/ac2aNoThresholdsColor.tex94 \addplot[color=black,line width=1pt] table[x=C,y=v2,col sep=comma]{equilibriumWithoutThresholdsV2.csv};
pgfTikZ/ac2aNoThresholdsColor.tex95
pgfTikZ/ac2aNoThresholdsColor.tex96 \end{axis}

4DCreation of LaTeX Tables and Text

4D.1Table I

Reporting the results requires us to make a LaTeX file that creates macros embodying the numbers included in the text.

tableOfThresholdsLaTeX.m7f1=fopen('tableOfThresholdsText.tex','w');

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

tableOfThresholdsLaTeX.m11fprintf(f1,'\\def\\cFiveSigmaTwo{$%3.2f$}\n',freeEntryThresholds(3,5));
tableOfThresholdsLaTeX.m12fprintf(f1,'\\def\\cFiveSigmaThree{$%3.2f$}\n',freeEntryThresholds(4,5));

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

tableOfThresholdsLaTeX.m16fprintf(f1,'\\def\\cSixSigmaOne{$%3.2f$}\n',freeEntryThresholds(2,6));
tableOfThresholdsLaTeX.m17fprintf(f1,'\\def\\cSixSigmaTwo{$%3.2f$}\n',freeEntryThresholds(3,6));

small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image and small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

tableOfThresholdsLaTeX.m21fprintf(f1,'\\def\\cSevenSigmaZero{$%3.2f$}\n',freeEntryThresholds(1,7));
tableOfThresholdsLaTeX.m22fprintf(f1,'\\def\\cSevenSigmaOne{$%3.2f$}\n',freeEntryThresholds(2,7));

The first static exit threshold.

tableOfThresholdsLaTeX.m26fprintf(f1,'\\def\\cOneSigmaZero{$%3.2f$}\n',freeContinuationThresholds(1,1));

Exit rates

tableOfThresholdsLaTeX.m30fprintf(f1,'\\def\\exitRateOne{$%2.1f$}\n',freeEntryExitRate(2));
tableOfThresholdsLaTeX.m31fprintf(f1,'\\def\\exitRateTwo{$%2.1f$}\n',freeEntryExitRate(3));
tableOfThresholdsLaTeX.m32fprintf(f1,'\\def\\exitRateThree{$%2.1f$}\n',freeEntryExitRate(4));
tableOfThresholdsLaTeX.m33
tableOfThresholdsLaTeX.m34fclose(f1);

We place the table of equilibrium thresholds into ac2atableOfThresholds.tex

tableOfThresholdsLaTeX.m38f1=fopen('tableOfThresholds.tex','w');

The next two panels report the entry and continuation thresholds from the barrier-free equilibrium with different values of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . We construct each of these with a separate tabular environment.

Entry Thresholds from Barrier-Free Experiment

We construct each panel by writing its contents to cell arrays and then using fprintf to place them into the LaTeX file.

tableOfThresholdsLaTeX.m46header=cell(5,1);

Open the tabular environment.

tableOfThresholdsLaTeX.m50header{1} = ['\begin{tabular}{*{' num2str(size(freeEntryThresholds,2)+1) '}{c}}'];

Start with a double rule, as required by the Econometrica style.

tableOfThresholdsLaTeX.m54header{2} = '\hline\hline\\';

The first row labels the experiment being undertaken.

tableOfThresholdsLaTeX.m58header{3} = ['\multicolumn{' num2str(size(freeEntryThresholds,2)+1) '}{c}{ $\pi(N)=4$ }\\ \\'];

The second row describes the results being reported.

tableOfThresholdsLaTeX.m62header{4} = [' & \multicolumn{' num2str(size(freeEntryThresholds,2)) '}{c}{Entry Thresholds} \\'];

The third row labels the contents of each column and draws a line across the table.

tableOfThresholdsLaTeX.m66header{5} = ['$\sigma $' num2str(1:1:size(freeEntryThresholds,2),' & $\\overline{C}_{%1.0f}$') ' \\ \hline'];

Next comes the content. There is one row for each value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image

tableOfThresholdsLaTeX.m70content=cell(length(sigma),size(freeEntryThresholds,2)+2);
tableOfThresholdsLaTeX.m71
tableOfThresholdsLaTeX.m72for i=1:length(sigma)
tableOfThresholdsLaTeX.m73 content{i,1}=num2str(sigma(i),'%2.2f');
tableOfThresholdsLaTeX.m74 for j=1:size(freeEntryThresholds,2);
tableOfThresholdsLaTeX.m75 if ~isnan(freeEntryThresholds(i,j))
tableOfThresholdsLaTeX.m76 content{i,j+1}=num2str(freeEntryThresholds(i,j),' & \\makebox[24pt]{%2.2f}');
tableOfThresholdsLaTeX.m77 end
tableOfThresholdsLaTeX.m78 end
tableOfThresholdsLaTeX.m79 content{i,end}='\\';
tableOfThresholdsLaTeX.m80end

End the tabular environment,

tableOfThresholdsLaTeX.m84footer=cell(1,1);
tableOfThresholdsLaTeX.m85footer{1}='\end{tabular}';

and write the first panel to the output file.

tableOfThresholdsLaTeX.m89for i=1:5
tableOfThresholdsLaTeX.m90 fprintf(f1,'%s\n',char(header{i}));
tableOfThresholdsLaTeX.m91end
tableOfThresholdsLaTeX.m92for i=1:length(sigma)
tableOfThresholdsLaTeX.m93 for j=1:size(freeEntryThresholds,2)+2
tableOfThresholdsLaTeX.m94 fprintf(f1,'%s',char(content{i,j}));
tableOfThresholdsLaTeX.m95 end
tableOfThresholdsLaTeX.m96 fprintf(f1,'\n');
tableOfThresholdsLaTeX.m97end
tableOfThresholdsLaTeX.m98
tableOfThresholdsLaTeX.m99fprintf(f1,'%s\n\n',char(footer{1}));

Continuation Thresholds from Barrier-Free Experiment

The panel with the continuation thresholds has no double line and a blank line (taking space) in place of the experiment label;

tableOfThresholdsLaTeX.m104header{2} = '';
tableOfThresholdsLaTeX.m105header{3} = '\\';

and the results being reported are different.

tableOfThresholdsLaTeX.m109header{4} = [' & \multicolumn{' num2str(size(freeEntryThresholds,2)) '}{c}{Exit Thresholds} \\'];

% The row of column labels uses the notation for continuation thresholds.

tableOfThresholdsLaTeX.m113header{5} = ['$\sigma $' num2str(1:1:size(freeEntryThresholds,2),' & $\\underline{C}_{%1.0f}$') ' \\ \hline'];

The content also obviously changes.

tableOfThresholdsLaTeX.m117content=cell(length(sigma),size(freeEntryThresholds,2)+2);
tableOfThresholdsLaTeX.m118
tableOfThresholdsLaTeX.m119for i=1:length(sigma)
tableOfThresholdsLaTeX.m120 content{i,1}=num2str(sigma(i),'%2.2f');
tableOfThresholdsLaTeX.m121 for j=1:size(freeEntryThresholds,2);
tableOfThresholdsLaTeX.m122 if ~isnan(freeContinuationThresholds(i,j))
tableOfThresholdsLaTeX.m123 content{i,j+1}=num2str(freeContinuationThresholds(i,j),' & \\makebox[24pt]{%2.2f}');
tableOfThresholdsLaTeX.m124 end
tableOfThresholdsLaTeX.m125 end
tableOfThresholdsLaTeX.m126 content{i,end}='\\';
tableOfThresholdsLaTeX.m127end

This panel is now ready for output.

tableOfThresholdsLaTeX.m131for i=1:5
tableOfThresholdsLaTeX.m132 fprintf(f1,'%s\n',char(header{i}));
tableOfThresholdsLaTeX.m133end
tableOfThresholdsLaTeX.m134for i=1:length(sigma)
tableOfThresholdsLaTeX.m135 for j=1:size(freeEntryThresholds,2)+2
tableOfThresholdsLaTeX.m136 fprintf(f1,'%s',char(content{i,j}));
tableOfThresholdsLaTeX.m137 end
tableOfThresholdsLaTeX.m138 fprintf(f1,'\n');
tableOfThresholdsLaTeX.m139end
tableOfThresholdsLaTeX.m140
tableOfThresholdsLaTeX.m141fprintf(f1,'%s\n\n',char(footer{1}));

Put a \bigskip between the two experiments

tableOfThresholdsLaTeX.m145fprintf(f1,'\n\\bigskip\n');

Entry Thresholds for Experiments with Barrier

This panel also has no double line but does get a label.

tableOfThresholdsLaTeX.m150header{3} = ['\multicolumn{' num2str(size(freeEntryThresholds,2)+1) '}{c}{ $\pi(N)=4\times I\left\{N\leq 4\right\}$ }\\ \\'];
tableOfThresholdsLaTeX.m151header{4} = [' & \multicolumn{' num2str(size(freeEntryThresholds,2)) '}{c}{Entry Thresholds} \\'];
tableOfThresholdsLaTeX.m152header{5} = ['$\sigma $' num2str(1:1:size(freeEntryThresholds,2),' & $\\overline{C}_{%1.0f}$') ' \\ \hline'];

Pad fourEntryThresholds with NaNs so that it is the same width as freeEntryThresholds.

tableOfThresholdsLaTeX.m156fourEntryThresholds=[fourEntryThresholds NaN(length(sigma),size(freeEntryThresholds,2)-4)];
tableOfThresholdsLaTeX.m157
tableOfThresholdsLaTeX.m158content=cell(length(sigma),size(freeEntryThresholds,2)+2);
tableOfThresholdsLaTeX.m159
tableOfThresholdsLaTeX.m160for i=1:length(sigma)
tableOfThresholdsLaTeX.m161 content{i,1}=num2str(sigma(i),'%2.2f');
tableOfThresholdsLaTeX.m162 for j=1:size(fourEntryThresholds,2);
tableOfThresholdsLaTeX.m163 if ~isnan(fourEntryThresholds(i,j))
tableOfThresholdsLaTeX.m164 content{i,j+1}=num2str(fourEntryThresholds(i,j),' & \\makebox[24pt]{%2.2f}');
tableOfThresholdsLaTeX.m165 else
tableOfThresholdsLaTeX.m166 content{i,j+1}='& \makebox[24pt]{}';
tableOfThresholdsLaTeX.m167 end
tableOfThresholdsLaTeX.m168 end
tableOfThresholdsLaTeX.m169 content{i,end}='\\';
tableOfThresholdsLaTeX.m170end

Send this panel to the output.

tableOfThresholdsLaTeX.m174for i=1:5
tableOfThresholdsLaTeX.m175 fprintf(f1,'%s\n',char(header{i}));
tableOfThresholdsLaTeX.m176end
tableOfThresholdsLaTeX.m177for i=1:length(sigma)
tableOfThresholdsLaTeX.m178 for j=1:size(fourEntryThresholds,2)+2
tableOfThresholdsLaTeX.m179 fprintf(f1,'%s',char(content{i,j}));
tableOfThresholdsLaTeX.m180 end
tableOfThresholdsLaTeX.m181 fprintf(f1,'\n');
tableOfThresholdsLaTeX.m182end
tableOfThresholdsLaTeX.m183
tableOfThresholdsLaTeX.m184fprintf(f1,'%s\n\n',char(footer{1}));

Exit Thresholds for Experiments with Barrier

This panel mimics that for the exit thresholds from the barrier-free experiments.

tableOfThresholdsLaTeX.m189header{3} = '\\';
tableOfThresholdsLaTeX.m190header{4} = [' & \multicolumn{' num2str(size(freeEntryThresholds,2)) '}{c}{Exit Thresholds} \\'];
tableOfThresholdsLaTeX.m191header{5} = ['$\sigma $' num2str(1:1:size(freeEntryThresholds,2),' & $\\underline{C}_{%1.0f}$') ' \\ \hline'];

The panel's content comes from fourContinuationThresholds. Pad it with NaNs so that the relevant columns are filled with an empty box.

tableOfThresholdsLaTeX.m195fourContinuationThresholds=[fourContinuationThresholds NaN(length(sigma),size(freeEntryThresholds,2)-4)];
tableOfThresholdsLaTeX.m196
tableOfThresholdsLaTeX.m197content=cell(length(sigma),size(fourEntryThresholds,2)+2);
tableOfThresholdsLaTeX.m198
tableOfThresholdsLaTeX.m199for i=1:length(sigma)
tableOfThresholdsLaTeX.m200 content{i,1}=num2str(sigma(i),'%2.2f');
tableOfThresholdsLaTeX.m201 for j=1:size(fourContinuationThresholds,2);
tableOfThresholdsLaTeX.m202 if ~isnan(fourContinuationThresholds(i,j))
tableOfThresholdsLaTeX.m203 content{i,j+1}=num2str(fourContinuationThresholds(i,j),' & \\makebox[24pt]{%2.2f}');
tableOfThresholdsLaTeX.m204 else
tableOfThresholdsLaTeX.m205 content{i,j+1}='& \makebox[24pt]{}';
tableOfThresholdsLaTeX.m206 end
tableOfThresholdsLaTeX.m207 end
tableOfThresholdsLaTeX.m208 content{i,end}='\\';
tableOfThresholdsLaTeX.m209end

Send this panel to the output.

tableOfThresholdsLaTeX.m213for i=1:5
tableOfThresholdsLaTeX.m214 fprintf(f1,'%s\n',char(header{i}));
tableOfThresholdsLaTeX.m215end
tableOfThresholdsLaTeX.m216for i=1:length(sigma)
tableOfThresholdsLaTeX.m217 for j=1:size(fourEntryThresholds,2)+2
tableOfThresholdsLaTeX.m218 fprintf(f1,'%s',char(content{i,j}));
tableOfThresholdsLaTeX.m219 end
tableOfThresholdsLaTeX.m220 fprintf(f1,'\n');
tableOfThresholdsLaTeX.m221end
tableOfThresholdsLaTeX.m222
tableOfThresholdsLaTeX.m223fprintf(f1,'%s\n\n',char(footer{1}));

This completes this table's construction. All that remains is to close the output file.

tableOfThresholdsLaTeX.m227fclose(f1);

4D.2Table II

We place the table of equilibrium thresholds into tableOfOrderedProbitThresholds.tex

tableOfOrderedProbitThresholdsLaTeX.m7f1=fopen('tableOfOrderedProbitThresholds.tex','w');

Threshold Estimates

The first panel reports the estimated ordered Probit thresholds. Each row corresponds to a different value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

tableOfOrderedProbitThresholdsLaTeX.m12header=cell(4,1);

Open the tabular environment.

tableOfOrderedProbitThresholdsLaTeX.m16header{1} = ['\begin{tabular}{*{' num2str(size(probitThresholds,2)+1) '}{c}}'];

Start with a double rule, as required by the Econometrica style.

tableOfOrderedProbitThresholdsLaTeX.m20header{2} = '\hline\hline\\';

The first row labels the results

tableOfOrderedProbitThresholdsLaTeX.m24header{3} = ['\multicolumn{' num2str(size(probitThresholds,2)+1) '}{c}{ Implied Static Entry Thresholds }\\ \\'];

The second row labels the contents of each column and draws a line across the table.

tableOfOrderedProbitThresholdsLaTeX.m28header{4} = ['$\sigma $' num2str(1:1:size(probitThresholds,2),' & $\\overline{C}_{%1.0f}$') ' \\ \hline'];

Next comes the content. There is one row for each value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image .

tableOfOrderedProbitThresholdsLaTeX.m32content=cell(length(sigma),size(probitThresholds,2)+2);
tableOfOrderedProbitThresholdsLaTeX.m33
tableOfOrderedProbitThresholdsLaTeX.m34for i=1:length(sigma)
tableOfOrderedProbitThresholdsLaTeX.m35 content{i,1}=num2str(sigma(i),'%2.2f');
tableOfOrderedProbitThresholdsLaTeX.m36 for j=1:size(probitThresholds,2);
tableOfOrderedProbitThresholdsLaTeX.m37 if ~isnan(probitThresholds(i,j))
tableOfOrderedProbitThresholdsLaTeX.m38 content{i,j+1}=num2str(probitThresholds(i,j),' & \\makebox[24pt]{%2.2f}');
tableOfOrderedProbitThresholdsLaTeX.m39 end
tableOfOrderedProbitThresholdsLaTeX.m40 end
tableOfOrderedProbitThresholdsLaTeX.m41 content{i,end}='\\';
tableOfOrderedProbitThresholdsLaTeX.m42end

End the tabular environment,

tableOfOrderedProbitThresholdsLaTeX.m46footer=cell(1,1);
tableOfOrderedProbitThresholdsLaTeX.m47footer{1}='\end{tabular}';

and write the first panel to the output file.

tableOfOrderedProbitThresholdsLaTeX.m51for i=1:4
tableOfOrderedProbitThresholdsLaTeX.m52 fprintf(f1,'%s\n',char(header{i}));
tableOfOrderedProbitThresholdsLaTeX.m53end
tableOfOrderedProbitThresholdsLaTeX.m54for i=1:length(sigma)
tableOfOrderedProbitThresholdsLaTeX.m55 for j=1:size(probitThresholds,2)+2
tableOfOrderedProbitThresholdsLaTeX.m56 fprintf(f1,'%s',char(content{i,j}));
tableOfOrderedProbitThresholdsLaTeX.m57 end
tableOfOrderedProbitThresholdsLaTeX.m58 fprintf(f1,'\n');
tableOfOrderedProbitThresholdsLaTeX.m59end
tableOfOrderedProbitThresholdsLaTeX.m60
tableOfOrderedProbitThresholdsLaTeX.m61fprintf(f1,'%s\n\n',char(footer{1}));

Producers' Surplus Estimates

The second panel reports the ratios of per customer producers' surplus in piRatios. Its format is similar to the first panel's, but it has no double line at the top, the label for the results is different, and its first row lists the value of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image rather than the notation for the static entry thresholds.

tableOfOrderedProbitThresholdsLaTeX.m67header{2}='';
tableOfOrderedProbitThresholdsLaTeX.m68header{3}= ['\multicolumn{' num2str(size(piRatios,2)+1) '}{c}{Implied $\pi(N)/\pi(1)$ for $N=$}\\ \\'];
tableOfOrderedProbitThresholdsLaTeX.m69header{4} = ['$\sigma $' num2str(1:1:size(probitThresholds,2),' & $%1.0f$') ' \\ \hline'];

The code for creating the second panel's content is identical to that of the first panel.

tableOfOrderedProbitThresholdsLaTeX.m73content=cell(length(sigma),size(piRatios,2)+2);
tableOfOrderedProbitThresholdsLaTeX.m74
tableOfOrderedProbitThresholdsLaTeX.m75for i=1:length(sigma)
tableOfOrderedProbitThresholdsLaTeX.m76 content{i,1}=num2str(sigma(i),'%2.2f');
tableOfOrderedProbitThresholdsLaTeX.m77 for j=1:size(piRatios,2);
tableOfOrderedProbitThresholdsLaTeX.m78 if ~isnan(piRatios(i,j))
tableOfOrderedProbitThresholdsLaTeX.m79 content{i,j+1}=num2str(piRatios(i,j),' & \\makebox[24pt]{%2.2f}');
tableOfOrderedProbitThresholdsLaTeX.m80 end
tableOfOrderedProbitThresholdsLaTeX.m81 end
tableOfOrderedProbitThresholdsLaTeX.m82 content{i,end}='\\';
tableOfOrderedProbitThresholdsLaTeX.m83end

We can now write the second panel to the output file.

tableOfOrderedProbitThresholdsLaTeX.m87for i=1:4
tableOfOrderedProbitThresholdsLaTeX.m88 fprintf(f1,'%s\n',char(header{i}));
tableOfOrderedProbitThresholdsLaTeX.m89end
tableOfOrderedProbitThresholdsLaTeX.m90for i=1:length(sigma)
tableOfOrderedProbitThresholdsLaTeX.m91 for j=1:size(piRatios,2)+2
tableOfOrderedProbitThresholdsLaTeX.m92 fprintf(f1,'%s',char(content{i,j}));
tableOfOrderedProbitThresholdsLaTeX.m93 end
tableOfOrderedProbitThresholdsLaTeX.m94 fprintf(f1,'\n');
tableOfOrderedProbitThresholdsLaTeX.m95end
tableOfOrderedProbitThresholdsLaTeX.m96
tableOfOrderedProbitThresholdsLaTeX.m97fprintf(f1,'%s\n\n',char(footer{1}));

This completes the creation of the LaTeX table. All that remains is to close the output file.

tableOfOrderedProbitThresholdsLaTeX.m101fclose(f1);

One final task remains undone. The text references the ordered probit estimate of small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image for the case with small image LARGE image footnotesize image Large image scriptsize image large image tiny image Huge image huge image normalsize image . To include this in the text automatically, we write the command to create a LaTeX macro containing its value to a text file.

tableOfOrderedProbitThresholdsLaTeX.m106f1=fopen('tableOfOrderedProbitThresholdsText.tex','w');
tableOfOrderedProbitThresholdsLaTeX.m107fprintf(f1,'\\def\\piRatioFourTwo{$%3.2f$}\n',piRatios(3,2));
tableOfOrderedProbitThresholdsLaTeX.m108fclose(f1);


1 A similar option is available on Microsoft Internet Explorer. We use Cascading Style Sheets (CSS2) for all formatting. Since IE implements this standard poorly, we cannot guarantee that it will display this document well.
2We have successfully printed this using Firefox for the Macintosh and Firefox for Linux. Sadly, not all browsers are so cooperative. This document apparently triggers a bug in Safari that causes multiple blank pages to be printed after each actual page.
3It would probably be better to do this with pgfkeys.
4The “file” ac2apencilColor.tex within /compute is only a link to the file used by LaTeX when compiling the program.
5Again, the “file ac2aNoThresholdsColor.tex within compute| is only a link to the file used by LaTeX when compiling the program.
pencil.m7beta=1.05^(-5);
pencil.m8kappa=1.25;
pencil.m9phi=@(N) 1;
pencil.m10pi = @(N) 2-2*(N>2);
pencil.m11chat=0.1;
pencil.m12ccheck=2.5;
pencil.m13lambda=0.1;
pencil.m55cstar2 = @(vtilde2) (kappa-lambda*vtilde2/(1-lambda))*2/pi(2);
pencil.m56cunderbar2 = @(vtilde2) min(max(chat,cstar2(vtilde2)),ccheck);
pencil.m57vtildeprime2 = @(vtilde2) 0.25*(ccheck+chat)*pi(2)-kappa + ...
pencil.m58 +beta*((1-lambda)*(ccheck^2*pi(2)*0.25 - ccheck*kappa)...
pencil.m59 +lambda*ccheck*vtilde2)/((1-beta*(1-lambda))*(ccheck-chat))...
pencil.m60 -beta*((1-lambda)*(cunderbar2(vtilde2)^2*pi(2)*0.25 - cunderbar2(vtilde2)*kappa)...
pencil.m61 +cunderbar2(vtilde2)*lambda*vtilde2)/((1-beta*(1-lambda))*(ccheck-chat));
pencil.m67epsilon=1e-5;
pencil.m68T = (log(epsilon)-log(ccheck*pi(1)/(1-beta)))/log(beta)+1;
pencil.m69
pencil.m70vtilde2=0;
pencil.m71t=0;
pencil.m72
pencil.m73while t<T
pencil.m74 vtilde2=vtildeprime2(vtilde2);
pencil.m75 t=t+1;
pencil.m76end
pencil.m82cstarstar2 = @(vtilde2) (phi(2)*(1-beta*(1-lambda))/(beta*(1-lambda))...
pencil.m83 + kappa-lambda*vtilde2/(1-lambda))*2/pi(2);
pencil.m84coverbar2 = @(vtilde2) min(max(chat,cstarstar2(vtilde2)),ccheck);
pencil.m125cstar1= @(vtilde1) (kappa-lambda*vtilde1(1)/(1-lambda))/pi(1);
pencil.m131cunderbar1 = @(vtilde1) max(chat,cstar1(vtilde1));
pencil.m149vtildeprime10 = @(vtilde1) ((chat+ccheck)/2)*pi(1) - kappa + beta/((1-beta*(1-lambda))*(ccheck-chat))...
pencil.m150 *((1-lambda)*(coverbar2(vtilde2)^2*pi(1)/2-kappa*coverbar2(vtilde2))...
pencil.m151 +lambda*vtilde1(1)*coverbar2(vtilde2)...
pencil.m152 -((1-lambda)*(cunderbar1(vtilde1)^2*pi(1)/2-kappa*cunderbar1(vtilde1))...
pencil.m153 +lambda*vtilde1(1)*cunderbar1(vtilde1)) ...
pencil.m154 +(1-lambda)*(ccheck^2*pi(2)/4-kappa*ccheck)...
pencil.m155 +lambda*vtilde1(2)*ccheck ...
pencil.m156 -((1-lambda)*(coverbar2(vtilde2)^2*pi(2)/4-kappa*coverbar2(vtilde2))...
pencil.m157 +lambda*vtilde1(2)*coverbar2(vtilde2)));
pencil.m158
pencil.m159vtildeprime11 = @(vtilde1) ((chat+ccheck)/2)*pi(2)/2 - kappa + beta/((1-beta*(1-lambda))*(ccheck-chat))...
pencil.m160 *((1-lambda)*(cunderbar2(vtilde2)^2*pi(1)/2-kappa*cunderbar2(vtilde2))...
pencil.m161 +lambda*vtilde1(1)*cunderbar2(vtilde2)...
pencil.m162 -((1-lambda)*(cunderbar1(vtilde1)^2*pi(1)/2-kappa*cunderbar1(vtilde1))...
pencil.m163 +lambda*vtilde1(1)*cunderbar1(vtilde1)) ...
pencil.m164 +(1-lambda)*(ccheck^2*pi(2)/4-kappa*ccheck)...
pencil.m165 +lambda*vtilde1(2)*ccheck ...
pencil.m166 -((1-lambda)*(cunderbar2(vtilde2)^2*pi(2)/4-kappa*cunderbar2(vtilde2))...
pencil.m167 +lambda*vtilde1(2)*cunderbar2(vtilde2)));
pencil.m168
pencil.m169vtildeprime1 = @(vtilde1) [vtildeprime10(vtilde1) vtildeprime11(vtilde1)];
pencil.m173vtilde1=[vtilde2 vtilde2];
pencil.m174t=0;
pencil.m175while t<T
pencil.m176
pencil.m177 vtilde1=vtildeprime1(vtilde1);
pencil.m178 t=t+1;
pencil.m179
pencil.m180end
pencil.m184cstarstar1 = @(vtilde1) (phi(1)*(1-beta*(1-lambda))/beta/(1-lambda) ...
pencil.m185 + kappa-lambda*vtilde1(1)/(1-lambda))/pi(1);
pencil.m186coverbar1 = @(vtilde1) min(max(chat,cstarstar1(vtilde1)),ccheck);
pencil.m213f1=fopen('pgfTikZ/ac2aPencilConstants.tex','w');
pencil.m219fprintf(f1,'\\def\\pencilChat{%3.2f}\n',chat);
pencil.m220fprintf(f1,'\\def\\pencilCcheck{%3.2f}\n',ccheck);
pencil.m221fprintf(f1,'\\def\\pencilCunderbarOne{%3.2f}\n',cunderbar1(vtilde1));
pencil.m222fprintf(f1,'\\def\\pencilCoverbarOne{%3.2f}\n',coverbar1(vtilde1));
pencil.m223fprintf(f1,'\\def\\pencilCunderbarTwo{%3.2f}\n',cunderbar2(vtilde2));
pencil.m224fprintf(f1,'\\def\\pencilCoverbarTwo{%3.2f}\n',coverbar2(vtilde2));
pencil.m228fprintf(f1,'\\def\\pencilPhiTwo{%3.2f}\n',phi(2));
pencil.m229fprintf(f1,'\\def\\pencilPhiOne{%3.2f}\n',phi(1));
pencil.m233v11coverbar2=beta*((1-lambda)*(coverbar2(vtilde2)*pi(1)-kappa)...
pencil.m234 +lambda*vtilde1(1))/(1-beta*(1-lambda));
pencil.m235fprintf(f1,'\\def\\pencilVOneOneCoverbarTwo{%3.2f}\n',v11coverbar2);
pencil.m239v12cunderbartwo=beta*((1-lambda)*(cunderbar2(vtilde2)*pi(2)/2-kappa)...
pencil.m240 +lambda*vtilde1(2))/(1-beta*(1-lambda));
pencil.m241fprintf(f1,'\\def\\pencilVOneTwoCunderbarTwo{%3.2f}\n',v12cunderbartwo);
pencil.m245v12ccheck=beta*((1-lambda)*(ccheck*pi(2)/2-kappa)...
pencil.m246 +lambda*vtilde1(2))/(1-beta*(1-lambda));
pencil.m247fprintf(f1,'\\def\\pencilVOneTwoCcheck{%3.2f}\n',v12ccheck);
pencil.m251v2ccheck=beta*((1-lambda)*(ccheck*pi(2)/2-kappa)...
pencil.m252 +lambda*vtilde2)/(1-beta*(1-lambda));
pencil.m253fprintf(f1,'\\def\\pencilVTwoCcheck{%3.2f}\n',v2ccheck);
pencil.m257fprintf(f1,'\\def\\pencilPiOne{%3.2f}\n',pi(1));
pencil.m258fclose(f1);
pencil.m264makequit
makequit.m7if ( isunix || ismac )
makequit.m8
makequit.m9 makelevel=getenv('MAKELEVEL');
makequit.m10
makequit.m11 if ~strcmp(makelevel,'') && ~exist('stay','var')
makequit.m12 quit
makequit.m13 end
makequit.m14
makequit.m15end
solveOptimalStoppingProblem.m44function OUT = solveOptimalStoppingProblem(ARG)
solveOptimalStoppingProblem.m45
solveOptimalStoppingProblem.m47OUT=ARG;
solveOptimalStoppingProblem.m48
solveOptimalStoppingProblem.m50calX = ARG.stateSpace;
solveOptimalStoppingProblem.m51Pi = ARG.transitionMatrix;
solveOptimalStoppingProblem.m52f = ARG.flowPayoff;
solveOptimalStoppingProblem.m53S = ARG.outsideValue;
solveOptimalStoppingProblem.m54beta = ARG.discountFactor;
solveOptimalStoppingProblem.m55eps = ARG.convergenceTolerance;
solveOptimalStoppingProblem.m56V = ARG.valueFunction;
solveOptimalStoppingProblem.m57
solveOptimalStoppingProblem.m61fX = f(calX);
solveOptimalStoppingProblem.m62SX = S(calX);
solveOptimalStoppingProblem.m63
solveOptimalStoppingProblem.m67vDistance=eps+1;
solveOptimalStoppingProblem.m68
solveOptimalStoppingProblem.m71while vDistance>eps
solveOptimalStoppingProblem.m72
solveOptimalStoppingProblem.m73 Vprime=max([SX beta*(Pi*(fX+V))],[],2);
solveOptimalStoppingProblem.m74 vDistance=max(abs(Vprime-V));
solveOptimalStoppingProblem.m75 V=Vprime;
solveOptimalStoppingProblem.m76
solveOptimalStoppingProblem.m77end
solveOptimalStoppingProblem.m78
solveOptimalStoppingProblem.m82OUT.valueFunction=V;
solveOptimalStoppingProblem.m83end
solveOptimalStoppingProblem.m84
solveOptimalStoppingProblemTest.m6chat=0.1;
solveOptimalStoppingProblemTest.m7ccheck=2.5;
solveOptimalStoppingProblemTest.m8step=0.01;
solveOptimalStoppingProblemTest.m9omega=(chat:step:ccheck)';
solveOptimalStoppingProblemTest.m10N = length(omega);
solveOptimalStoppingProblemTest.m11
solveOptimalStoppingProblemTest.m12lambda=0.1;
solveOptimalStoppingProblemTest.m13Pi=(1-lambda)*eye(N)+lambda*ones(N,N)/N;
solveOptimalStoppingProblemTest.m17pi=2;
solveOptimalStoppingProblemTest.m18kappa=1.25;
solveOptimalStoppingProblemTest.m19f = @(x) x*pi/2-kappa;
solveOptimalStoppingProblemTest.m20S = @(x) zeros(size(x,1),1);
solveOptimalStoppingProblemTest.m24beta=1.05^(-5);
solveOptimalStoppingProblemTest.m28eps=1e-7;
solveOptimalStoppingProblemTest.m32V=zeros(N,1);
solveOptimalStoppingProblemTest.m36PENCIL.stateSpace = omega;
solveOptimalStoppingProblemTest.m37PENCIL.transitionMatrix = Pi;
solveOptimalStoppingProblemTest.m38PENCIL.flowPayoff = f;
solveOptimalStoppingProblemTest.m39PENCIL.outsideValue = S;
solveOptimalStoppingProblemTest.m40PENCIL.discountFactor = beta;
solveOptimalStoppingProblemTest.m41PENCIL.convergenceTolerance = eps;
solveOptimalStoppingProblemTest.m42PENCIL.valueFunction = V;
solveOptimalStoppingProblemTest.m46PENCIL = solveOptimalStoppingProblem(PENCIL);
solveOptimalStoppingProblemTest.m52cunderbarIndex=find(PENCIL.valueFunction==0,1,'last');
solveOptimalStoppingProblemTest.m53cunderbar=PENCIL.stateSpace(cunderbarIndex);
solveOptimalStoppingProblemTest.m54
solveOptimalStoppingProblemTest.m55coverbarIndex=find(PENCIL.valueFunction<1,1,'last');
solveOptimalStoppingProblemTest.m56coverbar=PENCIL.stateSpace(coverbarIndex);
solveOptimalStoppingProblemTest.m57plot(PENCIL.stateSpace,ones(length(PENCIL.stateSpace),1),'-','LineWidth',1.5,'Color',[0.8 0.8 0.8]);
solveOptimalStoppingProblemTest.m58hold
solveOptimalStoppingProblemTest.m59plot(PENCIL.stateSpace,PENCIL.valueFunction,'-k','LineWidth',2);
solveOptimalStoppingProblemTest.m60
solveOptimalStoppingProblemTest.m61set(gca,'box','off','FontSize',14,'Xtick',[chat cunderbar coverbar ccheck]);
solveOptimalStoppingProblemTest.m62xlim([chat ccheck]);
solveOptimalStoppingProblemTest.m63set(gcf,'Color',[1 1 1]);
solveOptimalStoppingProblemTest.m67set(gcf,'Position',[-3 5 1280 950],...
solveOptimalStoppingProblemTest.m68 'PaperUnits','in','PaperSize',[5 3],...
solveOptimalStoppingProblemTest.m69 'PaperPositionMode','manual',...
solveOptimalStoppingProblemTest.m70 'PaperPosition',[0 0 5 3]);
solveOptimalStoppingProblemTest.m71print -djpeg -painters solveOptimalStoppingProblemTest.jpg
solveOptimalStoppingProblemTest.m72makequit;
calculateLifoEquilibrium.m24function OUT = calculateLifoEquilibrium(ARG)
calculateLifoEquilibrium.m25
calculateLifoEquilibrium.m28pi = ARG.pi;
calculateLifoEquilibrium.m29kappa = ARG.kappa;
calculateLifoEquilibrium.m30phi = ARG.phi;
calculateLifoEquilibrium.m31omega = ARG.omega;
calculateLifoEquilibrium.m32Pi = ARG.Pi;
calculateLifoEquilibrium.m33beta = ARG.beta;
calculateLifoEquilibrium.m34eps = ARG.convergenceTolerance;
calculateLifoEquilibrium.m35nCheck = ARG.nCheck;
calculateLifoEquilibrium.m36
calculateLifoEquilibrium.m37
calculateLifoEquilibrium.m45f = @(x) x(:,1).*pi(x(:,2))./x(:,2)-kappa;
calculateLifoEquilibrium.m46
calculateLifoEquilibrium.m50if isempty(nCheck)
calculateLifoEquilibrium.m51 nCheck=1;
calculateLifoEquilibrium.m52 cCheck=max(omega);
calculateLifoEquilibrium.m53 while f([cCheck nCheck])>0
calculateLifoEquilibrium.m54 nCheck=nCheck+1;
calculateLifoEquilibrium.m55 end
calculateLifoEquilibrium.m56 ARG.nCheck=nCheck-1;
calculateLifoEquilibrium.m57 nCheck=ARG.nCheck;
calculateLifoEquilibrium.m58end
calculateLifoEquilibrium.m59
calculateLifoEquilibrium.m61n=length(omega);
calculateLifoEquilibrium.m62V = zeros(nCheck,n,nCheck);
calculateLifoEquilibrium.m63nPrime = ones(n,1)*(1:1:nCheck);
calculateLifoEquilibrium.m64
calculateLifoEquilibrium.m65
calculateLifoEquilibrium.m67for i=nCheck:-1:1
calculateLifoEquilibrium.m68
calculateLifoEquilibrium.m69
calculateLifoEquilibrium.m71ARG_TRANSITION.transitionMatrixForC = Pi;
calculateLifoEquilibrium.m72ARG_TRANSITION.supportForC = omega;
calculateLifoEquilibrium.m73ARG_TRANSITION.minimumN = i;
calculateLifoEquilibrium.m74ARG_TRANSITION.maximumN = nCheck;
calculateLifoEquilibrium.m75ARG_TRANSITION.nextN = nPrime(:,i:nCheck);
calculateLifoEquilibrium.m76
calculateLifoEquilibrium.m77TRANSITION=calculateLifoTransitionMatrix(ARG_TRANSITION);
calculateLifoEquilibrium.m78
calculateLifoEquilibrium.m80STOPPING.stateSpace = TRANSITION.supportForCandN;
calculateLifoEquilibrium.m81STOPPING.transitionMatrix = TRANSITION.transitionMatrixForCandN;
calculateLifoEquilibrium.m82STOPPING.flowPayoff = f;
calculateLifoEquilibrium.m83STOPPING.outsideValue = @(x) zeros(size(x,1),1);
calculateLifoEquilibrium.m84STOPPING.discountFactor = beta;
calculateLifoEquilibrium.m85STOPPING.convergenceTolerance= eps;
calculateLifoEquilibrium.m86STOPPING.valueFunction = zeros(length(TRANSITION.supportForCandN),1);
calculateLifoEquilibrium.m87
calculateLifoEquilibrium.m88STOPPING=solveOptimalStoppingProblem(STOPPING);
calculateLifoEquilibrium.m89
calculateLifoEquilibrium.m92vMatrix=reshape(STOPPING.valueFunction,n,nCheck-i+1);
calculateLifoEquilibrium.m93
calculateLifoEquilibrium.m95nPrime(:,i:nCheck)=nPrime(:,i:nCheck)-(vMatrix==0);
calculateLifoEquilibrium.m96
calculateLifoEquilibrium.m98nPrime(:,1:i-1)=nPrime(:,1:i-1)+(vMatrix(:,1)*ones(1,i-1)>phi(i));
calculateLifoEquilibrium.m99
calculateLifoEquilibrium.m101if i>1
calculateLifoEquilibrium.m102 V(i,:,:)=[NaN(n,i-1) vMatrix];
calculateLifoEquilibrium.m103else
calculateLifoEquilibrium.m104 V(i,:,:)=vMatrix;
calculateLifoEquilibrium.m105end
calculateLifoEquilibrium.m106
calculateLifoEquilibrium.m107end
calculateLifoEquilibrium.m108
calculateLifoEquilibrium.m111nPrimeZero=zeros(n,1);
calculateLifoEquilibrium.m112
calculateLifoEquilibrium.m113for j=1:nCheck;
calculateLifoEquilibrium.m114 vj=squeeze(V(j,:,j))';
calculateLifoEquilibrium.m115 nPrimeZero=nPrimeZero+(vj>phi(j));
calculateLifoEquilibrium.m116end
calculateLifoEquilibrium.m117nPrime = [nPrimeZero nPrime];
calculateLifoEquilibrium.m118
calculateLifoEquilibrium.m119
calculateLifoEquilibrium.m122OUT=ARG;
calculateLifoEquilibrium.m123OUT.nCheck=nCheck;
calculateLifoEquilibrium.m124OUT.valueFunction=V;
calculateLifoEquilibrium.m125OUT.equilibriumFirmCount=nPrime;
calculateLifoEquilibrium.m126
calculateLifoEquilibriumTest.m6chat=0.1;
calculateLifoEquilibriumTest.m7ccheck=2.5;
calculateLifoEquilibriumTest.m8step=0.01;
calculateLifoEquilibriumTest.m9omega=(chat:step:ccheck)';
calculateLifoEquilibriumTest.m10N = length(omega);
calculateLifoEquilibriumTest.m11lambda=0.1;
calculateLifoEquilibriumTest.m12Pi=(1-lambda)*eye(N)+lambda*ones(N,N)/N;
calculateLifoEquilibriumTest.m13kappa=1.25;
calculateLifoEquilibriumTest.m14pi = @(x) 2*ones(size(x,1),1);
calculateLifoEquilibriumTest.m15beta=1.05^(-5);
calculateLifoEquilibriumTest.m16phi = @(x) ones(length(x),1);
calculateLifoEquilibriumTest.m17
calculateLifoEquilibriumTest.m21eps=1e-7;
calculateLifoEquilibriumTest.m25ARG.pi = pi;
calculateLifoEquilibriumTest.m26ARG.kappa = kappa;
calculateLifoEquilibriumTest.m27ARG.phi = phi;
calculateLifoEquilibriumTest.m28ARG.omega = omega;
calculateLifoEquilibriumTest.m29ARG.Pi = Pi;
calculateLifoEquilibriumTest.m30ARG.beta = beta;
calculateLifoEquilibriumTest.m31ARG.convergenceTolerance = 1e-7;
calculateLifoEquilibriumTest.m32ARG.nCheck = [];
calculateLifoEquilibriumTest.m33ARG.V = [];
calculateLifoEquilibriumTest.m34ARG.nPrime = [];
calculateLifoEquilibriumTest.m35
calculateLifoEquilibriumTest.m36OUT=calculateLifoEquilibrium(ARG);
calculateLifoEquilibriumTest.m40nCheck=OUT.nCheck;
calculateLifoEquilibriumTest.m41V=OUT.valueFunction;
calculateLifoEquilibriumTest.m42
calculateLifoEquilibriumTest.m43figure(1)
calculateLifoEquilibriumTest.m44for i=1:nCheck;
calculateLifoEquilibriumTest.m45 subplot(nCheck,1,i)
calculateLifoEquilibriumTest.m49 plot(omega,phi(i)*ones(size(omega)),'LineWidth',2,'Color',[0.8 0.8 0.8]);
calculateLifoEquilibriumTest.m53