# wbroscious/bargaining architecture

> Architecture diagram of the GitHub repository wbroscious/bargaining, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wbroscious/bargaining
- Repository: https://github.com/wbroscious/bargaining

## Overview

1. This repository is an analysis pipeline for Matthew Backus’s eBay bargaining data, not an application server or package. The architecture is a sequence of numbered Python scripts that transform raw bargaining records into derived variables, analysis samples, regressions, and publication-ready tables/figures.

2. The first subsystem is data/schema setup. `01_Load_Schema.py` and `compare_schemas.py` establish the data model and check that the loaded data match the expected schema. Supporting docs like `Delay_Schema.txt`, `Codebook.xlsx`, `Documentation.docx`, and `memory/project_overview.md` describe the underlying fields and project conventions.

3. The next layer is feature engineering and sample definition. `02_Variable_Creation.py`, `09_Alternative_Variable_Creation.py`, and `09b_Variable_Creation_Full.py` build the main analysis variables, while `03_Sample_Justification.py` and `04_Sample_Creation.py` define and defend the final estimation sample. This is the main boundary between raw data and analysis-ready data.

4. Baseline inference lives in the regression layer. `05_Regressions.py`, `Regressions.py`, `06_Other_Statistics.py`, and `Table_Category_Regressions.tex` produce the core econometric results and summary tables. These scripts are the central consumer of the engineered sample and variables.

5. A separate branch handles causal credibility and sensitivity. `07_Robustness_Checks.py`, `08_Identification_Tests.py`, `25_threshold_sensitivity.py`, `26_compare_naive_vs_asof.py`, `33_bimodality_test.py`, `34_zinb_test.py`, and `34b_diag.py` test whether results survive alternative specifications, matching logic, threshold choices, and distributional assumptions.

6. Several scripts focus on event structure and bargaining dynamics over time. `10_Events.py`, `13_Bargaining_Test.py`, `14_Bilateral_Monopoly.py`, `22_accept_worse*.py`, `23_worse_category_controlling_gs.py`, and `32_rate_persistence_floor.py` examine negotiation behavior, acceptance patterns, and dynamic outcomes after specific events.

7. Another major subsystem is seller- and competition-level analysis. `11_Competition_Regressions.py`, `12_Seller_Regressions.py`, `12a_Build_Seller_Reg.py`, `42_long_negotiation_sellers.py`, `43_seller_6227032.py`, `44_seller_leaf_specialization.py`, `44b_meta_specialization.py`, `45_sellers_highST_lowdemand.py`, and `46_target_seller_negotiations.py` shift the unit of analysis from listings to sellers and seller groups.

8. The repo also contains many focused exploratory modules around market structure and bargaining frictions: `15_linked_items.py`, `16_group_size_analysis.py`, `17_price_gap_analysis.py`, `18_relist_bid_rate.py`, `19_sale_channels.py`, `20_group_size_leaves.py`, `21_bm_and_highgs.py`, `27_chain_flag_heterogeneity.py`, `28_build_listing_bidrate.py`, `29_stamps_explore.py`, `30_stamps_unsold_relist.py`, and `31*` scripts. These are domain-specific probes into relisting, group size, channel differences, and item/category specialization.

9. Output artifacts are split from code but still part of the analysis architecture. `Figures/`, `PDF_Old/`, `BM_Identification_Report.pdf`, `Asymmetric_Aspirational_eBay_Bargaining.pdf`, `Aspirational_Bargaining.txt`, `Analysis_Summary.md`, `thickness_regression_by_category.xlsx`, and `Table_Category_Regressions.tex` are generated deliverables for writing, plotting, and reporting.

10. There is a lightweight validation/debugging layer for consistency across iterations of the pipeline. `compare_new_to_debug.py`, `compare_seller_results.py`, `sample_compare.py`, `inspect_debug.py`, and `diagnose_listing_count.py` compare schemas, samples, and seller-level outputs to catch regressions when the analysis logic changes.

11. The overall data flow is one-way: raw bargaining data and schema definitions feed variable creation, which feed sample construction, which feed the main regressions and specialized sub-analyses, which then feed tables, figures, and reports. The numbered filenames strongly suggest a staged research workflow where later scripts depend on earlier outputs rather than a single monolithic program.

12. In architecture-diagram terms, the key boundaries are: raw data/schema input; transformed analysis dataset; core econometric engine; seller/market sub-analyses; and reporting/artifact generation. This is a research codebase centered on reproducible econometric analysis rather than a service-oriented system.

