spb/wp9_uqo Public
UQO Working Paper No. 9 — A grand hedonic model of the Canadian housing market: decomposing structure and location value.
TeX 60.1%
Python 39.8%
1# Author: Simon-Pierre Boucher — contact@spboucher.ai2"""Paths and global constants for the WP9 pipeline.34All paths are relative to the repository root, so the pipeline runs on any5machine after cloning. Override the root with the ``WP9_ROOT`` environment6variable if the scripts are launched from elsewhere.7"""8import os9from pathlib import Path1011ROOT = Path(os.environ.get("WP9_ROOT", Path(__file__).resolve().parents[2]))1213RAW_DB = ROOT / "data" / "raw" / "realtor_mls_unique.duckdb"14PROCESSED = ROOT / "data" / "processed"15ANALYSIS_PARQUET = PROCESSED / "analysis.parquet"16FIGURES = ROOT / "figures"17RESULTS = ROOT / "results"18REFERENCE = RESULTS / "reference" # original (canonical) outputs — paper numbers19REPRODUCED = RESULTS / "reproduced" # outputs regenerated by this pipeline20TABLES = RESULTS / "tables"2122# Unit conversions (as documented in the paper's data section)23SQFT_TO_M2 = 0.092902324ACRE_TO_M2 = 4046.8625HA_TO_M2 = 10_000.02627# Sample construction28TRIM_LO, TRIM_HI = 0.01, 0.99 # 1% tails of price and living area29FSA_MIN_LISTINGS = 25 # FSAs below this are pooled into <PROV>_other30LOT_TAIL_Q = 0.99 # positive lot areas above this quantile set to 0 (unparseable/exotic)3132# Structural regressors used in every specification33STRUCT = ["ln_living", "bedrooms", "bathrooms", "half_baths",34 "parking_n", "stories_n", "has_lot", "ln_lot"]3536# Random seeds (identical to the original analysis scripts)37SEED_OOS = 1234538SEED_MORAN = 339SEED_EXT2 = 74041# Nine major metropolitan centres for the urban-gradient analysis42METROS = {43 "Toronto": (43.65, -79.38),44 "Montreal": (45.50, -73.57),45 "Vancouver": (49.28, -123.12),46 "Calgary": (51.05, -114.07),47 "Ottawa-Gatineau": (45.42, -75.70),48 "Edmonton": (53.55, -113.49),49 "Winnipeg": (49.90, -97.14),50 "Quebec City": (46.81, -71.21),51 "Halifax": (44.65, -63.58),52}5354def ensure_dirs() -> None:55 """Create every output directory the pipeline writes to."""56 for p in (PROCESSED, FIGURES, REFERENCE, REPRODUCED, TABLES):57 p.mkdir(parents=True, exist_ok=True)58