mergeron 2024.739099.1__py3-none-any.whl → 2024.739104.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.

@@ -21,7 +21,6 @@ from scipy.stats import beta, norm # type: ignore
21
21
  from .. import ( # noqa: TID252
22
22
  _PKG_NAME,
23
23
  DATA_DIR,
24
- TI,
25
24
  VERSION,
26
25
  ArrayBIGINT,
27
26
  ArrayDouble,
@@ -121,7 +120,7 @@ if not (_out_path := DATA_DIR.joinpath(f"{_PKG_NAME}.cls")).is_file():
121
120
 
122
121
 
123
122
  if not (_DOTTEX := DATA_DIR / Rf"{_PKG_NAME}_TikZTableSettings.tex").is_file():
124
- # Write to dottex
123
+ # Write to LaTeX table settings file
125
124
  with resources.as_file(
126
125
  resources.files(f"{_PKG_NAME}.data.jinja2_LaTeX_templates").joinpath(
127
126
  "setup_tikz_tables.tex"
@@ -165,32 +164,6 @@ hhi_delta_ranger, hhi_zone_post_ranger = (
165
164
  for _f in (HHI_DELTA_KNOTS, HHI_POST_ZONE_KNOTS)
166
165
  )
167
166
 
168
- HMG_PRESUMPTION_ZONE_DICT = {
169
- HHI_POST_ZONE_KNOTS[0]: {
170
- HHI_DELTA_KNOTS[0]: (0, 0, 0),
171
- HHI_DELTA_KNOTS[1]: (0, 0, 0),
172
- HHI_DELTA_KNOTS[2]: (0, 0, 0),
173
- },
174
- HHI_POST_ZONE_KNOTS[1]: {
175
- HHI_DELTA_KNOTS[0]: (0, 1, 1),
176
- HHI_DELTA_KNOTS[1]: (1, 1, 2),
177
- HHI_DELTA_KNOTS[2]: (1, 1, 2),
178
- },
179
- HHI_POST_ZONE_KNOTS[2]: {
180
- HHI_DELTA_KNOTS[0]: (0, 2, 1),
181
- HHI_DELTA_KNOTS[1]: (1, 2, 3),
182
- HHI_DELTA_KNOTS[2]: (2, 2, 4),
183
- },
184
- }
185
-
186
- ZONE_VALS = np.unique(
187
- np.vstack([
188
- tuple(HMG_PRESUMPTION_ZONE_DICT[_k].values())
189
- for _k in HMG_PRESUMPTION_ZONE_DICT
190
- ]),
191
- axis=0,
192
- )
193
-
194
167
  ZONE_STRINGS = {
195
168
  0: R"Green Zone (Safeharbor)",
196
169
  1: R"Yellow Zone",
@@ -234,6 +207,31 @@ ZONE_DETAIL_STRINGS_DELTA_LATEX = {
234
207
  4: Rf"\Delta HHI \geqslant \text{{{HHI_DELTA_KNOTS[2]} pts.}}",
235
208
  }
236
209
 
210
+ HMG_PRESUMPTION_ZONE_MAP = {
211
+ HHI_POST_ZONE_KNOTS[0]: {
212
+ HHI_DELTA_KNOTS[0]: (0, 0, 0),
213
+ HHI_DELTA_KNOTS[1]: (0, 0, 0),
214
+ HHI_DELTA_KNOTS[2]: (0, 0, 0),
215
+ },
216
+ HHI_POST_ZONE_KNOTS[1]: {
217
+ HHI_DELTA_KNOTS[0]: (0, 1, 1),
218
+ HHI_DELTA_KNOTS[1]: (1, 1, 2),
219
+ HHI_DELTA_KNOTS[2]: (1, 1, 2),
220
+ },
221
+ HHI_POST_ZONE_KNOTS[2]: {
222
+ HHI_DELTA_KNOTS[0]: (0, 2, 1),
223
+ HHI_DELTA_KNOTS[1]: (1, 2, 3),
224
+ HHI_DELTA_KNOTS[2]: (2, 2, 4),
225
+ },
226
+ }
227
+
228
+ ZONE_VALS = np.unique(
229
+ np.vstack([
230
+ tuple(HMG_PRESUMPTION_ZONE_MAP[_k].values()) for _k in HMG_PRESUMPTION_ZONE_MAP
231
+ ]),
232
+ axis=0,
233
+ )
234
+
237
235
 
238
236
  def enf_stats_output(
239
237
  _data_array_dict: fid.INVData,
@@ -475,7 +473,7 @@ def enf_cnts_byconczone(_cnts_array: ArrayBIGINT, /) -> ArrayBIGINT:
475
473
  else (_hhi_delta_ranged == _hhi_zone_delta_lim)
476
474
  )
477
475
 
478
- _zone_val = HMG_PRESUMPTION_ZONE_DICT[_hhi_zone_post_lim][
476
+ _zone_val = HMG_PRESUMPTION_ZONE_MAP[_hhi_zone_post_lim][
479
477
  _hhi_zone_delta_lim
480
478
  ]
481
479
 
@@ -667,7 +665,7 @@ def _stats_formatted_row(
667
665
  match _return_type_sel:
668
666
  case StatsReturnSelector.RIN:
669
667
  _stats_row_ci = np.array([
670
- _propn_ci(*g, method="Wilson")
668
+ propn_ci(*g, method="Wilson")
671
669
  for g in zip(_stats_row_cnt[1:], _stats_row_tot[1:], strict=True)
672
670
  ])
673
671
  return [
@@ -722,9 +720,9 @@ def stats_print_rows(
722
720
  print()
723
721
 
724
722
 
725
- def _propn_ci(
726
- _npos: ArrayINT[TI] | int = 4,
727
- _nobs: ArrayINT[TI] | int = 10,
723
+ def propn_ci(
724
+ _npos: ArrayINT | int = 4,
725
+ _nobs: ArrayINT | int = 10,
728
726
  /,
729
727
  *,
730
728
  alpha: float = 0.05,
mergeron/gen/upp_tests.py CHANGED
@@ -11,19 +11,16 @@ from typing import Literal, TypeAlias, TypedDict
11
11
 
12
12
  import numpy as np
13
13
  import tables as ptb # type: ignore
14
- from joblib import Parallel, cpu_count, delayed # type: ignore
15
14
  from numpy.random import SeedSequence
16
15
 
17
- from .. import ( # noqa: TID252
18
- TF,
19
- TI,
16
+ from .. import ( # noqa
20
17
  VERSION,
21
18
  ArrayBIGINT,
22
19
  ArrayBoolean,
23
20
  ArrayDouble,
24
21
  ArrayFloat,
25
22
  ArrayINT,
26
- RECConstants,
23
+ RECTypes,
27
24
  UPPAggrSelector,
28
25
  )
29
26
  from ..core import guidelines_boundaries as gbl # noqa: TID252
@@ -32,12 +29,10 @@ from . import (
32
29
  DataclassInstance,
33
30
  INVResolution,
34
31
  MarketDataSample,
35
- MarketSpec,
36
32
  UPPTestRegime,
37
33
  UPPTestsCounts,
38
34
  UPPTestsRaw,
39
35
  )
40
- from . import data_generation as dgl
41
36
  from . import enforcement_stats as esl
42
37
 
43
38
  __version__ = VERSION
@@ -58,169 +53,37 @@ class INVRESCntsArgs(TypedDict, total=False):
58
53
  saved_array_name_suffix: str
59
54
 
60
55
 
61
- def sim_enf_cnts_ll(
62
- _mkt_sample_spec: MarketSpec,
63
- _enf_parm_vec: gbl.HMGThresholds,
64
- _sim_test_regime: UPPTestRegime,
56
+ def enf_cnts(
57
+ _market_data_sample: MarketDataSample,
58
+ _upp_test_parms: gbl.HMGThresholds,
59
+ _upp_test_regime: UPPTestRegime,
65
60
  /,
66
- *,
67
- sample_size: int = 10**6,
68
- seed_seq_list: list[SeedSequence] | None = None,
69
- nthreads: int = 16,
70
- save_data_to_file: SaveData = False,
71
- saved_array_name_suffix: str = "",
72
61
  ) -> UPPTestsCounts:
73
- """A function to parallelize data-generation and testing
74
-
75
- The parameters `_sim_enf_cnts_kwargs` are passed unaltered to
76
- the parent function, `sim_enf_cnts()`, except that, if provided,
77
- `seed_seq_list` is used to spawn a seed sequence for each thread,
78
- to assure independent samples in each thread, and `nthreads` defines
79
- the number of parallel processes used. The number of draws in
80
- each thread may be tuned, by trial and error, to the amount of
81
- memory (RAM) available.
62
+ """Estimate enforcement and clearance counts from market data sample
82
63
 
83
64
  Parameters
84
65
  ----------
66
+ _market_data_sample
67
+ Market data sample
85
68
 
86
- _enf_parm_vec
87
- Guidelines thresholds to test against
88
-
89
- _mkt_sample_spec
90
- Configuration to use for generating sample data to test
91
-
92
- _sim_test_regime
93
- Configuration to use for testing
94
-
95
- saved_array_name_suffix
96
- Suffix to add to the array names in the HDF5 file
97
-
98
- save_data_to_file
99
- Whether to save data to an HDF5 file, and where to save it
100
-
101
- sample_size
102
- Number of draws to simulate
103
-
104
- seed_seq_list
105
- List of seed sequences, to assure independent samples in each thread
69
+ _upp_test_parms
70
+ Threshold values for various Guidelines criteria
106
71
 
107
- nthreads
108
- Number of parallel processes to use
72
+ _upp_test_regime
73
+ Specifies whether to analyze enforcement, clearance, or both
74
+ and the GUPPI and diversion ratio aggregators employed, with
75
+ default being to analyze enforcement based on the maximum
76
+ merging-firm GUPPI and maximum diversion ratio between the
77
+ merging firms
109
78
 
110
79
  Returns
111
80
  -------
112
- Arrays of UPPTestCounts
81
+ UPPTestsCounts
82
+ Enforced and cleared counts
113
83
 
114
84
  """
115
- _sample_sz = sample_size
116
- _subsample_sz = 10**6
117
- _iter_count = int(_sample_sz / _subsample_sz) if _subsample_sz < _sample_sz else 1
118
- _thread_count = cpu_count()
119
-
120
- if (
121
- _mkt_sample_spec.share_spec.recapture_form != RECConstants.OUTIN
122
- and _mkt_sample_spec.share_spec.recapture_rate != _enf_parm_vec.rec
123
- ):
124
- raise ValueError(
125
- "{} {} {}".format(
126
- f"Recapture rate from market sample spec, {_mkt_sample_spec.share_spec.recapture_rate}",
127
- f"must match the value, {_enf_parm_vec.rec}",
128
- "the guidelines thresholds vector.",
129
- )
130
- )
131
85
 
132
- _rng_seed_seq_list = [None] * _iter_count
133
- if seed_seq_list:
134
- _rng_seed_seq_list = list(
135
- zip(*[g.spawn(_iter_count) for g in seed_seq_list], strict=True) # type: ignore
136
- )
137
-
138
- _sim_enf_cnts_kwargs: INVRESCntsArgs = INVRESCntsArgs({
139
- "sample_size": _subsample_sz,
140
- "save_data_to_file": save_data_to_file,
141
- "nthreads": nthreads,
142
- })
143
-
144
- _res_list = Parallel(n_jobs=_thread_count, prefer="threads")(
145
- delayed(sim_enf_cnts)(
146
- _mkt_sample_spec,
147
- _enf_parm_vec,
148
- _sim_test_regime,
149
- **_sim_enf_cnts_kwargs,
150
- saved_array_name_suffix=f"{saved_array_name_suffix}_{_iter_id:0{2 + int(np.ceil(np.log10(_iter_count)))}d}",
151
- seed_seq_list=_rng_seed_seq_list_ch,
152
- )
153
- for _iter_id, _rng_seed_seq_list_ch in enumerate(_rng_seed_seq_list)
154
- )
155
-
156
- _res_list_stacks = UPPTestsCounts(*[
157
- np.stack([getattr(_j, _k) for _j in _res_list])
158
- for _k in ("by_firm_count", "by_delta", "by_conczone")
159
- ])
160
- upp_test_results = UPPTestsCounts(*[
161
- np.column_stack((
162
- (_gv := getattr(_res_list_stacks, _g))[0, :, :_h],
163
- np.einsum("ijk->jk", np.int64(1) * _gv[:, :, _h:]),
164
- ))
165
- for _g, _h in zip(
166
- _res_list_stacks.__dataclass_fields__.keys(), [1, 1, 3], strict=True
167
- )
168
- ])
169
- del _res_list, _res_list_stacks
170
-
171
- return upp_test_results
172
-
173
-
174
- def sim_enf_cnts(
175
- _mkt_sample_spec: MarketSpec,
176
- _upp_test_parms: gbl.HMGThresholds,
177
- _sim_test_regime: UPPTestRegime,
178
- /,
179
- *,
180
- sample_size: int = 10**6,
181
- seed_seq_list: list[SeedSequence] | None = None,
182
- nthreads: int = 16,
183
- save_data_to_file: SaveData = False,
184
- saved_array_name_suffix: str = "",
185
- ) -> UPPTestsCounts:
186
- # Generate market data
187
- _market_data_sample = dgl.gen_market_sample(
188
- _mkt_sample_spec,
189
- sample_size=sample_size,
190
- seed_seq_list=seed_seq_list,
191
- nthreads=nthreads,
192
- )
193
-
194
- _invalid_array_names = (
195
- ("fcounts", "choice_prob_outgd", "nth_firm_share", "hhi_post")
196
- if _mkt_sample_spec.share_spec.dist_type == "Uniform"
197
- else ()
198
- )
199
-
200
- save_data_to_hdf5(
201
- _market_data_sample,
202
- saved_array_name_suffix=saved_array_name_suffix,
203
- excluded_attrs=_invalid_array_names,
204
- save_data_to_file=save_data_to_file,
205
- )
206
-
207
- _upp_test_arrays = enf_cnts(_market_data_sample, _upp_test_parms, _sim_test_regime)
208
-
209
- save_data_to_hdf5(
210
- _upp_test_arrays,
211
- saved_array_name_suffix=saved_array_name_suffix,
212
- save_data_to_file=save_data_to_file,
213
- )
214
-
215
- return _upp_test_arrays
216
-
217
-
218
- def enf_cnts(
219
- _market_data_sample: MarketDataSample,
220
- _upp_test_parms: gbl.HMGThresholds,
221
- _upp_test_regime: UPPTestRegime,
222
- /,
223
- ) -> UPPTestsCounts:
86
+ _enf_cnts_sim_array = -1 * np.ones((6, 2), np.int64)
224
87
  _upp_test_arrays = gen_upp_test_arrays(
225
88
  _market_data_sample, _upp_test_parms, _upp_test_regime
226
89
  )
@@ -231,12 +94,13 @@ def enf_cnts(
231
94
 
232
95
  _stats_rowlen = 6
233
96
  # Clearance/enforcement counts --- by firm count
234
- _firm_counts_weights = np.unique(_fcounts)
235
- if _firm_counts_weights is not None and np.all(_firm_counts_weights >= 0):
236
- _max_firm_count = len(_firm_counts_weights)
97
+ _firm_counts_list = np.unique(_fcounts)
98
+ if _firm_counts_list is not None and np.all(_firm_counts_list >= 0):
99
+ # _max_firm_count = len(_firm_counts_list)
100
+ _max_firm_count = max(_firm_counts_list)
237
101
 
238
102
  _enf_cnts_sim_byfirmcount_array = -1 * np.ones(_stats_rowlen, np.int64)
239
- for _firm_cnt in 2 + np.arange(_max_firm_count):
103
+ for _firm_cnt in 1 + np.arange(1, _max_firm_count):
240
104
  _firm_count_test = _fcounts == _firm_cnt
241
105
 
242
106
  _enf_cnts_sim_byfirmcount_array = np.vstack((
@@ -260,7 +124,7 @@ def enf_cnts(
260
124
  )
261
125
  _enf_cnts_sim_byfirmcount_array[0] = 2
262
126
 
263
- # Clearance/enfrocement counts --- by delta
127
+ # Clearance/enforcement counts --- by delta
264
128
  _hhi_delta_ranged = esl.hhi_delta_ranger(_hhi_delta)
265
129
  _enf_cnts_sim_bydelta_array = -1 * np.ones(_stats_rowlen, np.int64)
266
130
  for _hhi_delta_lim in esl.HHI_DELTA_KNOTS[:-1]:
@@ -282,7 +146,7 @@ def enf_cnts(
282
146
 
283
147
  _enf_cnts_sim_bydelta_array = _enf_cnts_sim_bydelta_array[1:]
284
148
 
285
- # Clearance/enfrocement counts --- by zone
149
+ # Clearance/enforcement counts --- by zone
286
150
  try:
287
151
  _hhi_zone_post_ranged = esl.hhi_zone_post_ranger(_hhi_post)
288
152
  except ValueError as _err:
@@ -353,12 +217,10 @@ def gen_upp_test_arrays(
353
217
  getattr(_upp_test_parms, _f) for _f in ("guppi", "divr", "cmcr", "ipr")
354
218
  )
355
219
 
356
- _enf_resolution, _guppi_aggregator, _divr_aggregator = (
357
- getattr(_sim_test_regime, _f)
358
- for _f in ("resolution", "guppi_aggregator", "divr_aggregator")
220
+ _guppi_array, _ipr_array, _cmcr_array = (
221
+ np.empty_like(_market_data.price_array) for _ in range(3)
359
222
  )
360
223
 
361
- _guppi_array = np.empty_like(_market_data.divr_array)
362
224
  np.einsum(
363
225
  "ij,ij,ij->ij",
364
226
  _market_data.divr_array,
@@ -367,30 +229,53 @@ def gen_upp_test_arrays(
367
229
  out=_guppi_array,
368
230
  )
369
231
 
370
- _cmcr_array = np.empty_like(_market_data.divr_array)
371
- np.divide(
372
- np.einsum("ij,ij->ij", _market_data.pcm_array, _market_data.divr_array),
373
- np.einsum("ij,ij->ij", 1 - _market_data.pcm_array, 1 - _market_data.divr_array),
374
- out=_cmcr_array,
375
- )
376
-
377
- _ipr_array = np.empty_like(_market_data.divr_array)
378
232
  np.divide(
379
233
  np.einsum("ij,ij->ij", _market_data.pcm_array, _market_data.divr_array),
380
234
  1 - _market_data.divr_array,
381
235
  out=_ipr_array,
382
236
  )
383
237
 
384
- # This one needs further testing:
385
- # _ipr_array_alt = np.empty_like(_market_data.divr_array)
386
- # np.divide(_guppi_array, (1 - _market_data.divr_array[:, ::-1]), out=_ipr_array_alt)
238
+ np.divide(_ipr_array, 1 - _market_data.pcm_array, out=_cmcr_array)
387
239
 
388
- _test_measure_seq = (_market_data.divr_array, _guppi_array, _cmcr_array, _ipr_array)
240
+ (_divr_test_vector,) = _compute_test_value_seq(
241
+ (_market_data.divr_array,),
242
+ _market_data.frmshr_array,
243
+ _sim_test_regime.divr_aggregator,
244
+ )
245
+
246
+ (_guppi_test_vector, _cmcr_test_vector, _ipr_test_vector) = _compute_test_value_seq(
247
+ (_guppi_array, _cmcr_array, _ipr_array),
248
+ _market_data.frmshr_array,
249
+ _sim_test_regime.guppi_aggregator,
250
+ )
251
+ del _cmcr_array, _ipr_array, _guppi_array
389
252
 
253
+ if _sim_test_regime.resolution == INVResolution.ENFT:
254
+ _upp_test_arrays = UPPTestsRaw(
255
+ _guppi_test_vector >= _g_bar,
256
+ (_guppi_test_vector >= _g_bar) | (_divr_test_vector >= _divr_bar),
257
+ _cmcr_test_vector >= _cmcr_bar,
258
+ _ipr_test_vector >= _ipr_bar,
259
+ )
260
+ else:
261
+ _upp_test_arrays = UPPTestsRaw(
262
+ _guppi_test_vector < _g_bar,
263
+ (_guppi_test_vector < _g_bar) & (_divr_test_vector < _divr_bar),
264
+ _cmcr_test_vector < _cmcr_bar,
265
+ _ipr_test_vector < _ipr_bar,
266
+ )
267
+
268
+ return _upp_test_arrays
269
+
270
+
271
+ def _compute_test_value_seq(
272
+ _test_measure_seq: tuple[ArrayDouble, ...],
273
+ _wt_array: ArrayDouble,
274
+ _aggregator: UPPAggrSelector,
275
+ ) -> tuple[ArrayDouble, ...]:
390
276
  _wt_array = (
391
- _market_data.frmshr_array
392
- / np.einsum("ij->i", _market_data.frmshr_array)[:, None]
393
- if _guppi_aggregator
277
+ _wt_array / np.einsum("ij->i", _wt_array)[:, None]
278
+ if _aggregator
394
279
  in (
395
280
  UPPAggrSelector.CPA,
396
281
  UPPAggrSelector.CPD,
@@ -400,7 +285,7 @@ def gen_upp_test_arrays(
400
285
  else EMPTY_ARRAY_DEFAULT
401
286
  )
402
287
 
403
- match _guppi_aggregator:
288
+ match _aggregator:
404
289
  case UPPAggrSelector.AVG:
405
290
  _test_value_seq = (
406
291
  1 / 2 * np.einsum("ij->i", _g)[:, None] for _g in _test_measure_seq
@@ -440,30 +325,7 @@ def gen_upp_test_arrays(
440
325
  )
441
326
  case _:
442
327
  raise ValueError("GUPPI/diversion ratio aggregation method is invalid.")
443
- del _cmcr_array, _guppi_array
444
- (_divr_test_vector, _guppi_test_vector, _cmcr_test_vector, _ipr_test_vector) = (
445
- _test_value_seq
446
- )
447
-
448
- if _divr_aggregator == UPPAggrSelector.MAX:
449
- _divr_test_vector = _market_data.divr_array.max(axis=1, keepdims=True)
450
-
451
- if _enf_resolution == INVResolution.ENFT:
452
- _upp_test_arrays = UPPTestsRaw(
453
- _guppi_test_vector >= _g_bar,
454
- (_guppi_test_vector >= _g_bar) | (_divr_test_vector >= _divr_bar),
455
- _cmcr_test_vector >= _cmcr_bar,
456
- _ipr_test_vector >= _ipr_bar,
457
- )
458
- else:
459
- _upp_test_arrays = UPPTestsRaw(
460
- _guppi_test_vector < _g_bar,
461
- (_guppi_test_vector < _g_bar) & (_divr_test_vector < _divr_bar),
462
- _cmcr_test_vector < _cmcr_bar,
463
- _ipr_test_vector < _ipr_bar,
464
- )
465
-
466
- return _upp_test_arrays
328
+ return tuple(_test_value_seq)
467
329
 
468
330
 
469
331
  def initialize_hd5(
@@ -506,11 +368,7 @@ def save_data_to_hdf5(
506
368
 
507
369
 
508
370
  def save_array_to_hdf5(
509
- _array_obj: ArrayFloat[TF]
510
- | ArrayINT[TI]
511
- | ArrayDouble
512
- | ArrayBIGINT
513
- | ArrayBoolean,
371
+ _array_obj: ArrayFloat | ArrayINT | ArrayDouble | ArrayBIGINT | ArrayBoolean,
514
372
  _array_name: str,
515
373
  _h5_group: ptb.Group,
516
374
  _h5_file: ptb.File,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mergeron
3
- Version: 2024.739099.1
3
+ Version: 2024.739104.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
@@ -1,10 +1,10 @@
1
1
  mergeron/License.txt,sha256=7iX-y0EyjkbVJKJLS4ZKzuuE1wd0lryfsD_IytLG8lQ,1246
2
- mergeron/__init__.py,sha256=u08ycqko_RgETIhaYivtm7Tglj2dZFk83KUJIbPRuL4,1541
2
+ mergeron/__init__.py,sha256=MXow5RSpGz49ggTHygQKv5TIJd5iRpTKyQyT9sYGdm4,1455
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=oL_4yrNPpjuNIluBsDc51lYd2Z4NBBrd7-sHKd3FCbg,28129
6
- mergeron/core/guidelines_boundaries.py,sha256=Lv-7EE7b2SiudpRjW3gFY1uHu-K0UdesewwiqaqjcOw,15585
7
- mergeron/core/guidelines_boundary_functions.py,sha256=HbuVOpQWlbIhvlWYvL2PXovase5az8DFU82woVl1VLo,29685
5
+ mergeron/core/ftc_merger_investigations_data.py,sha256=qGAjjXEyqwS1PKKxvJGsSkr0sfI--4oyLss9I1qCNR4,28247
6
+ mergeron/core/guidelines_boundaries.py,sha256=Iu7MBg3WzaRUALOobNmzmv_g7l-Njk1k7Y-esLBZBbk,15541
7
+ mergeron/core/guidelines_boundary_functions.py,sha256=gohb7Uj1AjJQtD5ew7bVZZjGhJEYCjNNAPB1o6TsA9M,29683
8
8
  mergeron/core/guidelines_boundary_functions_extra.py,sha256=t84dMsaMKnYUNuvvGrMCP6vI8MDn88PJOgGZlNe1Zts,11280
9
9
  mergeron/core/pseudorandom_numbers.py,sha256=cJEWDTfy9CUTzR_di6Fm1Vl1Le6xWoU8wFHbYVMEuLI,9225
10
10
  mergeron/data/__init__.py,sha256=KtjBlZOl7jwBCAUhrTJB9PdrN39YLYytNiSUSM_gRmA,62
@@ -20,13 +20,12 @@ mergeron/data/jinja2_LaTeX_templates/mergeron_table_collection_template.tex.jinj
20
20
  mergeron/data/jinja2_LaTeX_templates/setup_tikz_tables.tex,sha256=1hw3RINDtBrh9ZEToMIiNFIu9rozcPwRly69-5O_0UQ,3207
21
21
  mergeron/demo/__init__.py,sha256=KtjBlZOl7jwBCAUhrTJB9PdrN39YLYytNiSUSM_gRmA,62
22
22
  mergeron/demo/visualize_empirical_margin_distribution.py,sha256=v1xFJumBX2Ooye82kSSgly-_GpFVkYSDqBwM__rcmZY,2363
23
- mergeron/gen/__init__.py,sha256=Tm_eDiZkOwoOrfKyRu_3jkmNpFqyBMxfMY-Lu9BYAnc,17050
24
- mergeron/gen/_data_generation_functions.py,sha256=I4J8cDTMR27683Kr18ST1nzdA8kCZVKz7cyk8y3rfMo,27582
25
- mergeron/gen/data_generation.py,sha256=dj9otFi1OE3Eo7f32BD0ZXm9Xvlg0fCp4DDQ_XhDN_w,8479
26
- mergeron/gen/enforcement_stats.py,sha256=6IekvV8qvGFid6xbvqOazKYytMZQEwLyApt5TzTFPWU,27421
27
- mergeron/gen/market_sample.py,sha256=HkzRFTKBXYIs2HbAyVDUiUHo9nCtAciSn5sohR-34cM,4282
28
- mergeron/gen/upp_tests.py,sha256=xYhzWBgJJxYtz6VlGrrtx_cwwSZD3FdTDLD5zB1RDng,17261
23
+ mergeron/gen/__init__.py,sha256=A-co8RQL-QTsgfErF2O6qC3zcYYR56F6m9PBjH_M1kk,16564
24
+ mergeron/gen/data_generation.py,sha256=_sjFm426uIj0MkoMIWQyL8hq3P4XbBIKe0kMUy7aVps,16449
25
+ mergeron/gen/data_generation_functions.py,sha256=Pglv9rzeb2mG1SKp01AtkILJdvggDQvDnK-u90019po,28505
26
+ mergeron/gen/enforcement_stats.py,sha256=ANnviFnoSUAwZOM5cMG1WrZwbkjuUohplRn5fQmd8Bs,27410
27
+ mergeron/gen/upp_tests.py,sha256=iDtfy-lc7uSnBK37f_AxDIz3mO7Gf7-G5tHbX3QRDI0,12647
29
28
  mergeron/py.typed,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
30
- mergeron-2024.739099.1.dist-info/METADATA,sha256=9AN4mWKYnvtQInNpO-ytzRthOUI3nB63FcnVVBNjD_s,10922
31
- mergeron-2024.739099.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
- mergeron-2024.739099.1.dist-info/RECORD,,
29
+ mergeron-2024.739104.1.dist-info/METADATA,sha256=A4K7HcIzkIoT7KUmlNOqUic42V1psF1kxNgtIih5l68,10922
30
+ mergeron-2024.739104.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
31
+ mergeron-2024.739104.1.dist-info/RECORD,,
@@ -1,143 +0,0 @@
1
- """
2
- Methods to generate data for analyzing merger enforcement policy.
3
-
4
- """
5
-
6
- from __future__ import annotations
7
-
8
- from attrs import define
9
- from numpy.random import SeedSequence
10
-
11
- from .. import VERSION # noqa: TID252
12
- from ..core.guidelines_boundaries import HMGThresholds # noqa: TID252
13
- from . import MarketSpec, UPPTestRegime
14
- from .data_generation import gen_market_sample
15
- from .upp_tests import SaveData, enf_cnts, save_data_to_hdf5, sim_enf_cnts_ll
16
-
17
- __version__ = VERSION
18
-
19
-
20
- @define(slots=False)
21
- class MarketSample(MarketSpec):
22
- def generate_sample(
23
- self,
24
- /,
25
- *,
26
- sample_size: int,
27
- seed_seq_list: list[SeedSequence] | None,
28
- nthreads: int,
29
- save_data_to_file: SaveData,
30
- ) -> None:
31
- """Generate market data
32
-
33
- Parameters
34
- ----------
35
- sample_size
36
- Size of the market sample drawn
37
-
38
- seed_seq_list
39
- List of :code:`numpy.random.SeedSequence` objects
40
-
41
- nthreads
42
- Number of threads to use
43
-
44
- save_data_to_file
45
- Save data to given HDF5 file, at specified group node
46
-
47
- Returns
48
- -------
49
- None
50
-
51
- Notes
52
- -----
53
- See documentation for :class:`mergeron.gen.data_generation.gen_market_sample`
54
- for more information, and :func:`mergeron.gen.data_generation.parse_seed_seq_list`
55
- on the specification of :code:`seed_seq_list`.
56
-
57
- """
58
- self.data = gen_market_sample(
59
- self,
60
- sample_size=sample_size,
61
- seed_seq_list=seed_seq_list,
62
- nthreads=nthreads,
63
- )
64
-
65
- _invalid_array_names = (
66
- ("fcounts", "choice_prob_outgd", "nth_firm_share", "hhi_post")
67
- if self.share_spec.dist_type == "Uniform"
68
- else ()
69
- )
70
-
71
- if save_data_to_file:
72
- save_data_to_hdf5(
73
- self.data,
74
- excluded_attrs=_invalid_array_names,
75
- save_data_to_file=save_data_to_file,
76
- )
77
-
78
- def estimate_enf_counts(
79
- self,
80
- _enf_parm_vec: HMGThresholds,
81
- _upp_test_regime: UPPTestRegime,
82
- /,
83
- *,
84
- sample_size: int = 10**6,
85
- seed_seq_list: list[SeedSequence] | None,
86
- nthreads: int,
87
- save_data_to_file: SaveData = False,
88
- ) -> None:
89
- """Generate market data
90
-
91
- Parameters
92
- ----------
93
- _enf_parm_vec
94
- Threshold values for various Guidelines criteria
95
-
96
- _upp_test_regime
97
- Specifies whether to analyze enforcement, clearance, or both
98
- and the GUPPI and diversion ratio aggregators employed, with
99
- default being to analyze enforcement based on the maximum
100
- merging-firm GUPPI and maximum diversion ratio between the
101
- merging firms
102
-
103
- sample_size
104
- Size of the market sample drawn
105
-
106
- seed_seq_list
107
- List of :code:`numpy.random.SeedSequence` objects
108
-
109
- nthreads
110
- Number of threads to use
111
-
112
- save_data_to_file
113
- Save data to given HDF5 file, at specified group node
114
-
115
- Returns
116
- -------
117
- None
118
-
119
- Notes
120
- -----
121
- See documentation for :class:`mergeron.gen.MarketSpec` for details on specifying
122
- how shares, margins, prices, and diversion ratios are generated, and whether to restrict
123
- the sample to draws representing mergers that meet the HSR filing requirements. See
124
- :class:`mergeron.gen.MarketDataSample` on the sample data generated; see,
125
- :func:`mergeron.gen.data_generation.parse_seed_seq_list` on
126
- the specification of :code:`seed_seq_list`.
127
-
128
- """
129
-
130
- if getattr(self, "market_data_sample", None) is None:
131
- self.enf_counts = sim_enf_cnts_ll(
132
- self,
133
- _enf_parm_vec,
134
- _upp_test_regime,
135
- sample_size=sample_size,
136
- seed_seq_list=seed_seq_list,
137
- nthreads=nthreads,
138
- save_data_to_file=save_data_to_file,
139
- )
140
- else:
141
- self.enf_counts = enf_cnts(self.data, _enf_parm_vec, _upp_test_regime)
142
- if save_data_to_file:
143
- save_data_to_hdf5(self.enf_counts, save_data_to_file=save_data_to_file)