# gulkhan92/doubleml_for_demand_price_elasticity architecture

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

- Interactive diagram: https://gitdiagram.com/gulkhan92/doubleml_for_demand_price_elasticity
- Repository: https://github.com/gulkhan92/doubleml_for_demand_price_elasticity

## Overview

This is a Python research pipeline for estimating retail demand price elasticity with Double Machine Learning (DML), alongside an OLS baseline and supporting causal analyses. The main workflow loads and joins M5 sales, calendar, and price data, filters sparse series, engineers lag and categorical features, estimates OLS and DML models, and compares results. Separate modules provide EDA, robustness, falsification, heterogeneity, and stability analyses. Edges reflect the main entry point and sampled imports/calls; unsampled analysis internals are not inferred.

Main entry points: [`data_preparation.py`](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/data_preparation.py) (Load and aggregate data), [`main.py`](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/main.py) (Pipeline entry point), [`feature_engineering.py`](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/feature_engineering.py) (Feature engineering), [`model_training.py`](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/model_training.py) (DML training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_preparation["Load and aggregate data"]
  node_features["Feature engineering"]
  node_feature_cache[("Feature cache<br/>[config.py]")]
end

subgraph group_estimation["Elasticity estimation"]
  node_main["Pipeline entry point<br/>[main.py]"]
  node_training["DML training<br/>[model_training.py]"]
  node_model_cache[("Model cache<br/>[config.py]")]
  node_evaluation["OLS and DML comparison<br/>[evaluation.py]"]
end

subgraph group_diagnostics["Diagnostics and analysis"]
  node_eda["Exploratory analysis<br/>[eda.py]"]
  node_robustness["Robustness analysis"]
  node_falsification["Falsification tests"]
  node_heterogeneity["Heterogeneity analysis"]
  node_stability["Stability analysis"]
  node_hausman["Hausman analysis<br/>[hausman_test.py]"]
end

subgraph group_support["Shared configuration"]
  node_config["Pipeline configuration<br/>[config.py]"]
end

node_analyst(("Analyst"))
node_sales["Sales CSV"]
node_prices["Prices CSV"]
node_calendar["Calendar CSV"]

node_analyst -->|"runs"| node_main
node_sales -->|"reads"| node_preparation
node_prices -->|"reads"| node_preparation
node_calendar -->|"reads"| node_preparation
node_main -->|"loads data"| node_preparation
node_main -->|"engineers features"| node_features
node_main -->|"reads/writes"| node_feature_cache
node_main -->|"runs baseline"| node_evaluation
node_main -->|"fits learners"| node_training
node_main -->|"reads/writes"| node_model_cache
node_main -->|"compares results"| node_evaluation
node_preparation -->|"uses paths and columns"| node_config
node_features -->|"uses feature columns"| node_config
node_training -->|"uses model settings"| node_config
node_evaluation -->|"uses outcome columns"| node_config
node_analyst -.->|"runs"| node_eda
node_eda -->|"loads data"| node_preparation
node_eda -->|"engineers features"| node_features
node_analyst -.->|"runs"| node_robustness
node_robustness -->|"loads data"| node_preparation
node_robustness -->|"engineers features"| node_features
node_analyst -.->|"runs"| node_falsification
node_falsification -->|"fits placebo models"| node_training
node_falsification -->|"loads data"| node_preparation
node_falsification -->|"engineers features"| node_features
node_analyst -.->|"runs"| node_heterogeneity
node_heterogeneity -->|"fits segment models"| node_training
node_heterogeneity -->|"loads data"| node_preparation
node_heterogeneity -->|"engineers features"| node_features
node_analyst -.->|"runs"| node_stability
node_stability -->|"fits subsample models"| node_training
node_stability -->|"loads data"| node_preparation
node_stability -->|"engineers features"| node_features

click node_main "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/main.py"
click node_preparation "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/data_preparation.py"
click node_features "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/feature_engineering.py"
click node_feature_cache "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/config.py"
click node_training "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/model_training.py"
click node_model_cache "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/config.py"
click node_evaluation "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/evaluation.py"
click node_config "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/config.py"
click node_eda "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/eda.py"
click node_robustness "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/robustness_analysis.py"
click node_falsification "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/falsification_tests.py"
click node_heterogeneity "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/heterogeneity_analysis.py"
click node_stability "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/stability_analysis.py"
click node_hausman "https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/hausman_test.py"

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_preparation,node_features,node_feature_cache toneBlue
class node_main,node_training,node_model_cache,node_evaluation toneAmber
class node_eda,node_robustness,node_falsification,node_heterogeneity,node_stability,node_hausman toneMint
class node_config toneRose
class node_analyst,node_sales,node_prices,node_calendar toneIndigo
```

## Components

### Data preparation

- [Load and aggregate data](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/data_preparation.py): `data_preparation.py`
- [Feature engineering](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/feature_engineering.py): `feature_engineering.py`
- [Feature cache](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/config.py): `config.py`

### Elasticity estimation

- [Pipeline entry point](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/main.py): `main.py`
- [DML training](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/model_training.py): `model_training.py`
- [Model cache](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/config.py): `config.py`
- [OLS and DML comparison](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/evaluation.py): `evaluation.py`

### Diagnostics and analysis

- [Exploratory analysis](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/eda.py): `eda.py`
- [Robustness analysis](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/robustness_analysis.py): `robustness_analysis.py`
- [Falsification tests](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/falsification_tests.py): `falsification_tests.py`
- [Heterogeneity analysis](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/heterogeneity_analysis.py): `heterogeneity_analysis.py`
- [Stability analysis](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/stability_analysis.py): `stability_analysis.py`
- [Hausman analysis](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/hausman_test.py): `hausman_test.py`

### Shared configuration

- [Pipeline configuration](https://github.com/gulkhan92/doubleml_for_demand_price_elasticity/blob/main/config.py): `config.py`

### Other components

- **Analyst**
- **Sales CSV**
- **Prices CSV**
- **Calendar CSV**

## Connections

- Analyst → Pipeline entry point: runs (evidence: `README.md`)
- Sales CSV → Load and aggregate data: reads (evidence: `data_preparation.py`)
- Prices CSV → Load and aggregate data: reads (evidence: `data_preparation.py`)
- Calendar CSV → Load and aggregate data: reads (evidence: `data_preparation.py`)
- Pipeline entry point → Load and aggregate data: loads data (evidence: `main.py`)
- Pipeline entry point → Feature engineering: engineers features (evidence: `main.py`)
- Pipeline entry point → Feature cache: reads/writes (evidence: `main.py`)
- Pipeline entry point → OLS and DML comparison: runs baseline (evidence: `main.py`)
- Pipeline entry point → DML training: fits learners (evidence: `main.py`)
- Pipeline entry point → Model cache: reads/writes (evidence: `main.py`)
- Pipeline entry point → OLS and DML comparison: compares results (evidence: `main.py`)
- Load and aggregate data → Pipeline configuration: uses paths and columns (evidence: `data_preparation.py`)
- Feature engineering → Pipeline configuration: uses feature columns (evidence: `feature_engineering.py`)
- DML training → Pipeline configuration: uses model settings (evidence: `model_training.py`)
- OLS and DML comparison → Pipeline configuration: uses outcome columns (evidence: `evaluation.py`)
- Analyst → Exploratory analysis: runs
- Exploratory analysis → Load and aggregate data: loads data (evidence: `eda.py`)
- Exploratory analysis → Feature engineering: engineers features (evidence: `eda.py`)
- Analyst → Robustness analysis: runs
- Robustness analysis → Load and aggregate data: loads data (evidence: `robustness_analysis.py`)
- Robustness analysis → Feature engineering: engineers features (evidence: `robustness_analysis.py`)
- Analyst → Falsification tests: runs
- Falsification tests → DML training: fits placebo models (evidence: `falsification_tests.py`)
- Falsification tests → Load and aggregate data: loads data (evidence: `falsification_tests.py`)
- Falsification tests → Feature engineering: engineers features (evidence: `falsification_tests.py`)
- Analyst → Heterogeneity analysis: runs
- Heterogeneity analysis → DML training: fits segment models (evidence: `heterogeneity_analysis.py`)
- Heterogeneity analysis → Load and aggregate data: loads data (evidence: `heterogeneity_analysis.py`)
- Heterogeneity analysis → Feature engineering: engineers features (evidence: `heterogeneity_analysis.py`)
- Analyst → Stability analysis: runs
- Stability analysis → DML training: fits subsample models (evidence: `stability_analysis.py`)
- Stability analysis → Load and aggregate data: loads data (evidence: `stability_analysis.py`)
- Stability analysis → Feature engineering: engineers features (evidence: `stability_analysis.py`)
