experimentI.m

Calculates the equilibrium entry and exit thresholds presented in Table I of Abbring and Campbell's ''Last-In First-Out Oligopoly Dynamics.''

Contents

Set grid of innovation variances examined.

sigmaG=[0 0.05 0.1 0.15];

Set remaining parameters.

This section creates the structures with all parameters required for the model's solution. Some of these are replaced later when cycling through the grid points.

% Parameters for approximating the innovation distribution
approximateARG.F=@(x) (1+erf(x/sqrt(2)))./2;
approximateARG.Frange=4.0;
approximateARG.k=51;

% Parameters for approximating the Markov chain.
markovARG.approximateARG=approximateARG;
markovARG.rho=1.0;
markovARG.sigma=0.30;       %Placeholder value
markovARG.omegaCenter=0.0;
markovARG.omegaStep=0.005;
markovARG.omegaWidth=3;

% Parameters describing profits and discounting.
k=4;
piF = @(x) k*ones(size(x));
kappa=1.75;
beta=1.05^(-1);             %5 percent annual interest rate.
phi = @(N) 0.25*beta/(1-beta);

Baseline specification

% Mark cpu time for efficiency calculations.
tstart=cputime;

% Cycle through the parameter values and calculate the statistics of interest.
nPoints=length(sigmaG);
entryThresholds=NaN(nPoints,1);    % Vectors for storing thresholds from the experiments.
exitThresholds=NaN(nPoints,1);
exitRate=NaN(nPoints,1);           % Vector for storing each experiment's ergodic exit rate.

for iter=1:nPoints;

    markovARG.sigma=sigmaG(iter);

    %Calculate equilibrium continuation values.
     [nPrime,nPrimeIndex,vFuncs,minN,maxN,Pi,omega,nCstates] = bellman(piF,kappa,beta,phi,markovARG);

    %Calculate entry and exit rules' threshold representations.
    [overlineC,underlineC] = thresholds(maxN,vFuncs,phi,omega);

    entryThresholds(iter,1:maxN)=overlineC';
    exitThresholds(iter,1:maxN)=underlineC';

    %Pad storage results with NaNs if required (assumes that maxN decreases as sigma increases.
    if maxN<size(entryThresholds,2)
        entryThresholds(iter,maxN+1:end)=NaN;
        exitThresholds(iter,maxN+1:end)=NaN;
    end

    %Calculate average exit rate.
    [ PiCN,v ] = ergodic(Pi,nPrime,nPrimeIndex,minN,maxN,nCstates,omega);

    nVec=kron((minN:1:maxN)',ones(nCstates,1));
    nprimeVec=nPrime(:);
    dN=nprimeVec-nVec;
    Eexit=v(dN<0)'*(dN(dN<0)./nVec(dN<0));
    Eexit=Eexit/sum(v(nVec>0));
    exitRate(iter)=100*abs(Eexit);

    clear Pi %This triggers the recalculation of the approximating Markov chain on the next trip through this loop.

end

Write the baseline specification's panel for Table I.

doublerule='Yes';       %Switch to add the double rule at the panel's top.
descstr='$\pi(N)=4$';   %String to describe the results in the panel's first row.
latextableI;

%Write the two panels to a LaTeX file
f1=fopen('ac2aExperimentIa.tex','w');
for i=1:1:size(tablestra,1)
    fprintf(f1,'%s \n',tablestra(i,:));
end
fprintf(f1,'\n \\medskip \n \n');

for i=1:1:size(tablestrb,1)
    fprintf(f1,'%s \n',tablestrb(i,:));
end

fclose(f1);

Write table elements referenced in the text to LaTeX macros

This automation creates an audit trail for these numbers.

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

% \overline{C}_5 for \sigma=0.20 and \sigma=0.30
fprintf(f1,'\\def\\cFiveSigmaTwo{$%3.2f$}\n',entryThresholds(3,5));
fprintf(f1,'\\def\\cFiveSigmaThree{$%3.2f$}\n',entryThresholds(4,5));

% \overline{C}_6 for \sigma=0.1 and \sigma=0.2
fprintf(f1,'\\def\\cSixSigmaOne{$%3.2f$}\n',entryThresholds(2,6));
fprintf(f1,'\\def\\cSixSigmaTwo{$%3.2f$}\n',entryThresholds(3,6));

% \overline{C}_7 for \sigma=0 and \sigma=0.1
fprintf(f1,'\\def\\cSevenSigmaZero{$%3.2f$}\n',entryThresholds(1,7));
fprintf(f1,'\\def\\cSevenSigmaOne{$%3.2f$}\n',entryThresholds(2,7));

% The first static exit threshold.
fprintf(f1,'\\def\\cOneSigmaZero{$%3.2f$}\n',exitThresholds(1,1));

% Exit rates
fprintf(f1,'\\def\\exitRateOne{$%2.1f$}\n',exitRate(2));
fprintf(f1,'\\def\\exitRateTwo{$%2.1f$}\n',exitRate(3));
fprintf(f1,'\\def\\exitRateThree{$%2.1f$}\n',exitRate(4));

fclose(f1);

Specification with exogenously limited entry

This computation proceeds analogously to that for the baseline specification.

piF = @(x) k*ones(size(x)).*(x<=k);

maxN1=size(exitThresholds,2); %Number of possible entrants before limiting entry.

entryThresholds=NaN(nPoints,1);
exitThresholds=NaN(nPoints,1);

for iter=1:nPoints;

    markovARG.sigma=sigmaG(iter);

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

    entryThresholds(iter,1:maxN)=overlineC';
    exitThresholds(iter,1:maxN)=underlineC';

    %Pad storage results with NaNs if required (assumes that maxN decreases as sigma increases.
    if maxN<size(entryThresholds,2)
        entryThresholds(iter,maxN+1:end)=NaN;
        exitThresholds(iter,maxN+1:end)=NaN;
    end

    clear Pi

end

% Add columns of NaN's to entry and exit thresholds so that the tables from this experiment have the same format as those from the previous experiment.
if size(entryThresholds,2)<maxN1;
    entryThresholds=[entryThresholds NaN(nPoints,maxN1-size(entryThresholds,2))];
    exitThresholds = [exitThresholds NaN(nPoints,maxN1-size(exitThresholds,2))];
end

Write the limited entry specification's panel for Table I.

%Create the tables of interest
doublerule='No';
descstr='$\pi(N)=4\times I\left\{N\leq 4\right\}$';
latextableI;

%Write the two panels to a LaTeX file
f1=fopen('ac2aExperimentIb.tex','w');
for i=1:1:size(tablestra,1)
    fprintf(f1,'%s \n',tablestra(i,:));
end
fprintf(f1,'\n \\medskip \n \n');

for i=1:1:size(tablestrb,1)
    fprintf(f1,'%s \n',tablestrb(i,:));
end

fclose(f1);

Display computation time.

disp(['Experiment took ' num2str(cputime-tstart,'%6.2f') ' seconds']);
Experiment took 112.81 seconds

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