mergeron 2024.739127.0__py3-none-any.whl → 2024.739127.1__py3-none-any.whl

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.

mergeron/__init__.py CHANGED
@@ -2,14 +2,13 @@ from __future__ import annotations
2
2
 
3
3
  import enum
4
4
  from pathlib import Path
5
- from typing import TypeAlias
6
5
 
7
6
  import numpy as np
8
7
  from numpy.typing import NDArray
9
8
 
10
9
  _PKG_NAME: str = Path(__file__).parent.stem
11
10
 
12
- VERSION = "2024.739127.0"
11
+ VERSION = "2024.739127.1"
13
12
 
14
13
  __version__ = VERSION
15
14
 
@@ -25,21 +24,21 @@ if not DATA_DIR.is_dir():
25
24
  np.set_printoptions(precision=18)
26
25
 
27
26
 
28
- ArrayINT = NDArray[np.intp]
29
- ArrayFloat = NDArray[np.half | np.single | np.double]
27
+ type ArrayINT = NDArray[np.intp]
28
+ type ArrayFloat = NDArray[np.half | np.single | np.double]
30
29
 
31
30
 
32
- ArrayBoolean: TypeAlias = NDArray[np.bool_]
31
+ type ArrayBoolean = NDArray[np.bool_]
33
32
 
34
- ArrayDouble: TypeAlias = NDArray[np.double]
35
- ArrayBIGINT: TypeAlias = NDArray[np.int64]
33
+ type ArrayDouble = NDArray[np.double]
34
+ type ArrayBIGINT = NDArray[np.int64]
36
35
 
37
36
  DEFAULT_REC_RATE = 0.85
38
37
 
39
38
 
40
39
  @enum.unique
41
40
  class RECForm(enum.StrEnum):
42
- """Recapture rate - derivation methods."""
41
+ """For derivation of recapture rate from market shares."""
43
42
 
44
43
  INOUT = "inside-out"
45
44
  OUTIN = "outside-in"
@@ -49,7 +48,7 @@ class RECForm(enum.StrEnum):
49
48
  @enum.unique
50
49
  class UPPAggrSelector(enum.StrEnum):
51
50
  """
52
- Aggregator selection for GUPPI and diversion ratio
51
+ Aggregator for GUPPI and diversion ratio estimates.
53
52
 
54
53
  """
55
54
 
@@ -14,7 +14,7 @@ from importlib import resources
14
14
  from operator import itemgetter
15
15
  from pathlib import Path
16
16
  from types import MappingProxyType
17
- from typing import Any, NamedTuple, TypeAlias
17
+ from typing import Any, NamedTuple
18
18
 
19
19
  import msgpack # type: ignore
20
20
  import msgpack_numpy as m # type: ignore
@@ -95,7 +95,7 @@ class INVTableData(NamedTuple):
95
95
  data_array: ArrayBIGINT
96
96
 
97
97
 
98
- INVData: TypeAlias = Mapping[str, Mapping[str, Mapping[str, INVTableData]]]
98
+ type INVData = Mapping[str, Mapping[str, Mapping[str, INVTableData]]]
99
99
 
100
100
 
