How realrate/causing works
1. The user-facing entry points (examples CLI, Python API)
2. The core modules (model definition & processing, graph construction, utilities)
3. Data-flow paths (input CSV/JSON → model computations → JSON results → Graphviz → SVG output)
4. External dependencies (SymPy, Graphviz, file system)
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Main components
• CLI / Python API (causing/examples/__main__.py, user’s scripts)
• Model Builder & Evaluator (causing/model.py)
• Graph Constructor (causing/graph.py)
• Utility Layer (causing/utils.py)
• Data Store (input CSV/JSON under data/ or causing/examples/input/)
• Results Store (intermediate graphs.json under output/)
• Renderer (Graphviz engine invoked by causing/graph.py)
• Packaging & Tests (setup.py, Makefile, .github/workflows, tests/)
Interactions and data flow
1. User invokes “python -m causing.examples example” or uses Python API.
2. Examples loader reads dataset (CSV/JSON) → passes to Model Builder.
3. Model Builder (model.py)
– Defines SymPy symbols and equations
– Calculates endogenous variables per individual observation
– Calls Utility functions (utils.py) for data normalization, derivative computations
– Outputs a structural representation (adjacency, weights) to Graph Constructor
4. Graph Constructor (graph.py)
– Converts structural representation → internal graph object
– Splits total effects into mediation effects per edge
– Serializes per-individual IME graph(s) into JSON under output/…/graphs.json
– Calls Graphviz to render JSON → SVG/EPS output in output/…
5. Final graph files are stored under output/education, output/example*, etc.
Architectural patterns and design principles
• Modular design: clear separation of model logic, graph logic, utilities, CLI
• Data-driven flow: pipelines for input → compute → intermediate JSON → render → output
• External-tool integration: Graphviz as rendering back-end, SymPy for symbolic math
• Small-data, in-memory processing; no long-running services or microservices
• Test harness: unit tests for model estimation (tests/test_estimate.py), utils, examples