mergeron 2024.738963.0__tar.gz → 2025.739265.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mergeron might be problematic. Click here for more details.

Files changed (44) hide show
  1. mergeron-2025.739265.0/PKG-INFO +115 -0
  2. mergeron-2025.739265.0/README.rst +73 -0
  3. {mergeron-2024.738963.0 → mergeron-2025.739265.0}/pyproject.toml +45 -50
  4. {mergeron-2024.738963.0 → mergeron-2025.739265.0}/src/mergeron/__init__.py +26 -6
  5. mergeron-2025.739265.0/src/mergeron/core/__init__.py +8 -0
  6. mergeron-2024.738963.0/src/mergeron/core/damodaran_margin_data.py → mergeron-2025.739265.0/src/mergeron/core/empirical_margin_distribution.py +74 -58
  7. {mergeron-2024.738963.0 → mergeron-2025.739265.0}/src/mergeron/core/ftc_merger_investigations_data.py +142 -93
  8. mergeron-2025.739265.0/src/mergeron/core/guidelines_boundaries.py +461 -0
  9. mergeron-2024.738963.0/src/mergeron/core/guidelines_boundaries.py → mergeron-2025.739265.0/src/mergeron/core/guidelines_boundary_functions.py +866 -987
  10. mergeron-2024.738963.0/src/mergeron/core/guidelines_boundaries_specialized_functions.py → mergeron-2025.739265.0/src/mergeron/core/guidelines_boundary_functions_extra.py +76 -42
  11. {mergeron-2024.738963.0 → mergeron-2025.739265.0}/src/mergeron/core/pseudorandom_numbers.py +16 -22
  12. mergeron-2025.739265.0/src/mergeron/data/__init__.py +3 -0
  13. mergeron-2025.739265.0/src/mergeron/data/damodaran_margin_data.xls +0 -0
  14. mergeron-2025.739265.0/src/mergeron/data/damodaran_margin_data_dict.msgpack +0 -0
  15. mergeron-2025.739265.0/src/mergeron/demo/__init__.py +3 -0
  16. mergeron-2025.739265.0/src/mergeron/demo/visualize_empirical_margin_distribution.py +86 -0
  17. mergeron-2025.739265.0/src/mergeron/gen/__init__.py +518 -0
  18. mergeron-2025.739265.0/src/mergeron/gen/data_generation.py +529 -0
  19. mergeron-2025.739265.0/src/mergeron/gen/data_generation_functions.py +876 -0
  20. mergeron-2025.739265.0/src/mergeron/gen/enforcement_stats.py +355 -0
  21. mergeron-2025.739265.0/src/mergeron/gen/upp_tests.py +394 -0
  22. mergeron-2024.738963.0/PKG-INFO +0 -108
  23. mergeron-2024.738963.0/README.rst +0 -64
  24. mergeron-2024.738963.0/src/mergeron/License.txt +0 -16
  25. mergeron-2024.738963.0/src/mergeron/core/InCommon RSA Server CA cert chain.pem +0 -68
  26. mergeron-2024.738963.0/src/mergeron/core/__init__.py +0 -68
  27. mergeron-2024.738963.0/src/mergeron/core/excel_helper.py +0 -259
  28. mergeron-2024.738963.0/src/mergeron/core/proportions_tests.py +0 -520
  29. mergeron-2024.738963.0/src/mergeron/ext/__init__.py +0 -5
  30. mergeron-2024.738963.0/src/mergeron/ext/tol_colors.py +0 -851
  31. mergeron-2024.738963.0/src/mergeron/gen/__init__.py +0 -506
  32. mergeron-2024.738963.0/src/mergeron/gen/_data_generation_functions_nonpublic.py +0 -621
  33. mergeron-2024.738963.0/src/mergeron/gen/data_generation.py +0 -277
  34. mergeron-2024.738963.0/src/mergeron/gen/investigations_stats.py +0 -709
  35. mergeron-2024.738963.0/src/mergeron/gen/upp_tests.py +0 -494
  36. mergeron-2024.738963.0/src/mergeron/jinja_LaTex_templates/clrrate_cis_summary_table_template.tex.jinja2 +0 -121
  37. mergeron-2024.738963.0/src/mergeron/jinja_LaTex_templates/ftcinvdata_byhhianddelta_table_template.tex.jinja2 +0 -82
  38. mergeron-2024.738963.0/src/mergeron/jinja_LaTex_templates/ftcinvdata_summary_table_template.tex.jinja2 +0 -57
  39. mergeron-2024.738963.0/src/mergeron/jinja_LaTex_templates/ftcinvdata_summarypaired_table_template.tex.jinja2 +0 -104
  40. mergeron-2024.738963.0/src/mergeron/jinja_LaTex_templates/mergeron.cls +0 -161
  41. mergeron-2024.738963.0/src/mergeron/jinja_LaTex_templates/mergeron_table_collection_template.tex.jinja2 +0 -90
  42. mergeron-2024.738963.0/src/mergeron/jinja_LaTex_templates/setup_tikz_tables.tex.jinja2 +0 -84
  43. {mergeron-2024.738963.0/src/mergeron/core → mergeron-2025.739265.0/src/mergeron/data}/ftc_invdata.msgpack +0 -0
  44. {mergeron-2024.738963.0 → mergeron-2025.739265.0}/src/mergeron/py.typed +0 -0
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.3
2
+ Name: mergeron
3
+ Version: 2025.739265.0
4
+ Summary: Analyze merger enforcement policy using Python
5
+ License: MIT
6
+ Keywords: merger policy analysis,merger guidelines,merger screening,policy presumptions,concentration standards,upward pricing pressure,GUPPI
7
+ Author: Murthy Kambhampaty
8
+ Author-email: smk@capeconomics.com
9
+ Requires-Python: >=3.12,<4.0
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Requires-Dist: aenum (>=3.1.15,<4.0.0)
23
+ Requires-Dist: attrs (>=23.2)
24
+ Requires-Dist: bs4 (>=0.0.1)
25
+ Requires-Dist: certifi (>=2023.11.17)
26
+ Requires-Dist: google-re2 (>=1.1)
27
+ Requires-Dist: jinja2 (>=3.1)
28
+ Requires-Dist: joblib (>=1.3)
29
+ Requires-Dist: matplotlib (>=3.8)
30
+ Requires-Dist: mpmath (>=1.3)
31
+ Requires-Dist: msgpack (>=1.0)
32
+ Requires-Dist: msgpack-numpy (>=0.4)
33
+ Requires-Dist: scipy (>=1.12)
34
+ Requires-Dist: sympy (>=1.12)
35
+ Requires-Dist: tables (>=3.10.1)
36
+ Requires-Dist: types-beautifulsoup4 (>=4.11.2)
37
+ Requires-Dist: urllib3 (>=2.2.2,<3.0.0)
38
+ Requires-Dist: xlrd (>=2.0.1,<3.0.0)
39
+ Requires-Dist: xlsxwriter (>=3.1)
40
+ Description-Content-Type: text/x-rst
41
+
42
+ mergeron: Merger Policy Analysis using Python
43
+ =============================================
44
+
45
+ Visualize the sets of mergers conforming to concentration and diversion-ratio standards. Estimate intrinsic enforcement rates, and intrinsic clearance rates, under concentration, diversion ratio, GUPPI, CMCR, and IPR bounds using generated data with specified distributions of market shares, price-cost margins, firm counts, and prices, optionally imposing restrictions implied by statutory filing thresholds and/or Bertrand-Nash oligopoly with MNL demand. Download and analyze merger investigations data published by the U.S. Federal Trade Commission in various reports on extended merger investigations (Second Requests) during 1996 to 2011.
46
+
47
+ Here, enforcement rates derived with merger enforcement as being exogenous to firm conduct are defined as intrinsic enforcement rates, and similarly intrinsic clearance rates. Depending on the merger enforcement regime, or merger control regime, intrinsic enforcement rates may also not be the complement of intrinsic clearance rates, i.e, it is not necessarily true that the intrinsic clearance rate estimate for a given enforcement regime is 1 minus the intrinsic enforcement rate. In contrast, observed enforcement rates reflect the deterrent effects of merger enforcement on firm conduct as well as the effects of merger screening on the level of enforcement; and, by definition, the observed clearance rate is 1 minus the observed enforcement rate.
48
+
49
+ Introduction
50
+ ------------
51
+
52
+ Module :code:`.core.guidelines_boundaries` includes classes for specifying concentration bounds (:code:`.core.guidelines_boundaries.ConcentrationBoundary`) and diversion-ratio bounds (:code:`.core.guidelines_boundaries.DiversionRatioBoundary`), with automatic generation of boundary, as an array of share-pairs, and area. This module also includes a function for generating plots of concentration and diversion-ratio boundaries, and functions for mapping GUPPI standards to concentration (ΔHHI) standards, and vice-versa.
53
+
54
+ Module :code:`.gen.data_generation` includes the :code:`.gen.data_generation.MarketSample` which provides for a rich specification of shares and diversion ratios (:code:`.gen.data_generation.MarketSample.share_spec`), margins (:code:`.gen.data_generation.MarketSample.pcm_spec`, prices (:code:`.gen.data_generation.MarketSample.price_spec`), and HSR filing requirements (:code:`.gen.data_generation.MarketSample.hsr_filing_test_type`), and with methods for, (i) generating sample data (:code:`.gen.data_generation.MarketSample.generate_sample`), and (ii) computing the intrinsic enforcement rate and intrinsic clearance rate for the generated sample, given a method (:code:`.UPPAggrSelector`) of aggregating diversion ratio or GUPPI estimates for the firms in a merger (:code:`.gen.data_generation.MarketSample.estimate_enf_counts`). While the latter populate the properties, :code:`.gen.data_generation.MarketSample.data`
55
+ and :code:`.gen.data_generation.MarketSample.enf_counts`, respectively, the underlying methods for generating standalone :code:`MarketDataSample` and :code:`UPPTestCounts` objects are included in the class definition, with helper functions defined in the modules, :code:`.gen.data_generation_functions` and :code:`.gen.upp_tests`. Notably, market shares are generated for a sample of markets with firm-count distributed as specified in :code:`.gen.data_generation.MarketSample.share_spec.firm_count_weights`, with defaults as discussed below (also see, :code:`.gen.ShareSpec.firm_count_weights`.
56
+
57
+ By default, merging-firm shares are drawn with uniform distribution over the space :math:`s_1 + s_2 \leqslant 1` for an unspecified number of firms. Alternatively, shares may be drawn from the Dirichlet distribution (see property `dist_type` of :code:`.gen.data_generation.MarketSample.share_spec`, of type, :code:`.gen.SHRDistribution`), with specified shape parameters (property `dist_parms` of :code:`.gen.data_generation.MarketSample.share_spec`. When drawing shares from the Dirichlet distribution, the user specifies the `firm_count_weights` property of :code:`.gen.data_generation.MarketSample.share_spec`, as a vector of weights specifying the frequency distribution over sequential firm counts, e.g., :code:`[133, 184, 134, 52, 32, 10, 12, 4, 3]` to specify shares drawn from Dirichlet distributions with 2 to 10 pre-merger firms distributed as in data for FTC merger investigations during 1996--2003 (See, for example, Table 4.1 of `FTC, Horizontal Merger Investigations Data, Fiscal Years 1996--2003 (Revised: August 31, 2004) <https://www.ftc.gov/sites/default/files/documents/reports/horizontal-merger-investigation-data-fiscal-years-1996-2003/040831horizmergersdata96-03.pdf>`_). If the property `firm_count_weights` is not explicitly assigned a value when defining :code:`.gen.data_generation.MarketSample.share_spec`, the default values is used, which results in a sample of markets with 2 to 7 firms with relative frequency in inverse proportion to firm-count, with 2-firm markets being 6 times as likely to be drawn as 7-firm markets.
58
+
59
+ Recapture ratios can be specified as, "proportional", "inside-out", or "outside-in" (see :code:`.RECForm`). The "inside-out" specification (assigning :code:`.RECForm.INOUT` to the `recapture_form` property of :code:`.gen.data_generation.MarketSample.share_spec`) results in recapture ratios consistent with MNL demand, given merging-firms' in-market shares and a default recapture ratio. The "outside-in" specification (assigning :code:`.RECForm.INOUT` to the `recapture_form` property of :code:`.gen.data_generation.MarketSample.share_spec`) yields diversion ratios from purchase probabilities drawn at random for :math:`N+1` goods, with market shares and recapture ratios for the :math:`N` goods in the putative market (see, :code:`.gen.ShareSpec`) computed from the simulated choice probabilities. The "outside-in" specification requires specification of the distribution of markets over firm counts (the default being uniform distirbution over markets with 2 to 7 firms pre-merger), and Dirichlet-distributed shares, with optional parameters (the default being a "flat" Dirichlet distribution, i.e., one with all parameters being 1). The parameters of the Dirichlet distribution can, for example, be specified to increase (decrease) the probability of drawing mergers to monopoly relative to that probability associated with the Flat Dirichlet specification, by setting the first 2 specified parameters at higher (lower) values relative to the others. Lastly, the "proportional" form of recapture ratio (`recapture_form` = :code:`.RECForm.FIXED`) is often used in the literature, as an approximation to the "inside-out" calibration. See, for example, Coate (2011).
60
+
61
+ Price-cost-margins may be specified as having uniform distribution, Beta distribution (including a bounded Beta distribution with specified mean and variance), or a built-in empirical distribution (see, :code:`.gen.PCMSpec`). The in-built empirical margin distribution is based on resampling margin data published by Prof. Damodaran of NYU Stern School of Business (see Notes), using an estimated Gaussian KDE. The second merging firm's margin (per the property `firm2_pcm_constraint` of :code:`.gen.data_generation.MarketSample.pcm_spec`) may be specified as symmetric, i.i.d., or subject to equilibrium conditions for (profit-maximization in) Bertrand-Nash oligopoly with MNL demand (:code:`.gen.FM2Constraint`).
62
+
63
+ Prices may be specified as symmetric or asymmetric, and in the latter case, the direction of correlation between merging firm prices, if any, can also be specified (see, :code:`.gen.PriceSpec`). Prices may also be defined by imposing cost symmetry on firms in the sample, with fixed unit marginal costs normalized to 1 unit, such that prices equal :math:`1 / (1 - \pmb{m})`, where :math:`\pmb{m}` represents the array of margins for firms in the sample.
64
+
65
+ The market sample may be restricted to mergers meeting the HSR filing requirement under two alternative approaches: in the one, the smaller of the two merging firms meets the lower HSR size threshold ($10 million, as adjusted) and the larger of the two merging firms meets the size test if it's share is no less than 10 times the share of the smaller firm. In the other, the :math:`n`-th firm's size is maintained as $10 million, as adjusted (see, :code:`.gen.SSZConstant`), and a merger meets the HSR filing test if either, (a.) the smaller merging firm is no smaller than the n-th firm and the larger merging firm is at 10-times as large as the n-th firm, or (b.) the smaller merging firm's market share is in excess of 10%; in effect this version of the test maintains that if the smaller merging firm's market share exceeds 10%, the value of the transaction exceeds $200 million, as adjusted, and the size-of-person test is eliminated (see, FTC (2008, p. 12); the above are simplifications of the statutory HSR filing requirements). The second assumption avoids the unfortunate assumption in the first that, within the resulting sample, the larger merging firm be at least 10 times as large as the smaller merging firm, as a consequence of the full definition of the HSR filing requirement.
66
+
67
+ The full specification of a market sample is given in a :code:`.gen.data_generation.MarketSample` object, including the above parameters. Data are drawn by invoking :code:`.gen.data_generation.MarketSample.generate_sample` which adds a :code:`data` property of class, :code:`.gen.MarketDataSample`. Enforcement or clearance counts are computed by invoking :code:`.gen.data_generation.MarketSample.estimate_enf_counts`, which adds an :code:`enf_counts` property of class :code:`.gen.UPPTestsCounts`. For fast, parallel generation of enforcement or clearance counts over large market data samples that ordinarily would exceed available limits on machine memory, the user can invoke the method :code:`.gen.data_generation.MarketSample.estimate_enf_counts` on a :code:`.gen.data_generation.MarketSample` object without first invoking :code:`.gen.data_generation.MarketSample.generate_sample`. Note, however, that this strategy does not retain the market sample in memory in the interests of conserving memory and maintaining high performance (the user can specify that the market sample and enforcement statistics be stored to permanent storage; when saving to current PCIe NVMe storage, the performance penalty is slight, but can be considerable if saving to SATA storage).
68
+
69
+ Enforcement statistics based on FTC investigations data and test data are tabulated using methods provided in :code:`.gen.enforcement_stats`.
70
+
71
+ Programs demonstrating the use of this package are included in the sub-package, :code:`.demo`.
72
+
73
+ This package includes a class, :code:`.core.pseudorandom_numbers.MultithreadedRNG` for generating random numbers with selected continuous distribution over specified parameters, and with CPU multithreading on machines with multiple CPU cores, be they virtual, logical, or physical cores. This class is an adaptation from the documentation for the external :code:`numpy.random` subpackage, from the discussion on, "`Multithreaded generation <https://numpy.org/doc/stable/reference/random/multithreading.html>`_"; the version included here permits selection of the distribution with pre-tests to catch and inform on common errors. To access these directly:
74
+
75
+ .. code-block:: python
76
+
77
+ import mergeron.core.pseudorandom_numbers as prng
78
+
79
+ Documentation for this package is in the form of the API Reference. Documentation for individual functions and classes is accessible within a python shell. For example:
80
+
81
+ .. code-block:: python
82
+
83
+ import mergeron.core.data_generation as dgl
84
+
85
+ help(dgl.MarketSample)
86
+
87
+ .. rubric:: References
88
+
89
+ .. _coate2011:
90
+
91
+ Coate, M. B. (2011). Benchmarking the upward pricing pressure model with Federal Trade
92
+ Commission evidence. Journal of Competition Law & Economics, 7(4), 825--846. URL: https://doi.org/10.1093/joclec/nhr014.
93
+
94
+ .. _ftc_premerger_guide2:
95
+
96
+ FTC Premerger Notification Office. “To File or Not to File: When You Must File a Premerger Notification Report Form”. 2008 (September, revised). URL: https://www.ftc.gov/sites/default/files/attachments/premerger-introductory-guides/guide2.pdf
97
+
98
+
99
+ .. image:: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json
100
+ :alt: Poetry
101
+ :target: https://python-poetry.org/
102
+
103
+ .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
104
+ :alt: Ruff
105
+ :target: https://github.com/astral-sh/ruff/
106
+
107
+ .. image:: https://www.mypy-lang.org/static/mypy_badge.svg
108
+ :alt: Checked with mypy
109
+ :target: https://mypy-lang.org/
110
+
111
+ .. image:: https://img.shields.io/badge/License-MIT-yellow.svg
112
+ :alt: License: MIT
113
+ :target: https://opensource.org/licenses/MIT/
114
+
115
+
@@ -0,0 +1,73 @@
1
+ mergeron: Merger Policy Analysis using Python
2
+ =============================================
3
+
4
+ Visualize the sets of mergers conforming to concentration and diversion-ratio standards. Estimate intrinsic enforcement rates, and intrinsic clearance rates, under concentration, diversion ratio, GUPPI, CMCR, and IPR bounds using generated data with specified distributions of market shares, price-cost margins, firm counts, and prices, optionally imposing restrictions implied by statutory filing thresholds and/or Bertrand-Nash oligopoly with MNL demand. Download and analyze merger investigations data published by the U.S. Federal Trade Commission in various reports on extended merger investigations (Second Requests) during 1996 to 2011.
5
+
6
+ Here, enforcement rates derived with merger enforcement as being exogenous to firm conduct are defined as intrinsic enforcement rates, and similarly intrinsic clearance rates. Depending on the merger enforcement regime, or merger control regime, intrinsic enforcement rates may also not be the complement of intrinsic clearance rates, i.e, it is not necessarily true that the intrinsic clearance rate estimate for a given enforcement regime is 1 minus the intrinsic enforcement rate. In contrast, observed enforcement rates reflect the deterrent effects of merger enforcement on firm conduct as well as the effects of merger screening on the level of enforcement; and, by definition, the observed clearance rate is 1 minus the observed enforcement rate.
7
+
8
+ Introduction
9
+ ------------
10
+
11
+ Module :code:`.core.guidelines_boundaries` includes classes for specifying concentration bounds (:code:`.core.guidelines_boundaries.ConcentrationBoundary`) and diversion-ratio bounds (:code:`.core.guidelines_boundaries.DiversionRatioBoundary`), with automatic generation of boundary, as an array of share-pairs, and area. This module also includes a function for generating plots of concentration and diversion-ratio boundaries, and functions for mapping GUPPI standards to concentration (ΔHHI) standards, and vice-versa.
12
+
13
+ Module :code:`.gen.data_generation` includes the :code:`.gen.data_generation.MarketSample` which provides for a rich specification of shares and diversion ratios (:code:`.gen.data_generation.MarketSample.share_spec`), margins (:code:`.gen.data_generation.MarketSample.pcm_spec`, prices (:code:`.gen.data_generation.MarketSample.price_spec`), and HSR filing requirements (:code:`.gen.data_generation.MarketSample.hsr_filing_test_type`), and with methods for, (i) generating sample data (:code:`.gen.data_generation.MarketSample.generate_sample`), and (ii) computing the intrinsic enforcement rate and intrinsic clearance rate for the generated sample, given a method (:code:`.UPPAggrSelector`) of aggregating diversion ratio or GUPPI estimates for the firms in a merger (:code:`.gen.data_generation.MarketSample.estimate_enf_counts`). While the latter populate the properties, :code:`.gen.data_generation.MarketSample.data`
14
+ and :code:`.gen.data_generation.MarketSample.enf_counts`, respectively, the underlying methods for generating standalone :code:`MarketDataSample` and :code:`UPPTestCounts` objects are included in the class definition, with helper functions defined in the modules, :code:`.gen.data_generation_functions` and :code:`.gen.upp_tests`. Notably, market shares are generated for a sample of markets with firm-count distributed as specified in :code:`.gen.data_generation.MarketSample.share_spec.firm_count_weights`, with defaults as discussed below (also see, :code:`.gen.ShareSpec.firm_count_weights`.
15
+
16
+ By default, merging-firm shares are drawn with uniform distribution over the space :math:`s_1 + s_2 \leqslant 1` for an unspecified number of firms. Alternatively, shares may be drawn from the Dirichlet distribution (see property `dist_type` of :code:`.gen.data_generation.MarketSample.share_spec`, of type, :code:`.gen.SHRDistribution`), with specified shape parameters (property `dist_parms` of :code:`.gen.data_generation.MarketSample.share_spec`. When drawing shares from the Dirichlet distribution, the user specifies the `firm_count_weights` property of :code:`.gen.data_generation.MarketSample.share_spec`, as a vector of weights specifying the frequency distribution over sequential firm counts, e.g., :code:`[133, 184, 134, 52, 32, 10, 12, 4, 3]` to specify shares drawn from Dirichlet distributions with 2 to 10 pre-merger firms distributed as in data for FTC merger investigations during 1996--2003 (See, for example, Table 4.1 of `FTC, Horizontal Merger Investigations Data, Fiscal Years 1996--2003 (Revised: August 31, 2004) <https://www.ftc.gov/sites/default/files/documents/reports/horizontal-merger-investigation-data-fiscal-years-1996-2003/040831horizmergersdata96-03.pdf>`_). If the property `firm_count_weights` is not explicitly assigned a value when defining :code:`.gen.data_generation.MarketSample.share_spec`, the default values is used, which results in a sample of markets with 2 to 7 firms with relative frequency in inverse proportion to firm-count, with 2-firm markets being 6 times as likely to be drawn as 7-firm markets.
17
+
18
+ Recapture ratios can be specified as, "proportional", "inside-out", or "outside-in" (see :code:`.RECForm`). The "inside-out" specification (assigning :code:`.RECForm.INOUT` to the `recapture_form` property of :code:`.gen.data_generation.MarketSample.share_spec`) results in recapture ratios consistent with MNL demand, given merging-firms' in-market shares and a default recapture ratio. The "outside-in" specification (assigning :code:`.RECForm.INOUT` to the `recapture_form` property of :code:`.gen.data_generation.MarketSample.share_spec`) yields diversion ratios from purchase probabilities drawn at random for :math:`N+1` goods, with market shares and recapture ratios for the :math:`N` goods in the putative market (see, :code:`.gen.ShareSpec`) computed from the simulated choice probabilities. The "outside-in" specification requires specification of the distribution of markets over firm counts (the default being uniform distirbution over markets with 2 to 7 firms pre-merger), and Dirichlet-distributed shares, with optional parameters (the default being a "flat" Dirichlet distribution, i.e., one with all parameters being 1). The parameters of the Dirichlet distribution can, for example, be specified to increase (decrease) the probability of drawing mergers to monopoly relative to that probability associated with the Flat Dirichlet specification, by setting the first 2 specified parameters at higher (lower) values relative to the others. Lastly, the "proportional" form of recapture ratio (`recapture_form` = :code:`.RECForm.FIXED`) is often used in the literature, as an approximation to the "inside-out" calibration. See, for example, Coate (2011).
19
+
20
+ Price-cost-margins may be specified as having uniform distribution, Beta distribution (including a bounded Beta distribution with specified mean and variance), or a built-in empirical distribution (see, :code:`.gen.PCMSpec`). The in-built empirical margin distribution is based on resampling margin data published by Prof. Damodaran of NYU Stern School of Business (see Notes), using an estimated Gaussian KDE. The second merging firm's margin (per the property `firm2_pcm_constraint` of :code:`.gen.data_generation.MarketSample.pcm_spec`) may be specified as symmetric, i.i.d., or subject to equilibrium conditions for (profit-maximization in) Bertrand-Nash oligopoly with MNL demand (:code:`.gen.FM2Constraint`).
21
+
22
+ Prices may be specified as symmetric or asymmetric, and in the latter case, the direction of correlation between merging firm prices, if any, can also be specified (see, :code:`.gen.PriceSpec`). Prices may also be defined by imposing cost symmetry on firms in the sample, with fixed unit marginal costs normalized to 1 unit, such that prices equal :math:`1 / (1 - \pmb{m})`, where :math:`\pmb{m}` represents the array of margins for firms in the sample.
23
+
24
+ The market sample may be restricted to mergers meeting the HSR filing requirement under two alternative approaches: in the one, the smaller of the two merging firms meets the lower HSR size threshold ($10 million, as adjusted) and the larger of the two merging firms meets the size test if it's share is no less than 10 times the share of the smaller firm. In the other, the :math:`n`-th firm's size is maintained as $10 million, as adjusted (see, :code:`.gen.SSZConstant`), and a merger meets the HSR filing test if either, (a.) the smaller merging firm is no smaller than the n-th firm and the larger merging firm is at 10-times as large as the n-th firm, or (b.) the smaller merging firm's market share is in excess of 10%; in effect this version of the test maintains that if the smaller merging firm's market share exceeds 10%, the value of the transaction exceeds $200 million, as adjusted, and the size-of-person test is eliminated (see, FTC (2008, p. 12); the above are simplifications of the statutory HSR filing requirements). The second assumption avoids the unfortunate assumption in the first that, within the resulting sample, the larger merging firm be at least 10 times as large as the smaller merging firm, as a consequence of the full definition of the HSR filing requirement.
25
+
26
+ The full specification of a market sample is given in a :code:`.gen.data_generation.MarketSample` object, including the above parameters. Data are drawn by invoking :code:`.gen.data_generation.MarketSample.generate_sample` which adds a :code:`data` property of class, :code:`.gen.MarketDataSample`. Enforcement or clearance counts are computed by invoking :code:`.gen.data_generation.MarketSample.estimate_enf_counts`, which adds an :code:`enf_counts` property of class :code:`.gen.UPPTestsCounts`. For fast, parallel generation of enforcement or clearance counts over large market data samples that ordinarily would exceed available limits on machine memory, the user can invoke the method :code:`.gen.data_generation.MarketSample.estimate_enf_counts` on a :code:`.gen.data_generation.MarketSample` object without first invoking :code:`.gen.data_generation.MarketSample.generate_sample`. Note, however, that this strategy does not retain the market sample in memory in the interests of conserving memory and maintaining high performance (the user can specify that the market sample and enforcement statistics be stored to permanent storage; when saving to current PCIe NVMe storage, the performance penalty is slight, but can be considerable if saving to SATA storage).
27
+
28
+ Enforcement statistics based on FTC investigations data and test data are tabulated using methods provided in :code:`.gen.enforcement_stats`.
29
+
30
+ Programs demonstrating the use of this package are included in the sub-package, :code:`.demo`.
31
+
32
+ This package includes a class, :code:`.core.pseudorandom_numbers.MultithreadedRNG` for generating random numbers with selected continuous distribution over specified parameters, and with CPU multithreading on machines with multiple CPU cores, be they virtual, logical, or physical cores. This class is an adaptation from the documentation for the external :code:`numpy.random` subpackage, from the discussion on, "`Multithreaded generation <https://numpy.org/doc/stable/reference/random/multithreading.html>`_"; the version included here permits selection of the distribution with pre-tests to catch and inform on common errors. To access these directly:
33
+
34
+ .. code-block:: python
35
+
36
+ import mergeron.core.pseudorandom_numbers as prng
37
+
38
+ Documentation for this package is in the form of the API Reference. Documentation for individual functions and classes is accessible within a python shell. For example:
39
+
40
+ .. code-block:: python
41
+
42
+ import mergeron.core.data_generation as dgl
43
+
44
+ help(dgl.MarketSample)
45
+
46
+ .. rubric:: References
47
+
48
+ .. _coate2011:
49
+
50
+ Coate, M. B. (2011). Benchmarking the upward pricing pressure model with Federal Trade
51
+ Commission evidence. Journal of Competition Law & Economics, 7(4), 825--846. URL: https://doi.org/10.1093/joclec/nhr014.
52
+
53
+ .. _ftc_premerger_guide2:
54
+
55
+ FTC Premerger Notification Office. “To File or Not to File: When You Must File a Premerger Notification Report Form”. 2008 (September, revised). URL: https://www.ftc.gov/sites/default/files/attachments/premerger-introductory-guides/guide2.pdf
56
+
57
+
58
+ .. image:: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json
59
+ :alt: Poetry
60
+ :target: https://python-poetry.org/
61
+
62
+ .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
63
+ :alt: Ruff
64
+ :target: https://github.com/astral-sh/ruff/
65
+
66
+ .. image:: https://www.mypy-lang.org/static/mypy_badge.svg
67
+ :alt: Checked with mypy
68
+ :target: https://mypy-lang.org/
69
+
70
+ .. image:: https://img.shields.io/badge/License-MIT-yellow.svg
71
+ :alt: License: MIT
72
+ :target: https://opensource.org/licenses/MIT/
73
+
@@ -1,8 +1,9 @@
1
1
  [tool.poetry]
2
2
  name = "mergeron"
3
- # See ./get_version_str.py
4
- version = "2024.738963.0"
5
- description = "Analysis of standards defined in Horizontal Merger Guidelines"
3
+ authors = ["Murthy Kambhampaty <smk@capeconomics.com>"]
4
+ description = "Analyze merger enforcement policy using Python"
5
+ readme = "README.rst"
6
+ license = "MIT"
6
7
  keywords = [
7
8
  "merger policy analysis",
8
9
  "merger guidelines",
@@ -12,9 +13,7 @@ keywords = [
12
13
  "upward pricing pressure",
13
14
  "GUPPI",
14
15
  ]
15
- authors = ["Murthy Kambhampaty <smk@capeconomics.com>"]
16
- license = "MIT"
17
- readme = "README.rst"
16
+ version = "2025.739265.0"
18
17
 
19
18
  # Classifiers list: https://pypi.org/classifiers/
20
19
  classifiers = [
@@ -31,49 +30,51 @@ classifiers = [
31
30
  "Programming Language :: Python :: Implementation :: CPython",
32
31
  ]
33
32
 
33
+ [build-system]
34
+ requires = ["poetry-core"]
35
+ build-backend = "poetry.core.masonry.api"
36
+
37
+
34
38
  [tool.poetry.dependencies]
35
39
  # You may need to apply the fixes in, https://github.com/python-poetry/poetry/issues/3365
36
40
  # if poetry dependency resolution appears to hang (read the page at link to the end)
41
+ aenum = "^3.1.15"
37
42
  attrs = ">=23.2"
38
43
  bs4 = ">=0.0.1"
39
44
  google-re2 = ">=1.1"
40
45
  jinja2 = ">=3.1"
41
46
  joblib = ">=1.3"
42
- lxml = ">=5.0"
43
47
  matplotlib = ">=3.8"
44
48
  mpmath = ">=1.3"
45
49
  msgpack = ">=1.0"
46
50
  msgpack-numpy = ">=0.4"
47
- numpy = ">=1.26"
48
- openpyxl = ">=3.1.2"
49
51
  python = "^3.12"
50
- requests = ">=2.31"
51
52
  scipy = ">=1.12"
52
53
  sympy = ">=1.12"
53
- tables = ">=3.8"
54
- xlrd = ">=2.0"
54
+ tables = ">=3.10.1"
55
55
  xlsxwriter = ">=3.1"
56
56
  certifi = ">=2023.11.17"
57
- requests-toolbelt = ">=1.0.0"
58
- importlib-metadata = ">=7.0.1"
57
+ types-beautifulsoup4 = ">=4.11.2"
58
+ xlrd = "^2.0.1" # Needed to read margin data
59
+ urllib3 = "^2.2.2"
59
60
 
60
61
 
61
62
  [tool.poetry.group.dev.dependencies]
62
- semver = ">=3.0"
63
- pytest = ">=8.0"
63
+ icecream = ">=2.1.0"
64
64
  mypy = ">=1.8"
65
- ruff = ">=0.2"
66
- sphinx = ">=7.2"
65
+ openpyxl = ">=3.1.2"
66
+ pendulum = ">=3.0.0"
67
+ ruff = ">=0.5"
68
+ poetry-plugin-export = "^1.8.0"
69
+ pytest = ">=8.0"
70
+ Sphinx = ">=7.2, <8.0"
71
+ semver = ">=3.0"
67
72
  sphinx-autodoc-typehints = ">=2.0.0"
68
73
  sphinx-autoapi = ">=3.0"
69
74
  sphinx-immaterial = ">=0.11"
70
75
  pipdeptree = ">=2.15.1"
71
- uv = ">=0.1.11"
72
-
73
- [build-system]
74
- requires = ["poetry-core"]
75
- build-backend = "poetry.core.masonry.api"
76
-
76
+ types-openpyxl = ">=3.0.0"
77
+ pyright = "^1.1.380"
77
78
 
78
79
  [tool.ruff]
79
80
 
@@ -118,19 +119,20 @@ select = [
118
119
  "I", # isort
119
120
  "W", # pycodestyle
120
121
  # plugins:
121
- "B", # flake8-bugbear
122
- "C4", # flake8-comprehensions
123
- "ICN", # flake8-import-conventions
124
- "NPY", # NumPy-specific rules
125
- "PIE", # flake8-pie
126
- "PL", # pylint
127
- "PTH", # flake8-use-pathlib
128
- "S", # flake8-bandit
129
- "SIM", # flake8-simplify
130
- "TID", # flake8-tidy-imports
131
- "TCH", # flake8-type-checking
132
- "UP", # pyupgrade
133
- "RUF", # ruff-specific
122
+ "B", # flake8-bugbear
123
+ "C4", # flake8-comprehensions
124
+ "FURB", # refurb
125
+ "ICN", # flake8-import-conventions
126
+ "NPY", # NumPy-specific rules
127
+ "PIE", # flake8-pie
128
+ "PL", # pylint
129
+ "PTH", # flake8-use-pathlib
130
+ "S", # flake8-bandit
131
+ "SIM", # flake8-simplify
132
+ "TID", # flake8-tidy-imports
133
+ "TC", # flake8-type-checking
134
+ "UP", # pyupgrade
135
+ "RUF", # ruff-specific
134
136
  ]
135
137
 
136
138
  ignore = [
@@ -144,20 +146,11 @@ ignore = [
144
146
  # flake8-bugbear opinionated (disabled by default in flake8)
145
147
  'B904',
146
148
  'B905',
147
- # flake8-executable
148
- "EXE002", # file executable but no shebang present
149
- # pygrep-hooks
150
- "PGH003",
151
- # flake8-pie
152
- "PIE790", # unnecessary 'pass' statement
153
- # pylint
154
149
  "PLR2004", # avoid magic values
155
- # flake8-simplify
156
- "SIM102", # nested 'if' statements
157
150
  # flake8-type-checking
158
- "TCH001", # move application import into a type-checking block
159
- "TCH002", # move third-party import into a type-checking block
160
- "TCH003", # move third-party import into a type-checking block
151
+ "TC001", # move application import into a type-checking block
152
+ "TC002", # move third-party import into a type-checking block
153
+ "TC003", # move third-party import into a type-checking block
161
154
  # Use typing.TypeAlias for now:
162
155
  # mypy yet to implements PEP 695 type aliases;
163
156
  # sphinx (as setup here) gives different results with TypeAlias and typing statement
@@ -176,6 +169,7 @@ preview = true
176
169
  python_version = "3.12"
177
170
  ignore_missing_imports = false
178
171
  strict = true
172
+ enable_incomplete_feature = ["PreciseTupleTypes"]
179
173
 
180
174
  show_column_numbers = true
181
175
  show_error_codes = true
@@ -189,6 +183,7 @@ allow_redefinition = true
189
183
  plugins = "numpy.typing.mypy_plugin"
190
184
 
191
185
  [tool.pytest.ini_options]
186
+ log_auto_indent = 4
192
187
  minversion = "8.0"
193
188
  testpaths = ["tests"]
194
189
  addopts = ["--import-mode=importlib"]
@@ -198,7 +193,7 @@ filterwarnings = [
198
193
  "ignore::DeprecationWarning:jinja2.lexer",
199
194
  "ignore::DeprecationWarning:joblib._utils",
200
195
  "ignore::DeprecationWarning:openpyxl.packaging.core",
201
- "ignore::RuntimeWarning:mergeron.gen.investigations_stats",
202
196
  "ignore::RuntimeWarning:mergeron.core.proportions_tests",
197
+ "ignore::RuntimeWarning:mergeron.gen.enforcement_stats",
203
198
  ]
204
199
  tmp_path_retention_policy = "failed"
@@ -1,12 +1,17 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import enum
4
- from importlib.metadata import version
5
4
  from pathlib import Path
5
+ from typing import Literal
6
+
7
+ import numpy as np
8
+ from numpy.typing import NDArray
6
9
 
7
10
  _PKG_NAME: str = Path(__file__).parent.stem
8
11
 
9
- __version__ = version(_PKG_NAME)
12
+ VERSION = "2025.739265.0"
13
+
14
+ __version__ = VERSION
10
15
 
11
16
  DATA_DIR: Path = Path.home() / _PKG_NAME
12
17
  """
@@ -14,14 +19,26 @@ Defines a subdirectory named for this package in the user's home path.
14
19
 
15
20
  If the subdirectory doesn't exist, it is created on package invocation.
16
21
  """
17
-
18
22
  if not DATA_DIR.is_dir():
19
23
  DATA_DIR.mkdir(parents=False)
20
24
 
25
+ np.set_printoptions(precision=24, floatmode="fixed")
26
+
27
+ type HMGPubYear = Literal[1982, 1984, 1992, 2010, 2023]
28
+
29
+ type ArrayBoolean = NDArray[np.bool_]
30
+ type ArrayFloat = NDArray[np.float16 | np.float32 | np.float64 | np.float128]
31
+ type ArrayINT = NDArray[np.intp]
32
+
33
+ type ArrayDouble = NDArray[np.float64]
34
+ type ArrayBIGINT = NDArray[np.int64]
35
+
36
+ DEFAULT_REC_RATIO = 0.85
37
+
21
38
 
22
39
  @enum.unique
23
- class RECConstants(enum.StrEnum):
24
- """Recapture rate - derivation methods."""
40
+ class RECForm(enum.StrEnum):
41
+ """For derivation of recapture ratio from market shares."""
25
42
 
26
43
  INOUT = "inside-out"
27
44
  OUTIN = "outside-in"
@@ -31,15 +48,18 @@ class RECConstants(enum.StrEnum):
31
48
  @enum.unique
32
49
  class UPPAggrSelector(enum.StrEnum):
33
50
  """
34
- Aggregator selection for GUPPI and diversion ratio
51
+ Aggregator for GUPPI and diversion ratio estimates.
35
52
 
36
53
  """
37
54
 
38
55
  AVG = "average"
39
56
  CPA = "cross-product-share weighted average"
40
57
  CPD = "cross-product-share weighted distance"
58
+ CPG = "cross-product-share weighted geometric mean"
41
59
  DIS = "symmetrically-weighted distance"
60
+ GMN = "geometric mean"
42
61
  MAX = "max"
43
62
  MIN = "min"
44
63
  OSA = "own-share weighted average"
45
64
  OSD = "own-share weighted distance"
65
+ OSG = "own-share weighted geometric mean"
@@ -0,0 +1,8 @@
1
+ from mpmath import mp # type: ignore
2
+
3
+ from .. import VERSION # noqa: TID252
4
+
5
+ __version__ = VERSION
6
+
7
+ type MPFloat = mp.mpf # pyright: ignore
8
+ type MPMatrix = mp.matrix # pyright: ignore