nothreshold.m

Calculates the equilibrium continuation values for a parameterization of the Markov chain that does not generate a threshold rule. LaTeX/TikZ uses the results to create Figure 3 of Abbring and Campbell's ``Last-In First-Out Oligopoly Dynamics.''

Contents

Set up the problem's parameters.

For this specification, the Markov chain does not approximate an AR(1) with a continuous distribution, so we override the usual call to markov.m by defining Pi before calling bellman.m

%Parameters describing profits and discounting.

k=2;
piF = @(x) k.*(x<=k);
kappa=1.0;
beta=1.05^(-1);             %5 percent annual interest rate.
phi= @(N) 10;

%Parameters describing the Markov chain

%Support of C
omega=-1.5:0.001:1.5;
nCstates=length(omega);

%Markov transition matrix
Pi=eye(length(omega));


for i=301:1:length(omega)-300
    Pi(i,i)=0.5;
    Pi(i,i-300)=0.25;
    Pi(i,i+300)=0.25;
end

for i=length(omega)-300+1:1:length(omega);
    Pi(i,i)=0.5;
    Pi(i,i-300)=0.25;
    Pi(i,end)=Pi(i,end)+0.25;
end

for i=1:1:300
    Pi(i,i)=0.5;
    Pi(i,1)=Pi(i,1)+0.25;
    Pi(i,i+300)=0.25;
end

% build markovARG to pass to bellman
markovARG.Pi = Pi;
markovARG.omega = omega;
markovARG.nCstates = nCstates;

Call bellman.m

[nPrime,nPrimeIndex,vFuncs,minN,maxN,Pi,omega,nCstates] = bellman(piF,kappa,beta,phi,markovARG);

Calculate the entry and exit thresholds for the second competitor

v2=squeeze(vFuncs(:,:,2));
v2=v2(:,2);
if min(v2)<=phi(2);
    overlineC=omega(find(v2<=phi(2),1,'last'));
else
    overlineC=omega(1);
end

if min(v2)==0;
    underlineC=omega(find(v2==0,1,'last'));
else
    underlineC=omega(1);
end

Calculate the entry set for the first competitor and its ``hole''

v1=squeeze(vFuncs(:,:,1));
Alow=min(omega(v1(:,1)>=phi(1)));
Ahigh=min(omega(v1(:,1)<=phi(1) & omega'>Alow));
Clow=min(omega(v1(:,1)>=phi(1) & omega'>Ahigh));
Chigh=max(omega);

Export v1 and v2 to csv files for LaTeX plotting

v11=[omega(omega<=overlineC); v1(omega<=overlineC,1)']; %Note that fprintf spits out its input in column order.

f1=fopen('ac2aNoThresholdV11.csv','w');
fprintf(f1,'C, v11, dummy\n');
fprintf(f1,'%3.3f, %3.3f, 1.0\n',v11);
fclose(f1);

v12=[omega(omega>underlineC); v1(omega>underlineC,2)'];
f1=fopen('ac2aNoThresholdV12.csv','w');
fprintf(f1,'C, v12, dummy\n');
fprintf(f1,'%3.3f, %3.3f, 1.0\n',v12);
fclose(f1);

v2=[omega; v2'];
f1=fopen('ac2aNoThresholdV2.csv','w');
fprintf(f1,'C, v2, dummy\n');
fprintf(f1,'%3.3f, %3.3f, 1.0\n',v2);
fclose(f1);

Export other equilibrium calculations to LaTeX macros for use by TikZ when creating Figure 3.

f1=fopen('ac2aNoThresholdConstants.tex','w');

fprintf(f1,'\\def\\ymax{%3.2f}\n',max(v1(:,1)));
fprintf(f1,'\\def\\cunderbartwo{%3.2f}\n',underlineC);
fprintf(f1,'\\def\\coverbartwo{%3.2f}\n',overlineC);
fprintf(f1,'\\def\\phione{%3.2f}\n',phi(1));
fprintf(f1,'\\def\\phitwo{%3.2f}\n',phi(2));
fprintf(f1,'\\def\\chat{%3.2f}\n',min(omega));
fprintf(f1,'\\def\\ccheck{%3.2f}\n',max(omega));
fprintf(f1,'\\def\\Alow{%3.2f}\n',Alow);
fprintf(f1,'\\def\\Ahigh{%3.2f}\n',Ahigh);
fprintf(f1,'\\def\\Clow{%3.2f}\n',Clow);
fprintf(f1,'\\def\\Chigh{%3.2f}\n',Chigh);

fclose(f1);

Quit Matlab

We only wish to quit if we are running this from the makefile. To detect this,import the make level. If we are running this from within make, this will be nonempty. For extra security, we don't even bother with this step if we are not running within unix or mac.

if isunix || ismac

    makelevel=getenv('MAKELEVEL');

    if ~strcmp(makelevel,'')
        quit
    end

end