econpy.org

Python for Economists

Economic Merger Analysis in Python: Computing Pre- & Post-Merger HHIs


from __future__ import division
from math import pow

PreMerger = {'Firm R': [5,9,2,11],'Firm S': [4,2],    'Firm T': [12,9,3],
             'Firm U': [10,8],    'Firm V': [8,7,7],  'Firm W': [15,21,16,11],
             'Firm X': [3,13],    'Firm Y': [8,9,6,4],'Firm Z': [12,10,7,19]}

print "Suppose there are 9 firms that sell a homogeneous good in a " + \
"competitive market. Assume each firm has the same constant marginal cost."

print "\n        PRE-MERGER ANALYSIS:  \n       ========================"
FirmQ = [sum(i) for i in PreMerger.values()]
Q = sum(FirmQ)                                   # Market Quantity
PreMergerShares = [str(float(100*(i/Q)))[:5]+'%' for i in FirmQ]
PreC4prep = [float(i[:-1]) for i in PreMergerShares]
PreC4prep.sort()
PreMergerHHI = sum([pow(float(i[:-1]),2) for i in PreMergerShares])

print "       Number of Firms: %s" % len(PreMerger.keys())
print "        Pre-Merger HHI: %s" % str(float(PreMergerHHI))[:7]
print "                    C4: %s\n" % str(sum(PreC4prep[-4:]))[:5]
print "Assume the firms produce the good under CRS. Now, suppose Firm Y " + \
"wants to merge with Firm Z to form a single merged firm called Firm YZ. " + \
"As seen by the pre-merger HHI (%s), the " % str(float(PreMergerHHI))[:7] + \
"market is already mildly concentrated, so a merger is likely to " + \
"be challenged by regulators.\n\n"

PostMerger = {'Firm R': [5,9,2,11],'Firm S': [4,2],   'Firm T': [12,9,3],
              'Firm U': [10,8],    'Firm V': [8,7,7], 'Firm W': [15,21,16,11],
              'Firm X': [3,13],    'Firm YZ': [8,9,6,4,12,10,7,19]}

print "        POST-MERGER ANALYSIS:  \n       ========================"
FirmQ = [sum(i) for i in PostMerger.values()]
Q = sum(FirmQ)
PostMergerShares = [str(float(100*(i/Q)))[:5]+'%' for i in FirmQ]
PostC4prep = [float(i[:-1]) for i in PostMergerShares]
PostC4prep.sort()
PostMergerHHI = sum([pow(float(i[:-1]),2) for i in PostMergerShares])

print "       Number of Firms: %s" % len(PostMerger.keys())
print "       Post-Merger HHI: %s" % str(float(PostMergerHHI))[:7]
print "                    C4: %s\n" % str(sum(PostC4prep[-4:]))[:5]

if PostMergerHHI >= 1800:
        print "If Firm Y and Z were allowed to merge, the Post-Merger HHI " + \
        "would climb to %s, making the market " % str(float(PostMergerHHI))[:7] + \
        "highly concentrated according to current US Horizontal Merger " + \
        "Guidelines (e.g. Post-Merger HHI > 1800). Therefore, it's unlikely " + \
        "that regulators would allow Firm Y and Firm Z to merge."
%loadpy http://econpy.pythonanywhere.com/scripts/hhi.py