mws-lab Documentation
A complete reference for mws-lab — Water Scarcity in Morocco: the methodology, the data sources, the OLS model, the diagnostics, the repository structure, the analysis pipeline, and the validation checks.
Overview
mws-lab is an exploratory analysis of the climatic, agricultural, and socioeconomic drivers of national freshwater withdrawals in Morocco (2000–2025). It uses five publicly available World Bank indicators, supplemented by national indicators from Morocco's 2025 State of the Environment Report.
"Morocco's renewable freshwater per capita fell from roughly 2,560 m³ per year in 1960 to about 620 m³ in 2020, well inside the United Nations' absolute water-scarcity threshold."
Methodology
The analysis is exploratory and associational. It is not designed to establish causal attribution. All relationships are reported as associations, not as causal effects.
Analytical Workflow
1. Data Acquisition → World Bank WDI + SoE 2025
2. Data Harmonization → Units · periods · metadata
3. Quality Control → Missingness · outliers · source
4. Exploratory Analysis → Descriptives · trends
5. Empirical Modelling → Correlation · OLS (validated)
6. Robustness Checks → Diagnostics · specifications
7. Interpretation → Policy implications · limits
Regression Specification
FW_t = β0 + β1·IRRIG_t + β2·POPGR_t + β3·YIELD_t + β4·ARABLE_t + ε_t
β̂ = (XᵀX)⁻¹ Xᵀy
| Symbol | Variable |
|---|---|
| FW | Annual freshwater withdrawals |
| IRRIG | Irrigated share of agricultural land |
| POPGR | Population growth rate |
| YIELD | Cereal yield |
| ARABLE | Arable land share |
Data Sources
1. World Bank WDI
| Indicator | Code | Coverage |
|---|---|---|
| Arable land (% of land area) | AG.LND.ARBL.ZS | 2000–2024 |
| Agricultural land irrigated (%) | AG.LND.IRIG.AG.ZS | 2004–2019 |
| Cereal yield (kg/ha) | AG.YLD.CREL.KG | 2000–2024 |
| Annual freshwater withdrawals | ER.H2O.FWTL.K3 | 2000–2022 |
| Population growth (annual %) | SP.POP.GROW | 2000–2025 |
2. Morocco State of the Environment Report 2025
Renewable water resources per capita, potential and mobilizable water resources, groundwater abstraction, sectoral water allocation, seasonal rainfall, and national dam-filling rates for 2025 and 2026.
OLS Model
The regression is estimated by ordinary least squares on the complete-case window 2004–2019 (n = 16), limited by the irrigated-land series.
R² = 0.812 (adjusted R² = 0.744)
κ(X) ≈ 78,500 (condition number — severe multicollinearity)
n = 16 (complete-case window 2004–2019)
| Predictor | Approx. coefficient | Reading |
|---|---|---|
| Irrigated land | ≈ −3 | Negative, CI excludes zero |
| Population growth | ≈ −14 | Largest magnitude, wide CI |
| Cereal yield | ≈ 0 | Close to zero, narrow CI |
| Arable land | small positive | CI near zero |
Reproducibility
To reproduce the analysis:
# 1. Install the package
pip install mws-lab
# 2. Fetch the World Bank data
python -c "from mws_lab import fetch; fetch.main()"
# 3. Or: fetch manually
# Download the five WDI indicators for Morocco, 2000–2025
# Keep missing values missing
# Restrict the regression to 2004–2019 (n = 16)
# Estimate by OLS; report R², adjusted R², κ(X), CIs, VIFs
The full manuscript, all seven figures, and the analysis pipeline are available in the repository and on Zenodo/Figshare.
Key Findings
| # | Finding |
|---|---|
| 1 | Per-capita renewable water fell by roughly three-quarters (1960–2020) |
| 2 | Agriculture absorbs ≈ 88% of total water allocation |
| 3 | Withdrawals fell 2000–2010 and stabilized through 2022 |
| 4 | R² = 0.812 (n = 16), κ(X) ≈ 78,500 (severe multicollinearity) |
| 5 | Irrigated land ↔ population growth: r = −0.89 (inseparable) |
| 6 | The 2025–2026 rebound is a storage buffer, not a reversal |
Limitations
| Type | Concern |
|---|---|
| Sample size | n = 16, limited by irrigated-land series |
| Multicollinearity | κ(X) ≈ 78,500; coefficients unstable |
| Missing climate | No rainfall, temperature, ET in regression |
| Aggregation | National indicators mask basin heterogeneity |
| Inference | All relationships are associational |
| Coverage | Withdrawals reported only through 2022 |
Repository Structure
mws-lab/
├── README.md
├── AUTHORS.md
├── CHANGELOG.md
├── CITATION.cff
├── CONTRIBUTING.md
├── LICENSE
├── MANIFEST.in
├── VERSION
├── pyproject.toml
├── requirements.txt
├── setup.py
├── setup.cfg
├── upload_morocco.py
│
├── mws_lab/ # Python package
│ ├── __init__.py
│ ├── fetch.py
│ └── data/
│ ├── worldbank_data.csv
│ └── input.json
│
├── DATA/
│ └── raw/
│ ├── fetch_worldbank_data.py
│ ├── worldbank_data.csv
│ └── input.json
│
├── ANALYSIS/
│ ├── ANALYSIS_REPORT.md
│ └── analysis_insights.json
│
├── PUBLICATION/
│ ├── water_scarcity_morocco.pdf
│ ├── figures/
│ ├── Netlify/
│ │ └── public/
│ ├── credit_table.md
│ ├── manifest.json
│ └── netlify.toml
│
├── REPORTS/
├── EXTERNAL_REVIEW/
├── VALIDATION/
└── docs/
├── ITERATION_LOG.md
└── comprehensive_audit_report.json
Analysis Pipeline
The Python package mws-lab includes a fetch script
(mws_lab/fetch.py) that downloads the five World Bank indicators.
# Install
pip install mws-lab
# Fetch data
python -c "from mws_lab import fetch; fetch.main()"
# Or use the console script
mws-lab-fetch
The package includes:
mws_lab/fetch.py— reproducible data-fetch scriptmws_lab/data/worldbank_data.csv— World Bank WDI extractmws_lab/data/input.json— indicator configuration
Validation
Five validation checks are executed at v1.0.0. All pass.
| Check | Result |
|---|---|
| Model fit | R² = 0.812 (adjusted 0.744) |
| Multicollinearity | κ(X) ≈ 78,500 (reported) |
| Pairwise correlations | r = −0.89 (irrigated ↔ population) |
| Data completeness | No imputation, no interpolation |
| Causal claims | None (associational only) |
Scope & Limits
What mws-lab supports
- Reproducible data extraction from World Bank WDI.
- OLS regression with full diagnostics (VIF, condition number, CIs).
- Pairwise Pearson correlations on pairwise-complete observations.
- Open manuscript (CC-BY-4.0) and open code (MIT).
- Python package (PyPI:
mws-lab).
What mws-lab does not support
- Causal inference (no quasi-experimental design).
- Basin-level disaggregation (national indicators only).
- Direct climate variables in the regression.
- Sub-annual or seasonal analysis.
- Cross-country generalization.
Citation
Zenodo Archive
@software{baladi2026mws_zenodo,
author = {Baladi, Samir},
title = {{Water Scarcity in Morocco}: A Multivariate Analysis
of Climatic, Agricultural, and Socioeconomic Drivers},
year = {2026},
publisher = {Zenodo},
version = {1.0.0},
doi = {10.5281/zenodo.23884236},
url = {https://doi.org/10.5281/zenodo.23884236},
note = {Ronin Institute / Rite of Renaissance}
}
APA (inline)
Baladi, S. (2026). Water scarcity in Morocco: A multivariate analysis of climatic, agricultural, and socioeconomic drivers (Version 1.0.0). Zenodo. https://doi.org/10.5281/zenodo.23884236
Status
| Component | Status |
|---|---|
| Manuscript | Published (Zenodo · Figshare) |
| Figures (7) | Published (Figshare) |
| Data (WDI) | Open (CC-BY-4.0) |
| Python package | Published (PyPI: mws-lab) |
| Website | Published (Netlify) |
| Analysis | OLS, n = 16, R² = 0.812 |
| Diagnostics | VIF, condition number, CIs |
| Causal claims | None (associational only) |