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.

Published research. mws-lab is at v1.0.0. The manuscript, figures, data, and Python package are all published (Zenodo, Figshare, PyPI). The analysis is exploratory and associational; no causal claims are made.

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.

Projectmws-lab Full titleWater Scarcity in Morocco Version1.0.0 StagePublished · Exploratory associational analysis LicenseMIT (code) · CC-BY-4.0 (manuscript, figures, docs) DomainEarth & Environmental Sciences DOI10.5281/zenodo.23884236
"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
SymbolVariable
FWAnnual freshwater withdrawals
IRRIGIrrigated share of agricultural land
POPGRPopulation growth rate
YIELDCereal yield
ARABLEArable land share

Data Sources

1. World Bank WDI

IndicatorCodeCoverage
Arable land (% of land area)AG.LND.ARBL.ZS2000–2024
Agricultural land irrigated (%)AG.LND.IRIG.AG.ZS2004–2019
Cereal yield (kg/ha)AG.YLD.CREL.KG2000–2024
Annual freshwater withdrawalsER.H2O.FWTL.K32000–2022
Population growth (annual %)SP.POP.GROW2000–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.

No imputation, no interpolation. Missing values are kept missing. The complete-case sample for the OLS model is 2004–2019 (n = 16).

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)
PredictorApprox. coefficientReading
Irrigated land≈ −3Negative, CI excludes zero
Population growth≈ −14Largest magnitude, wide CI
Cereal yield≈ 0Close to zero, narrow CI
Arable landsmall positiveCI near zero
Multicollinearity as a finding. With κ(X) ≈ 78,500, individual coefficient magnitudes and signs are unstable and must not be read as independent causal effects. The model is reported as a description of joint explanatory power.

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
1Per-capita renewable water fell by roughly three-quarters (1960–2020)
2Agriculture absorbs ≈ 88% of total water allocation
3Withdrawals fell 2000–2010 and stabilized through 2022
4R² = 0.812 (n = 16), κ(X) ≈ 78,500 (severe multicollinearity)
5Irrigated land ↔ population growth: r = −0.89 (inseparable)
6The 2025–2026 rebound is a storage buffer, not a reversal

Limitations

TypeConcern
Sample sizen = 16, limited by irrigated-land series
Multicollinearityκ(X) ≈ 78,500; coefficients unstable
Missing climateNo rainfall, temperature, ET in regression
AggregationNational indicators mask basin heterogeneity
InferenceAll relationships are associational
CoverageWithdrawals 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 script
  • mws_lab/data/worldbank_data.csv — World Bank WDI extract
  • mws_lab/data/input.json — indicator configuration

Validation

Five validation checks are executed at v1.0.0. All pass.

CheckResult
Model fitR² = 0.812 (adjusted 0.744)
Multicollinearityκ(X) ≈ 78,500 (reported)
Pairwise correlationsr = −0.89 (irrigated ↔ population)
Data completenessNo imputation, no interpolation
Causal claimsNone (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.
Design philosophy. mws-lab is a research project, not a predictive model or a policy tool. Its purpose is to describe associations and to generate hypotheses, not to make forecasts or causal claims.

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

ComponentStatus
ManuscriptPublished (Zenodo · Figshare)
Figures (7)Published (Figshare)
Data (WDI)Open (CC-BY-4.0)
Python packagePublished (PyPI: mws-lab)
WebsitePublished (Netlify)
AnalysisOLS, n = 16, R² = 0.812
DiagnosticsVIF, condition number, CIs
Causal claimsNone (associational only)
Version 1.0.0 published. The analysis is exploratory and associational. No causal claims are made. All relationships are reported as associations, not as causal effects.