101
101
  def construct_data(
@@ -7,7 +7,7 @@ with a canvas on which to draw boundaries for Guidelines standards.
7
7
  from __future__ import annotations
8
8
 
9
9
  from dataclasses import dataclass
10
- from typing import Literal, TypeAlias
10
+ from typing import Literal
11
11
 
12
12
  import numpy as np
13
13
  from attrs import Attribute, field, frozen, validators
@@ -28,7 +28,7 @@ __version__ = VERSION
28
28
  mp.prec = 80
29
29
  mp.trap_complex = True
30
30
 
31
- HMGPubYear: TypeAlias = Literal[1992, 2004, 2010, 2023]
31
+ type HMGPubYear = Literal[1992, 2004, 2010, 2023]
32
32
 
33
33
 
34
34
  @dataclass(frozen=True)
@@ -48,10 +48,9 @@ with warnings.catch_warnings():
48
48
  mgn_kde = stats.gaussian_kde(mgn_data_obs, weights=mgn_data_wts, bw_method="silverman")
49
49
  mgn_kde.set_bandwidth(bw_method=mgn_kde.factor / 3.0)
50
50
 
51
- mgn_xvec = np.linspace(0, BIN_COUNT, 10**5) / BIN_COUNT
52
51
  mgn_ax.plot(
53
- mgn_xvec,
54
- mgn_kde(mgn_xvec),
52
+ (_xv := np.linspace(0, BIN_COUNT, 10**5) / BIN_COUNT),
53
+ mgn_kde(_xv),
55
54
  color="#004488",
56
55
  rasterized=True,
57
56
  label="Estimated Density",
mergeron/gen/upp_tests.py CHANGED
@@ -7,11 +7,12 @@ from generated market data.
7
7
  from collections.abc import Sequence
8
8
  from contextlib import suppress
9
9
  from pathlib import Path
10
- from typing import Literal, TypeAlias, TypedDict
10
+ from typing import Any, Literal, TypedDict
11
11
 
12
12
  import numpy as np
13
13
  import tables as ptb # type: ignore
14
14
  from numpy.random import SeedSequence
15
+ from numpy.typing import NDArray
15
16
 
16
17
  from .. import ( # noqa
17
18
  VERSION,
@@ -40,7 +41,7 @@ __version__ = VERSION
40
41
  ptb.parameters.MAX_NUMEXPR_THREADS = 8
41
42
  ptb.parameters.MAX_BLOSC_THREADS = 4
42
43
 
43
- SaveData: TypeAlias = Literal[False] | tuple[Literal[True], ptb.File, ptb.Group]
44
+ type SaveData = Literal[False] | tuple[Literal[True], ptb.File, ptb.Group]
44
45
 
45
46
 
46
47
  class INVRESCntsArgs(TypedDict, total=False):
@@ -213,7 +214,8 @@ def compute_upp_test_arrays(
213
214
 
214
215
  """
215
216
  _g_bar, _divr_bar, _cmcr_bar, _ipr_bar = (
216
- getattr(_upp_test_parms, _f) for _f in ("guppi", "divr", "cmcr", "ipr"))
217
+ getattr(_upp_test_parms, _f) for _f in ("guppi", "divr", "cmcr", "ipr")
218
+ )
217
219
 
218
220
  _guppi_array, _ipr_array, _cmcr_array = (
219
221
  np.empty_like(_market_data.price_array) for _ in range(3)
@@ -366,7 +368,7 @@ def save_data_to_hdf5(
366
368
 
367
369
 
368
370
  def save_array_to_hdf5(
369
- _array_obj: ArrayFloat | ArrayINT | ArrayDouble | ArrayBIGINT | ArrayBoolean,
371
+ _array_obj: NDArray[Any],
370
372
  _array_name: str,
371
373
  _h5_group: ptb.Group,
372
374
  _h5_file: ptb.File,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mergeron
3
- Version: 2024.739127.0
3
+ Version: 2024.739127.1
4
4
  Summary: Merger Policy Analysis using Python
5
5
  License: MIT
6
6
  Keywords: merger policy analysis,merger guidelines,merger screening,policy presumptions,concentration standards,upward pricing pressure,GUPPI
@@ -41,16 +41,16 @@ Description-Content-Type: text/x-rst
41
41
  mergeron: Merger Policy Analysis using Python
42
42
  =============================================
43
43
 
44
- Analyze the sets of mergers conforming to concentration and diversion ratio bounds. Analyze 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.
44
+ 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.
45
45
 
46
46
  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.
47
47
 
48
48
  Introduction
49
49
  ------------
50
50
 
51
- 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.
51
+ 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.
52
52
 
53
- 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) estimating enforcement or clearance rates under specified enforcement regimes given a method 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`
53
+ 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`
54
54
  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`.
55
55
 
56
56
  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.
@@ -65,11 +65,11 @@ The market sample may be restricted to mergers meeting the HSR filing requiremen
65
65
 
66
66
  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).
67
67
 
68
- Enforcement statistics based on FTC investigations data and test data are printed to screen or rendered to LaTex files (for processing into publication-quality tables) using methods provided in :code:`.gen.enforcement_stats`.
68
+ Enforcement statistics based on FTC investigations data and test data are tabulated using methods provided in :code:`.gen.enforcement_stats`.
69
69
 
70
70
  Programs demonstrating the use of this package are included in the sub-package, :code:`.demo`.
71
71
 
72
- 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 virtual, logical, or physical CPU cores. This class is an adaptation from the documentation of the :code:`numpy` package, from the discussion on `multithreaded random-number 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:
72
+ 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:
73
73
 
74
74
  .. code-block:: python
75
75
 
@@ -1,9 +1,9 @@
1
1
  mergeron/License.txt,sha256=7iX-y0EyjkbVJKJLS4ZKzuuE1wd0lryfsD_IytLG8lQ,1246
2
- mergeron/__init__.py,sha256=bTcTGdrdd0aHh_uD3Pl84q1uw-13oAwbGOXHqpK6vI8,1479
2
+ mergeron/__init__.py,sha256=SJjvuKqKcQsybbuFoLgA4PrvV8gB6TJFoQL7qbd2Jr4,1459
3
3
  mergeron/core/__init__.py,sha256=KtjBlZOl7jwBCAUhrTJB9PdrN39YLYytNiSUSM_gRmA,62
4
4
  mergeron/core/damodaran_margin_data.py,sha256=rMrgN1Qtw572a0ftY97OOj4otq8ldlLrcOi-bcE-org,8554
5
- mergeron/core/ftc_merger_investigations_data.py,sha256=Q8d2N4brY2cwJClibwxOVfLE3WV0XZABssblGN6nOdA,28639
6
- mergeron/core/guidelines_boundaries.py,sha256=sEvIIaOvWl6tMDYeZCIr8EsBioXOn9RSXKyKlmxnH-k,15610
5
+ mergeron/core/ftc_merger_investigations_data.py,sha256=eldNU4hX9oKE4Rb08YE9_1LgolvNKZnhOXW6KyWSwnM,28622
6
+ mergeron/core/guidelines_boundaries.py,sha256=aOpSOaZPsN3CKcLMgkjtCXT2O-l0qb8Qh0Xv4chdSgM,15593
7
7
  mergeron/core/guidelines_boundary_functions.py,sha256=GGn5mwBWmxkqcat4Ya0D-J6-7ujosgCCK3eJ9RFWASI,29749
8
8
  mergeron/core/guidelines_boundary_functions_extra.py,sha256=HDwwKZDWlrj3Tw-I0gHm0TCSDcIyb9jDfwbuDvK55B8,11322
9
9
  mergeron/core/pseudorandom_numbers.py,sha256=cJEWDTfy9CUTzR_di6Fm1Vl1Le6xWoU8wFHbYVMEuLI,9225
@@ -12,13 +12,13 @@ mergeron/data/damodaran_margin_data.xls,sha256=Qggl1p5nkOMJI8YUXhkwXQRz-OhRSqBTz
12
12
  mergeron/data/damodaran_margin_data_dict.msgpack,sha256=sr6s4L69kposEpzGI7jpPb4ULz0UpY-bEYfeNi6UlRA,57621
13
13
  mergeron/data/ftc_invdata.msgpack,sha256=WBFHgi7Ld4R-h2zL2Zc3TOIlKqVrbVFMH1LoI4-T-M0,264664
14
14
  mergeron/demo/__init__.py,sha256=KtjBlZOl7jwBCAUhrTJB9PdrN39YLYytNiSUSM_gRmA,62
15
- mergeron/demo/visualize_empirical_margin_distribution.py,sha256=v1xFJumBX2Ooye82kSSgly-_GpFVkYSDqBwM__rcmZY,2363
15
+ mergeron/demo/visualize_empirical_margin_distribution.py,sha256=R-sGC87kVovWBqcM5U6GiNC9oLsbNaMTJgljv8ts8w0,2347
16
16
  mergeron/gen/__init__.py,sha256=0rfcWpKDhYE_jNsw6xKTGFJqgNtfJ-5JFxHS89CIEuI,16575
17
17
  mergeron/gen/data_generation.py,sha256=jSpwB2BHBDPVTsT1-NZhTSCcUV6816qn5oZBe6S0Hio,16797
18
18
  mergeron/gen/data_generation_functions.py,sha256=bP3E0IPXINRc8s0dUxS_Wqo1byVzheZLX811A17WNbU,28571
19
19
  mergeron/gen/enforcement_stats.py,sha256=ZjrV_VkFMF0D1myc-fj-W99M1EhJMA9-nCfyE5g9e54,10890
20
- mergeron/gen/upp_tests.py,sha256=PtPOcu1zPDoHJUi06ytDUPNk21rzMwnfeGqUhvYXZs0,12607
20
+ mergeron/gen/upp_tests.py,sha256=uRF4RrBo3amwQQSu661Xa50xKGMUxtnM3zRtYy3nyB0,12581
21
21
  mergeron/py.typed,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
22
- mergeron-2024.739127.0.dist-info/METADATA,sha256=rvQUQmlBT2ECLY4t9Dy4fnUN1-A_sn_5f09z_IYNPE4,13976
23
- mergeron-2024.739127.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
- mergeron-2024.739127.0.dist-info/RECORD,,
22
+ mergeron-2024.739127.1.dist-info/METADATA,sha256=crHd8c-F-fRENxyWbg7kjVS0a-GhPDozGn2UxvLssB4,13967
23
+ mergeron-2024.739127.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
+ mergeron-2024.739127.1.dist-info/RECORD,,