An open structural quarterly macro model prototype for Malaysia.
v0.4.0 · An exploration by Shahid Rogers, built with Claude + Codex
- Quick Start
- CLI Tools
- What is this?
- What's inside
- What makes it Malaysian
- Key assumptions
- Use cases
- What's next
- Files
- Studies
- Changelog
- License
- References
Open studies/playground/index.html in your browser, or view online →
Requires Node.js 18+. No dependencies to install.
# Baseline scenario (8 quarters, outputs JSON to stdout)
node bin/run-model.mjs
# Oil shock: Brent at $150, weaker ringgit
node bin/run-model.mjs --brent 150 --fx 4.20 -o results/oil-shock.json
# Full war scenario: $200 oil, tighter policy
node bin/run-model.mjs --brent 200 --fx 4.50 --opr 4.0 --elnino
# Custom horizon
node bin/run-model.mjs --start 2027Q1 -n 12# Download latest GDP, CPI, labour, and trade data
node bin/fetch-opendosm.mjs
# Fetch specific dataset only
node bin/fetch-opendosm.mjs --dataset gdp
# With date range
node bin/fetch-opendosm.mjs --start 2015-01 --end 2025-12# Build a run pack from raw data + defaults
node bin/build-inputs.mjs -o data/run-packs/my-scenario.json
# Build with historical CSV overrides
node bin/build-inputs.mjs --historical historical_inputs.csv --scenario shock_overrides.jsonnode scripts/validate_model_inputs.mjs --historical <path> --scenario <path>npx serve .- Start with the Research Prototype Summary
- Read the Model Architecture for the 17-block overview
- Study How To Interpret This Model before using outputs
- Check the Operationalization Checklist for production readiness
Browse the studies/ directory for interactive scenario dashboards:
- Scenario Playground — adjust oil prices, OPR, exchange rates with live sliders
- $200 Oil — Iran War — full shock simulation
MaMaMo (Malaysia Macro Model) is a structural quarterly macroeconomic model prototype for the Malaysian economy. It adapts the broad architecture of the UK OBR/HM Treasury model and re-specifies its major blocks for Malaysian institutions, trade structure, and policy settings.
The idea is simple: Malaysia deserves a transparent, publicly inspectable macro model. BNM and MOF have their own, but those are proprietary. Academic models tend to be partial. MaMaMo aims to be something you can open, read, inspect, critique, extend, and learn from.
This is an exploration — built by Shahid Rogers with Claude and Codex to see what happens when you point LLM tools at a government-style macro framework and a country's economy. It is not a validated production forecasting system. It is a documented research build with enough structure to support serious iteration.
If you are new to the repo, start here:
- Research Prototype Summary
- Model Architecture Diagram
- How To Interpret This Model
- Model Standalone Readiness Audit
~200 equations, identities, and calibration rules across 17 blocks, written in EViews-compatible syntax:
| Block | What it covers |
|---|---|
| 1–3 | Private consumption (with credit and confidence), durables, property prices, inventories, business & housing investment, cost of capital |
| 4 | Labour market — employment, wages, unemployment, participation, and a foreign workers sub-block (~2M workers in plantations, construction, manufacturing) |
| 5–6 | Exports (E&E/semiconductors, commodities, tourism, other goods) and imports (with IO-table-derived import content ratios) |
| 7 | Prices and wages — CPI with administered prices split out (~22% weight for fuel, utilities, controlled food), PPI, ULC, export/import deflators, the GST/SST transition |
| 8 | Commodities — dual block for Oil & Gas (Petronas, Brent pass-through) and Palm Oil (CPO production, El Niño effects, export duties) |
| 9–10 | Government revenue (income tax, corporate tax, PITA, SST, Petronas dividends) and expenditure (emoluments, debt service, fuel subsidies, BSH cash transfers, development expenditure) |
| 11 | Balance of payments — managed float exchange rate, current account, remittance outflows, FDI/portfolio flows |
| 12 | Fiscal totals — fiscal balance, primary balance, debt dynamics, 65%-of-GDP ceiling |
| 13–14 | Monetary policy (OPR transmission to BLR, deposits, MGS yields) and financial sector |
| 15 | Income accounts — household disposable income, EPF, corporate profits, SOCSO |
| 16 | GDP identities, output gap, market sector satellite |
| 17 | Household balance sheet (deposits, EPF, equities, housing loans, hire purchase) and external IIP |
This is not just the UK model with labels swapped. Key Malaysia-specific features:
- Administered prices — RON95, diesel, electricity tariffs treated separately from market-driven CPI
- Petronas — upstream profits, PITA (38%), and dividends (~20% of federal revenue) flow through to the fiscal block
- Palm oil — CPO production with El Niño sensitivity, sliding-scale export duties, contribution to GVA
- E&E exports — driven by the global semiconductor cycle, ~38% of goods exports, with ~52% import content reflecting GVC integration
- EPF — mandatory 24% savings modelled as a distinct household wealth channel
- Foreign workers — 2 million workers modelled explicitly (absent from advanced-economy models)
- Fuel subsidies — endogenous: gap between Brent-in-ringgit and the administered pump price times consumption volume
- GST/SST transition — time-varying administered price weight and policy dummies for the 2015–2018 episode
- BNM-style fiscal — operating vs development expenditure, matching the federal budget structure
Crisis dummies for: 1997–98 AFC, 2008–09 GFC, 2013 minimum wage, 2015 oil crash, 2020 COVID.
Structural: Error-correction (ECM) framework — long-run equilibrium with short-run adjustment dynamics. Small open economy — Malaysia is a price-taker in commodity and capital markets. Managed float exchange rate — REER exogenous, NEER determined by relative prices.
Coefficients: Calibrated from BNM working papers, IMF Article IV reports, DOSM Input-Output tables, and published Malaysian macro studies. They are not yet fully estimated from raw data in a reproducible econometric pipeline, so treat them as informed starting points rather than validated structural parameters.
Policy variables (exogenous): OPR, administered fuel price, SST rate, CPO export duty rate, development expenditure growth.
Operational status: The model file is documented and internally coherent, but several important drivers and wedges are still external inputs or preprocessing products. That makes this a publishable research prototype, not yet a one-command forecasting system.
Fiscal scenario analysis under different oil/CPO paths. OPR transmission analysis. Subsidy rationalisation scenarios. Minimum wage impact assessment. Stress testing macro scenarios. Teaching structural macro modelling. Or just poking around to see how Malaysia's economy hangs together.
Not for:
- official forecasting
- policy sign-off
- investment advice
- point-estimate precision claims without separate validation
Use the model as a transparent scenario and learning framework unless and until the coefficients, preprocessing, and back-testing are upgraded.
This is the shortest honest description of the project today:
| Area | Status |
|---|---|
| Structure | Strong — 17-block Malaysia-specific model architecture is in place |
| Documentation | Strong — model file, glossary, and input docs are explicit |
| Calibration | Provisional — many coefficients are informed calibrations, not final estimates |
| Data pipeline | In progress — OpenDOSM fetcher and input pack builder in place |
| Scenario readiness | Usable — especially for structured what-if exercises |
| Production readiness | Not yet — too many important wedges remain external or loosely governed |
For a fuller operational view, see:
- Research Prototype Summary
- How To Interpret This Model
- Model Architecture Diagram
- Model Input Spec
- Model Operationalization Checklist
The biggest wins, roughly in priority order:
- Re-estimate everything — replace calibrated coefficients with proper econometrics using DOSM/BNM quarterly data
- Supply side — add a production function, TFP dynamics, sectoral capital stocks
- Sectoral disaggregation — break the market sector into manufacturing, services, agriculture, construction, mining
- Financial accelerator — link household debt (~84% of GDP) to NPLs, bank capital, credit supply
- E&E/GVC granularity — front-end vs back-end semicon, US-China decoupling scenarios
- Stochastic simulation — fan charts instead of point forecasts
- Data pipeline — auto-ingest from BNM API + OpenDOSM
- Back-testing — validate against AFC, GFC, COVID outturns
- Forward-looking expectations — rational expectations for inflation and exchange rates
- Digital economy — capture the ~23% of GDP that's now digital
In practice, model/malaysia-quarterly-model.md is now documented well enough to support a governed input pipeline. What it still lacks for true production quality is a preprocessing builder plus better treatment of the big external wedges, especially CREDIT, MCCI, GOVDEBTADJ, and HARAREA.
The next highest-value step is to build that preprocessing layer and satellite-rule set so the model can be run from raw source data instead of hand-assembled quarterly inputs.
Three command-line tools are available (Node.js 18+ required):
| Tool | What it does |
|---|---|
node bin/run-model.mjs |
Run the 17-block model solver with scenario inputs, output JSON |
node bin/fetch-opendosm.mjs |
Fetch quarterly data from Malaysia's OpenDOSM API |
node bin/build-inputs.mjs |
Assemble a run pack from raw data, CSVs, and defaults |
The solver (src/model-solver.js) is also importable as a library:
import { runModel } from './src/model-solver.js';
import { createBaselineRunPack } from './studies/playground/baseline-run-pack.js';
const runPack = createBaselineRunPack();
const results = runModel(runPack);
console.log(results[0]); // First quarter outputmodel/
malaysia-quarterly-model.md # The model (~200 equations, EViews syntax)
reference/
uk-obr-reference.md # Original UK OBR model (reference)
src/
model-engine.js # Core solver engine (reusable library)
model-solver.js # Full 17-block equation implementations
data-pipeline/ # Data ingestion modules
bin/
run-model.mjs # CLI: run scenarios, output JSON
build-inputs.mjs # CLI: assemble run packs from data
fetch-opendosm.mjs # CLI: fetch from OpenDOSM API
docs/
research-prototype-summary.md # One-page project summary
model-architecture.md # Clean architecture diagram
how-to-interpret-this-model.md # Reading guide and limitations
studies/
playground/
index.html # Interactive scenario playground
simulations/
oil-200-iran-war/
index.html # Interactive simulation dashboard
scenario-data.json # Full quarterly projections (JSON)
satellite/
residential-projects-slip/
index.html # Residential satellite dashboard
scenario-data.json # Residential quarterly projections (JSON)
README.md # You are here
| Scenario | What it models | Link |
|---|---|---|
| Scenario Playground | Interactive sandbox. Adjust oil prices, policy rates, exchange rates, and global conditions with live sliders. Watch macro outputs respond in real time through all transmission channels. | Open playground → |
| $200 Oil — Iran War | Brent spikes to $200/bbl on a US–Iran ground war. Traces fiscal, trade, household, and Petronas impacts over 8 quarters. | View simulation → |
| When Oil Hits $200, Residential Projects Slip | Satellite study inside the oil-war scenario. Maps the same macro shock into construction-cost inflation, launch deferrals, project delays, contractor stress, and LAD exposure for Malaysian residential development. | View simulation → |
v0.4.0 — Executable model engine and data pipeline. Added a standalone Node.js solver (src/model-solver.js) implementing all 17 blocks, CLI tools for running scenarios (bin/run-model.mjs), fetching OpenDOSM data (bin/fetch-opendosm.mjs), and building input packs (bin/build-inputs.mjs). The model can now be run from the command line with JSON output.
v0.3.0 — Documentation and presentation pass. Repositioned the project as a publishable research prototype, added a one-page summary, architecture diagram, interpretation note, and updated the landing page with inline document modals and clearer visitor-facing status.
v0.2.0 — Audit pass. Fixed 3 critical undefined variables (PDINV, TYCADJ, PXEE), added 2008–09 GFC dummies, corrected E&E import content (0.65 → 0.52), defined ~20 previously missing variables, made administered price weight time-varying for GST/SST.
v0.1.0 — Initial adaptation from UK OBR model. All 17 blocks rebuilt for Malaysia.
MIT License. See LICENSE for details. The original UK OBR model structure is Crown Copyright under the Open Government Licence. The Malaysian adaptation is provided as-is.
- OpenDOSM — Malaysia's open data platform. GDP, inflation, employment, trade, and population data under CC BY 4.0. open.dosm.gov.my
- DOSM, Input-Output Tables 2015 — Basis for import content ratios and cost structure weights. Released 26 Dec 2018. dosm.gov.my
- BNM Monthly Statistical Bulletin — Interest rates, monetary aggregates, credit, BOP, and financial data. bnm.gov.my/publications
- Bank Negara Malaysia, Annual Report 2024 — Macro outlook, monetary policy review, financial stability assessment. bnm.gov.my/ar2024
- BNM Research Papers — Working papers and staff studies on Malaysian monetary transmission, household debt, and macro modelling. bnm.gov.my/publications/research
- IMF, Malaysia: 2025 Article IV Consultation — Country Report No. 25/57, concluded 25 Feb 2025. Staff report with macro projections, fiscal assessment, and policy recommendations. imf.org
- IMF, Malaysia: 2024 Article IV Consultation — Country Report No. 24/70, Mar 2024. imf.org
- World Bank, Malaysia Economic Monitor, October 2025 — "From Bytes to Benefits: Digital Transformation as a Catalyst for Public Sector Productivity." worldbank.org
- OBR (UK), Forecast Methodology — Documentation of the original UK model architecture that MaMaMo adapts. obr.uk/forecasts-in-depth/forecast-methodology
- Alp, H., Elekdag, S.A. & Lall, S. (2012). "An Assessment of Malaysian Monetary Policy During the Global Financial Crisis of 2008–09." IMF Working Paper No. 12/35. imf.org
- BIS (2008). "The Monetary Transmission Mechanism in Malaysia." BIS Papers No. 35. bis.org
- Pham, T.A. & Nguyen, T.D. (2018). "The Transmission Mechanism of Malaysian Monetary Policy: A Time-Varying Vector Autoregression Approach." Empirical Economics, 55(2). ideas.repec.org