Assess debt sustainability¶
Take a country's public debt and its drivers, check that the debt-dynamics identity explains the history, project
the debt ratio from a set of assumptions, and see how it changes under stress. The baseline's change in debt is split
into the real interest rate, real growth, the exchange rate and the primary deficit. Gross financing needs and the
primary balance that would stabilise debt come with it. The stress tests are the IMF Debt Dynamics Tool's
deterministic scenarios plus a bank bail-out of your own. All of this is the pymetrix-fiscal plugin's, a separate
install, and it is PyMetrix's implementation of the published guidance, not an IMF or World Bank product.
Before you start¶
- The plugin,
pymetrix-fiscal: in a clone of pymetrix,pip install -e packages/pymetrix-fiscal. Restart the app and, when it asks about the new plugin, choose Enable. The plugin adds the Fiscal menu and a Fiscal workspace. - The data, one row per year, in the plugin's layout (its
docs/data-layout.md;pymetrix_fiscal.layout.layout_table()in code). It has the debt ratio, the foreign-currency and short-term shares, growth, inflation, effective interest rates on local- and foreign-currency debt, end-of-year and average exchange rates, the primary balance, other flows and amortisation, in per cent. Years with the debt ratio are history; the years after them, with debt left blank, are the assumptions. This page uses the plugin's example,dsa_example: a fictional country, 2010 to 2025, with assumptions to 2031, simulated. With your own data, load your file (File → Load data…) instead. - Your assumptions' sources. Each comes from a budget, a forecast round or your own judgement. The results'
provenance keeps them, so say where they came from (
Assumptions.with_paths(..., source=..., note=...)in code).
In the app, or in code¶
- File → Load example data…, with Example dataset: dsa_example and Save as: data.
- Fiscal → Debt profile…, with Debt: debt, Growth: growth, Inflation: inflation, Primary balance: primary_balance, Interest rate, local-currency debt: interest_domestic, Interest rate, foreign-currency debt: interest_foreign, Foreign-currency share: fx_share, Exchange rate, end of year: exchange_rate, Exchange rate, average: exchange_rate_avg, Other debt-creating flows: other_flows, and, under Advanced, Amortisation: amortisation, Short-term share: short_term_share and Foreign inflation: foreign_inflation. Save as: profile.
- The profile's window, Identity check tab: each year's change in debt, the part the identity explains, and the residual. Only 2020 is flagged: about 2.0 points of GDP of debt the balance does not account for (in this example, arrears cleared that year).
- Fiscal → Debt sustainability…, with Profile: profile, Assumptions from: Projection years of a dataset and Assumptions data: data. Save as: dsa. Its tabs are:
- Debt path: the ratio, history and projection, and the primary balance against the debt-stabilising balance;
- Decomposition: each year's change as stacked bars;
- Gross financing needs: their parts, by year;
- Identity check, Assumptions and Provenance.
- Fiscal → Stress tests…, with Profile: profile, Assumptions data: data, Standard tests: Debt Dynamics Tool (2021),
Scenario of your own:
other_flows[2027] += 5and Scenario name: Bank bail-out. Save as: stress. The Stress tests tab draws every scenario's debt and gross financing needs, the baseline heavier; Heat map shows each scenario's debt above the baseline.
from pymetrix import Dataset
from pymetrix_fiscal import DSA, Assumptions, Custom, DebtProfile, StressTests
data = Dataset.example("dsa_example")
profile = DebtProfile.from_data(data, "debt", growth="growth", inflation="inflation", primary_balance="primary_balance",
interest_domestic="interest_domestic", interest_foreign="interest_foreign",
fx_share="fx_share", exchange_rate="exchange_rate", exchange_rate_avg="exchange_rate_avg",
other_flows="other_flows", amortisation="amortisation",
short_term_share="short_term_share", foreign_inflation="foreign_inflation")
check = profile.check() # the identity on history, by year
dsa = DSA(profile, Assumptions.from_data(data))
baseline = dsa.project() # a DebtPath
parts = baseline.decomposition() # each year's change: SRDSF style; decomposition("mac2013") the other
tests = StressTests.ddt2021().add(Custom("Bank bail-out", changes={"other_flows": {"2027": 5.0}}))
stress = dsa.stress(tests) # a StressTestResult: the baseline first, then each test
The step Debt profile… records a call to debt_profile (from pymetrix_fiscal.app), which calls
DebtProfile.from_data. Debt sustainability… records project_debt and Stress tests… records stress_debt. The
script the steps write replays them.
Check the result¶
- The identity holds. In a projection, the components of each year's change add up to the change exactly (the Identity check tab's residual is zero to rounding). On history, look at the flagged years before trusting the drivers. A large residual is a flow missing from other flows, debt in a third currency, or a balance and a debt that cover different parts of the public sector.
- The baseline. Debt peaks at 59.4 per cent of GDP in 2027 and falls to 56.6 by 2031. That is because the primary balance (0.5 in 2031) ends above the debt-stabilising balance (-0.52). The decomposition shows the reason: growth takes off more than the real interest rate adds.
- The stress tests. The historical scenario raises debt most, to 67.7 per cent of GDP in 2031, because the history's primary deficits and residuals are worse than the plan. The constant primary balance gives 65.0. Of the shocks, growth's is the largest (63.4 at its peak). The bail-out adds 5 points in 2027, a little more once the intra-year exchange-rate term is counted.
- Provenance. Each result's Provenance tab names the data's series and fingerprint, every assumption with its source, the defaults used for anything left out, and the tests' historical window and moments.
Pitfalls¶
- Percentages, not fractions. The layout writes 5 for 5 per cent. A column of 0.05 is read as 0.05 per cent.
- The primary balance's definition. The decompositions treat interest as the interest bill. A balance that nets
interest revenue out (GFSM 2014's) differs from the SRDSF's, which excludes interest revenue too. Use one
definition throughout and say which in the profile (
balance=). - Shares are end-of-year.
fx_shareat the end of each year sets how much of next year's debt is revalued. A path of shares that jumps changes the intra-year exchange-rate term. - The projection starts the year after the history. Assumptions for a year that already has a debt ratio are refused: drop that year's debt or move the history's end.
- Not a rating. The plugin computes paths and stress tests; it gives no risk signal or sustainability judgement. The LIC DSF's thresholds and signals come in a later phase, labelled as PyMetrix's implementation.
See also¶
- The help topic Debt sustainability analysis (pymetrix-fiscal), which the plugin adds: the identity, the two decompositions, the stress tests and the checks.
- Run a forecast round: baseline, judgement and scenarios.
Assumptions.from_roundtakes a round's paths as the DSA's assumptions. - Make a report: the
dsa_brieftemplate puts the debt path, decomposition, stress tests and assumptions in one report.