Main entry points: [`04_Sample_Creation.py`](https://github.com/wbroscious/bargaining/blob/main/04_Sample_Creation.py) (Final sample), [`compare_new_to_debug.py`](https://github.com/wbroscious/bargaining/blob/main/compare_new_to_debug.py) (Validation tools), [`01_Load_Schema.py`](https://github.com/wbroscious/bargaining/blob/main/01_Load_Schema.py) (Schema setup), [`02_Variable_Creation.py`](https://github.com/wbroscious/bargaining/blob/main/02_Variable_Creation.py) (Variables)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Schema & inputs"]
  node_raw_schema["Schema setup<br/>data prep<br/>[01_Load_Schema.py]"]
  node_schema_compare["Schema compare<br/>validation<br/>[compare_schemas.py]"]
  node_project_docs["Project docs<br/>reference"]
end

subgraph group_prep["Prep & sampling"]
  node_var_create["Variables<br/>feature engineering"]
  node_var_alt["Alt variables<br/>feature engineering"]
  node_sample_justify["Sample logic<br/>sample design"]
  node_sample_build["Final sample<br/>sample construction"]
end

subgraph group_core["Core inference"]
  node_core_regs["Regressions<br/>econometrics<br/>[05_Regressions.py]"]
  node_stats["Summary stats<br/>descriptives"]
  node_regressions_module["Regression module<br/>econometrics<br/>[Regressions.py]"]
end

subgraph group_extensions["Extensions"]
  node_robustness["Robustness<br/>sensitivity"]
  node_identification["Identification<br/>design tests"]
  node_events["Events<br/>dynamics<br/>[10_Events.py]"]
  node_seller_regs["Seller regressions<br/>seller analysis"]
  node_competition_regs["Competition<br/>market structure"]
  node_bargaining_tests["Bargaining tests<br/>behavioral tests"]
  node_specialized_probes["Market probes<br/>exploratory analysis<br/>[15_linked_items.py]"]
  node_threshold_tests["Sensitivity suite<br/>robustness"]
  node_seller_probe["Seller focus<br/>case study"]
end

subgraph group_outputs["Reports & validation"]
  node_compare_debug["Validation tools<br/>consistency checks"]
  node_artifacts["Reports<br/>deliverables"]
end

node_project_docs -->|"define fields"| node_raw_schema
node_raw_schema -->|"verify"| node_schema_compare
node_raw_schema -->|"feed raw data"| node_var_create
node_var_create -->|"define sample"| node_sample_justify
node_sample_justify -->|"construct"| node_sample_build
node_var_create -->|"inputs"| node_sample_build
node_sample_build -->|"estimate"| node_core_regs
node_sample_build -->|"summarize"| node_stats
node_var_alt -->|"alt specs"| node_robustness
node_sample_build -->|"test stability"| node_robustness
node_sample_build -->|"test design"| node_identification
node_sample_build -->|"analyze dynamics"| node_events
node_sample_build -->|"market effects"| node_competition_regs
node_sample_build -->|"seller unit"| node_seller_regs
node_sample_build -->|"behavioral analysis"| node_bargaining_tests
node_sample_build -->|"probe frictions"| node_specialized_probes
node_sample_build -->|"sensitivity"| node_threshold_tests
node_sample_build -->|"case studies"| node_seller_probe
node_core_regs -->|"publish results"| node_artifacts
node_stats -->|"publish stats"| node_artifacts
node_robustness -->|"report checks"| node_artifacts
node_compare_debug -.->|"cross-check"| node_schema_compare
node_compare_debug -.->|"sample audit"| node_sample_build
node_compare_debug -.->|"seller audit"| node_seller_regs

click node_raw_schema "https://github.com/wbroscious/bargaining/blob/main/01_Load_Schema.py"
click node_schema_compare "https://github.com/wbroscious/bargaining/blob/main/compare_schemas.py"
click node_project_docs "https://github.com/wbroscious/bargaining/blob/main/memory/project_overview.md"
click node_var_create "https://github.com/wbroscious/bargaining/blob/main/02_Variable_Creation.py"
click node_var_alt "https://github.com/wbroscious/bargaining/blob/main/09_Alternative_Variable_Creation.py"
click node_sample_justify "https://github.com/wbroscious/bargaining/blob/main/03_Sample_Justification.py"
click node_sample_build "https://github.com/wbroscious/bargaining/blob/main/04_Sample_Creation.py"
click node_core_regs "https://github.com/wbroscious/bargaining/blob/main/05_Regressions.py"
click node_stats "https://github.com/wbroscious/bargaining/blob/main/06_Other_Statistics.py"
click node_regressions_module "https://github.com/wbroscious/bargaining/blob/main/Regressions.py"
click node_robustness "https://github.com/wbroscious/bargaining/blob/main/07_Robustness_Checks.py"
click node_identification "https://github.com/wbroscious/bargaining/blob/main/08_Identification_Tests.py"
click node_events "https://github.com/wbroscious/bargaining/blob/main/10_Events.py"
click node_seller_regs "https://github.com/wbroscious/bargaining/blob/main/12_Seller_Regressions.py"
click node_competition_regs "https://github.com/wbroscious/bargaining/blob/main/11_Competition_Regressions.py"
click node_bargaining_tests "https://github.com/wbroscious/bargaining/blob/main/13_Bargaining_Test.py"
click node_specialized_probes "https://github.com/wbroscious/bargaining/blob/main/15_linked_items.py"
click node_threshold_tests "https://github.com/wbroscious/bargaining/blob/main/25_threshold_sensitivity.py"
click node_seller_probe "https://github.com/wbroscious/bargaining/blob/main/42_long_negotiation_sellers.py"
click node_compare_debug "https://github.com/wbroscious/bargaining/blob/main/compare_new_to_debug.py"
click node_artifacts "https://github.com/wbroscious/bargaining/blob/main/Analysis_Summary.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_raw_schema,node_schema_compare,node_project_docs toneBlue
class node_var_create,node_var_alt,node_sample_justify,node_sample_build toneAmber
class node_core_regs,node_stats,node_regressions_module toneMint
class node_robustness,node_identification,node_events,node_seller_regs,node_competition_regs,node_bargaining_tests,node_specialized_probes,node_threshold_tests,node_seller_probe toneRose
class node_compare_debug,node_artifacts toneIndigo
```

## Components

### Schema & inputs

Raw bargaining data, schema definitions, and project conventions.

- [Schema setup](https://github.com/wbroscious/bargaining/blob/main/01_Load_Schema.py): data prep · Defines the expected bargaining data schema and checks loaded records against it. · `01_Load_Schema.py`
- [Schema compare](https://github.com/wbroscious/bargaining/blob/main/compare_schemas.py): validation · Compares inferred and expected schemas to catch structural mismatches. · `compare_schemas.py`
- [Project docs](https://github.com/wbroscious/bargaining/blob/main/memory/project_overview.md): reference · Codebook, schema notes, and project overview used to interpret fields and conventions. · `memory/project_overview.md`

### Prep & sampling

Feature engineering and sample construction.

- [Variables](https://github.com/wbroscious/bargaining/blob/main/02_Variable_Creation.py): feature engineering · Builds the main analysis variables from raw bargaining records. · `02_Variable_Creation.py`
- [Alt variables](https://github.com/wbroscious/bargaining/blob/main/09_Alternative_Variable_Creation.py): feature engineering · Alternative and full variable-construction variants for sensitivity analysis and extended coverage. · `09_Alternative_Variable_Creation.py`
- [Sample logic](https://github.com/wbroscious/bargaining/blob/main/03_Sample_Justification.py): sample design · Explains and justifies inclusion rules for the final estimation sample. · `03_Sample_Justification.py`
- [Final sample](https://github.com/wbroscious/bargaining/blob/main/04_Sample_Creation.py): sample construction · Constructs the analysis sample used by the downstream regressions and tests. · `04_Sample_Creation.py`

### Core inference

Baseline regressions and summary statistics.

- [Regressions](https://github.com/wbroscious/bargaining/blob/main/05_Regressions.py): econometrics · Main regression engine for the core bargaining results. · `05_Regressions.py`
- [Summary stats](https://github.com/wbroscious/bargaining/blob/main/06_Other_Statistics.py): descriptives · Produces additional statistics and supporting tables for the core analysis. · `06_Other_Statistics.py`
- [Regression module](https://github.com/wbroscious/bargaining/blob/main/Regressions.py): econometrics · Reusable regression definitions or shared logic used across the main results pipeline. · `Regressions.py`

### Extensions

Robustness, dynamics, seller analysis, and exploratory modules.

- [Robustness](https://github.com/wbroscious/bargaining/blob/main/07_Robustness_Checks.py): sensitivity · Alternative specifications and checks for stability of the baseline findings. · `07_Robustness_Checks.py`
- [Identification](https://github.com/wbroscious/bargaining/blob/main/08_Identification_Tests.py): design tests · Tests identification assumptions and matching logic behind the causal interpretation. · `08_Identification_Tests.py`
- [Events](https://github.com/wbroscious/bargaining/blob/main/10_Events.py): dynamics · Analyzes event structure and bargaining dynamics over time. · `10_Events.py`
- [Seller regressions](https://github.com/wbroscious/bargaining/blob/main/12_Seller_Regressions.py): seller analysis · Shifts the unit of analysis from listings to sellers and seller-level outcomes. · `12_Seller_Regressions.py`
- [Competition](https://github.com/wbroscious/bargaining/blob/main/11_Competition_Regressions.py): market structure · Studies competition-related bargaining effects and market-level regressions. · `11_Competition_Regressions.py`
- [Bargaining tests](https://github.com/wbroscious/bargaining/blob/main/13_Bargaining_Test.py): behavioral tests · Checks negotiation behavior, acceptance patterns, and bilateral monopoly cases. · `13_Bargaining_Test.py`
- [Market probes](https://github.com/wbroscious/bargaining/blob/main/15_linked_items.py): exploratory analysis · Domain-specific scans of relisting, group size, channels, persistence, and other frictions. · `15_linked_items.py`
- [Sensitivity suite](https://github.com/wbroscious/bargaining/blob/main/25_threshold_sensitivity.py): robustness · Threshold, matching, distributional, and specification sensitivity checks. · `25_threshold_sensitivity.py`
- [Seller focus](https://github.com/wbroscious/bargaining/blob/main/42_long_negotiation_sellers.py): case study · Targeted seller-level investigations and specialization analyses. · `42_long_negotiation_sellers.py`

### Reports & validation

Published deliverables and consistency checks.

- [Validation tools](https://github.com/wbroscious/bargaining/blob/main/compare_new_to_debug.py): consistency checks · Compares schemas, samples, and seller outputs across iterations to catch regressions. · `compare_new_to_debug.py`
- [Reports](https://github.com/wbroscious/bargaining/blob/main/Analysis_Summary.md): deliverables · Generated figures, tables, and paper/report outputs for publication and review. · `Analysis_Summary.md`

## Connections

- Project docs → Schema setup: define fields · Documentation specifies the expected schema and project conventions.
- Schema setup → Schema compare: verify · Loaded records are checked against the expected schema.
- Schema setup → Variables: feed raw data · Schema-loaded bargaining records enter feature engineering.
- Variables → Sample logic: define sample · Engineered variables support sample inclusion logic.
- Sample logic → Final sample: construct · Sample rules are implemented to create the final analysis sample.
- Variables → Final sample: inputs · Sample construction depends on derived variables and flags.
- Final sample → Regressions: estimate · The final sample feeds the baseline regressions.
- Final sample → Summary stats: summarize · Sample data also feeds descriptive statistics.
- Alt variables → Robustness: alt specs · Alternative variable definitions support sensitivity checks.
- Final sample → Robustness: test stability · Robustness checks re-run the core analysis under alternative assumptions.
- Final sample → Identification: test design · Identification tests probe the assumptions behind the sample and matching logic.
- Final sample → Events: analyze dynamics · Event-based analysis uses the constructed sample to study bargaining sequences.
- Final sample → Competition: market effects · Competition analysis reuses the analysis sample at a broader market level.
- Final sample → Seller regressions: seller unit · Seller regressions aggregate or restructure the sample at the seller level.
- Final sample → Bargaining tests: behavioral analysis · Negotiation tests examine acceptance and bargaining behavior in the sample.
- Final sample → Market probes: probe frictions · Exploratory modules study relisting, group size, channels, and persistence effects.
- Final sample → Sensitivity suite: sensitivity · Threshold and specification sensitivity modules depend on the analysis sample.
- Final sample → Seller focus: case studies · Targeted seller analyses isolate particular sellers or seller cohorts.
- Regressions → Reports: publish results · Main regressions generate tables and figures for the final outputs.
- Summary stats → Reports: publish stats · Summary statistics flow into tables and report artifacts.
- Robustness → Reports: report checks · Robustness outputs are packaged into the reporting layer.
- Validation tools → Schema compare: cross-check · Validation scripts compare schemas, samples, and outputs across runs.
- Validation tools → Final sample: sample audit · Sample comparison tooling helps detect regressions in construction logic.
- Validation tools → Seller regressions: seller audit · Seller comparison tooling checks consistency of seller-level outputs.
