# Federal contracts at the no-bid limits

Do Canadian federal contracts bunch just under the dollar limits below which a department may award without soliciting
bids, beyond what round-number pricing would produce anyway? And when one limit moved, did the pattern move with it? The
page is `index.html`.

A pile under a limit is a pattern. It does not prove contract splitting by anyone. No vendor is named or counted
individually, no buyer name is read, and no single contract is listed or described.

## Data

The "Contracts over $10,000" file of the federal proactive publication of contracts, published by the Treasury Board of
Canada Secretariat on open.canada.ca (record d8f85d91-7dec-4fd1-8055-483b77225d8b). Contains information licensed under the
Open Government Licence-Canada, https://open.canada.ca/en/open-government-licence-canada. The publisher states the data is unaudited.

The file is not copied here. `data/sources.json` holds its address and the sha256 of the bytes these results used. The
publisher refreshes it every quarter, so a later download will differ and the results will move a little.

## Reproduce

Python 3.12 with numpy. The page needs only the standard library.

```
python3 -B tests/test_bunching.py                 # controls on planted counts; no source file needed
python3 -B tests/test_change_1.py                 # the same for the later checks
python3 -B tests/test_change_2.py                 # the same for the later tallies
python3 -I -B tools/run_study.py --replay         # every point estimate, from results/histograms.json alone
python3 -I -B tools/change_1.py --replay          # every later point estimate, from the public results alone
python3 -I -B tools/change_2.py --replay          # every later tally, from the public results alone
python3 -I -B tools/get_source.py /path/to/new/dir
python3 -I -B tools/aggregate.py /path/to/new/dir/contracts.csv /path/to/new/dir/cells.json
python3 -I -B tools/run_study.py /path/to/new/dir/cells.json
python3 -I -B tools/sensitivity.py
python3 -I -B tools/aggregate_change_1.py /path/to/new/dir/contracts.csv /path/to/new/dir/cells-change-1.json
python3 -I -B tools/change_1.py /path/to/new/dir/cells-change-1.json
python3 -I -B tools/change_2.py
python3 -I -B site/render.py
```

The replays need no download and reproduce every point estimate. The intervals need the department by fiscal year counts,
which the aggregation steps rebuild from the source file. They are not published, because a cell that small comes close to
describing one contract.

## Files

- `protocol-r1.json`: the frozen parameters of the design, committed before any contract value was read.
  `predictions-r1.json` copies the ten predictions.
- `tools/aggregate.py`: streams the source file into bin counts and keeps no names and no rows.
- `tools/bunching.py`: the estimator and the labelling rule.
- `tools/run_study.py`: ratios, placebos, intervals, the natural check, the predictions as scored, and the replay.
- `tools/sensitivity.py`: added after the results were seen, and labelled so on the page: the curve and window sweep.
- `change-1-public.json`: the checks added after the results, written and committed before they ran, and after the scored
  results had been seen. `tools/aggregate_change_1.py` and `tools/change_1.py` run it. The first rebuilds the published
  counts from the source file and adds which values are round prices with or without tax. They write
  `results/change-1.json`.
- `change-2.json`: tallies from the public results, written and committed before its code ran, and after the scored
  results and the checks above had been seen. It tests nothing new. `tools/change_2.py` runs it and writes
  `results/change-2.json`.
- `results/summary.json`, `results/histograms.json`, `results/sensitivity.json`: the results and the public counts.
- `tests/test_bunching.py`, `tests/test_change_1.py`, `tests/test_change_2.py`: planted heaping, planted bunches, round prices
  and planted tallies. These are self-tests of the code, on counts of the form the estimator assumes.
- `site/render.py`, `site/page.css`: the page. Every number on it comes from `results/`, and its claims are asserted there.
- `vendor/viz-design-system/`: the chart kit (version 2.3.0) with its licences.

`protocol-r1.json` and the page state every rule, so nothing needed to re-run the study is missing.

Some files are packed in canada-contracts-thresholds-data-1.zip; unzip it here to restore the full export, which the manifest lists file by file.
