Sovereign Debt Default Probability Estimator
Key Economic Indicators
Enter positive for surplus, negative for deficit.
Enter positive for surplus, negative for deficit.
Qualitative Risk Factors & Weighting
Weighting of Factors (Total should be 100%)
Warning: Total weights must add up to 100%.
Default Probability Assessment
Please enter your data and risk factors, then click "Estimate Probability" to see the results.
Error: Please enter valid numbers for all inputs.
`; return; } // Validate weights sum to 100% let totalWeightSum = ( weightDebtGdp + weightFiscalBalance + weightFxReserves + weightInterestSpread + weightGdpGrowth + weightInflation + weightQualitative + weightExternalDebt + weightCurrentAccount ) * 100; // Convert back to percentage for comparison if (Math.abs(totalWeightSum - 100) > 0.01) { // Allow for tiny floating point errors showMessageBox('Weighting Error', `The sum of all factor weights must be 100%. Currently it is ${totalWeightSum.toFixed(0)}%. Please adjust the weights.`); resultsOutput.innerHTML = `Error: Total weights must sum to 100%.
`; return; } // --- Derived Ratios --- const debtToGdpRatio = countryGdp > 0 ? (totalPublicDebt / countryGdp) * 100 : 0; const fiscalBalanceGdp = countryGdp > 0 ? (fiscalDeficit / countryGdp) * 100 : 0; const fxReservesMonthsImports = monthlyImports > 0 ? fxReserves / monthlyImports : 0; const interestRateSpread = sovereignBondYield - riskFreeRate; const externalDebtGdp = countryGdp > 0 ? (externalDebt / countryGdp) * 100 : 0; const currentAccountBalanceGdp = countryGdp > 0 ? (currentAccountBalance / countryGdp) * 100 : 0; // --- Calculate Individual Risk Scores (0-100 for each factor, higher is worse) --- let scoreDebtGdp = 0; if (debtToGdpRatio > 120) scoreDebtGdp = 100; else if (debtToGdpRatio > 90) scoreDebtGdp = 80; else if (debtToGdpRatio > 60) scoreDebtGdp = 50; else if (debtToGdpRatio > 30) scoreDebtGdp = 20; let scoreFiscalBalance = 0; if (fiscalBalanceGdp < -10) scoreFiscalBalance = 100; // >10% deficit else if (fiscalBalanceGdp < -5) scoreFiscalBalance = 75; // 5-10% deficit else if (fiscalBalanceGdp < -2) scoreFiscalBalance = 50; // 2-5% deficit else if (fiscalBalanceGdp < 0) scoreFiscalBalance = 25; // Small deficit // Surplus will reduce score, but min is 0 for individual factor contributions let scoreFxReserves = 0; if (fxReservesMonthsImports < 1.5) scoreFxReserves = 100; else if (fxReservesMonthsImports < 3) scoreFxReserves = 80; else if (fxReservesMonthsImports < 4.5) scoreFxReserves = 50; else if (fxReservesMonthsImports < 6) scoreFxReserves = 20; let scoreInterestSpread = 0; if (interestRateSpread > 8) scoreInterestSpread = 100; else if (interestRateSpread > 5) scoreInterestSpread = 80; else if (interestRateSpread > 3) scoreInterestSpread = 50; else if (interestRateSpread > 1) scoreInterestSpread = 20; let scoreGdpGrowth = 0; if (gdpGrowthRate < -2) scoreGdpGrowth = 100; // Deep recession else if (gdpGrowthRate < 0) scoreGdpGrowth = 80; // Recession else if (gdpGrowthRate < 2) scoreGdpGrowth = 50; // Low growth else if (gdpGrowthRate < 4) scoreGdpGrowth = 20; let scoreInflation = 0; if (inflationRate > 20) scoreInflation = 100; else if (inflationRate > 10) scoreInflation = 80; else if (inflationRate > 5) scoreInflation = 50; else if (inflationRate > 2) scoreInflation = 20; let scoreExternalDebt = 0; if (externalDebtGdp > 100) scoreExternalDebt = 100; else if (externalDebtGdp > 70) scoreExternalDebt = 75; else if (externalDebtGdp > 40) scoreExternalDebt = 40; else if (externalDebtGdp > 20) scoreExternalDebt = 15; let scoreCurrentAccount = 0; if (currentAccountBalanceGdp < -10) scoreCurrentAccount = 100; else if (currentAccountBalanceGdp < -5) scoreCurrentAccount = 75; else if (currentAccountBalanceGdp < -2) scoreCurrentAccount = 40; else if (currentAccountBalanceGdp < 0) scoreCurrentAccount = 10; // Qualitative Score: Higher input means LOWER risk, so invert for risk score let scorePoliticalStability = (5 - politicalStability) * 20; // 0 for 5, 80 for 1 let scoreGovernanceQuality = (5 - governanceQuality) * 20; let scoreInstitutionalStrength = (5 - institutionalStrength) * 20; let scoreExternalShocksVulnerability = externalShocksVulnerability * 20; // 20 for 1, 100 for 5 // Combine qualitative scores (e.g., average them) let combinedQualitativeScore = ( scorePoliticalStability + scoreGovernanceQuality + scoreInstitutionalStrength + scoreExternalShocksVulnerability ) / 4; // Average of 4 factors // --- Weighted Average Default Probability --- let defaultProbability = ( (scoreDebtGdp * weightDebtGdp) + (scoreFiscalBalance * weightFiscalBalance) + (scoreFxReserves * weightFxReserves) + (scoreInterestSpread * weightInterestSpread) + (scoreGdpGrowth * weightGdpGrowth) + (scoreInflation * weightInflation) + (combinedQualitativeScore * weightQualitative) + (scoreExternalDebt * weightExternalDebt) + (scoreCurrentAccount * weightCurrentAccount) ); // Ensure probability is within 0-100 range defaultProbability = Math.max(0, Math.min(100, defaultProbability)); // --- Risk Level and Recommendation --- let riskLevel = "Low"; let riskColorClass = "text-green-600"; let recommendation = "The model suggests a low probability of sovereign debt default. Continued adherence to prudent fiscal and monetary policies, and strengthening of institutions, will help maintain this stability."; if (defaultProbability >= 50) { riskLevel = "High"; riskColorClass = "text-red-600"; recommendation = "The model indicates a high probability of sovereign debt default. This suggests significant vulnerabilities. Urgent and comprehensive policy reforms are likely needed to address high debt burdens, unsustainable fiscal paths, low reserves, or severe external imbalances. Seeking international assistance or debt restructuring might be necessary to avert a crisis."; } else if (defaultProbability >= 20) { riskLevel = "Medium"; riskColorClass = "text-orange-600"; recommendation = "The default probability is moderate. While not immediately critical, it signals underlying vulnerabilities. It is crucial for policymakers to monitor fiscal trends, debt sustainability, and external accounts closely. Implementing reforms to boost economic growth, diversify the economy, and build robust foreign exchange reserves should be a priority to improve resilience."; } // --- Display Results --- resultsOutput.innerHTML = `Key Financial Ratios:
Debt-to-GDP Ratio: ${debtToGdpRatio.toFixed(2)}%
Fiscal Balance (% of GDP): ${fiscalBalanceGdp.toFixed(2)}%
FX Reserves (Months of Imports): ${fxReservesMonthsImports.toFixed(2)} months
Interest Rate Spread (Sovereign vs. Risk-Free): ${interestRateSpread.toFixed(2)}%
External Debt (% of GDP): ${externalDebtGdp.toFixed(2)}%
Current Account Balance (% of GDP): ${currentAccountBalanceGdp.toFixed(2)}%
Estimated Default Probability:
${defaultProbability.toFixed(2)}%
Risk Level: ${riskLevel}
${recommendation}
Note: This model provides a simplified, conceptual estimate of sovereign debt default probability based on user inputs and assumed relationships. Actual sovereign default risk assessment is a highly complex process involving in-depth analysis of economic, political, and social factors, often employing sophisticated quantitative models and qualitative expert judgment. This tool should be used for illustrative purposes only and not as a substitute for professional financial or economic analysis.
`; } // PDF Download Functionality downloadPdfBtn.addEventListener('click', function() { const { jsPDF } = window.jspdf; const doc = new jsPDF(); // Re-collect values and re-calculate for PDF consistency const countryGdp = parseFloat(countryGdpInput.value); const totalPublicDebt = parseFloat(totalPublicDebtInput.value); const fiscalDeficit = parseFloat(fiscalDeficitInput.value); const fxReserves = parseFloat(fxReservesInput.value); const monthlyImports = parseFloat(monthlyImportsInput.value); const gdpGrowthRate = parseFloat(gdpGrowthRateInput.value); const inflationRate = parseFloat(inflationRateInput.value); const sovereignBondYield = parseFloat(sovereignBondYieldInput.value); const riskFreeRate = parseFloat(riskFreeRateInput.value); const externalDebt = parseFloat(externalDebtInput.value); const currentAccountBalance = parseFloat(currentAccountBalanceInput.value); const politicalStability = parseFloat(politicalStabilityInput.value); const governanceQuality = parseFloat(governanceQualityInput.value); const institutionalStrength = parseFloat(institutionalStrengthInput.value); const externalShocksVulnerability = parseFloat(externalShocksVulnerabilityInput.value); const weightDebtGdp = parseFloat(weightDebtGdpInput.value) / 100; const weightFiscalBalance = parseFloat(weightFiscalBalanceInput.value) / 100; const weightFxReserves = parseFloat(weightFxReservesInput.value) / 100; const weightInterestSpread = parseFloat(weightInterestSpreadInput.value) / 100; const weightGdpGrowth = parseFloat(weightGdpGrowthInput.value) / 100; const weightInflation = parseFloat(weightInflationInput.value) / 100; const weightQualitative = parseFloat(weightQualitativeInput.value) / 100; const weightExternalDebt = parseFloat(weightExternalDebtInput.value) / 100; const weightCurrentAccount = parseFloat(weightCurrentAccountInput.value) / 100; const debtToGdpRatio = countryGdp > 0 ? (totalPublicDebt / countryGdp) * 100 : 0; const fiscalBalanceGdp = countryGdp > 0 ? (fiscalDeficit / countryGdp) * 100 : 0; const fxReservesMonthsImports = monthlyImports > 0 ? fxReserves / monthlyImports : 0; const interestRateSpread = sovereignBondYield - riskFreeRate; const externalDebtGdp = countryGdp > 0 ? (externalDebt / countryGdp) * 100 : 0; const currentAccountBalanceGdp = countryGdp > 0 ? (currentAccountBalance / countryGdp) * 100 : 0; let scoreDebtGdp = 0; if (debtToGdpRatio > 120) scoreDebtGdp = 100; else if (debtToGdpRatio > 90) scoreDebtGdp = 80; else if (debtToGdpRatio > 60) scoreDebtGdp = 50; else if (debtToGdpRatio > 30) scoreDebtGdp = 20; let scoreFiscalBalance = 0; if (fiscalBalanceGdp < -10) scoreFiscalBalance = 100; else if (fiscalBalanceGdp < -5) scoreFiscalBalance = 75; else if (fiscalBalanceGdp < -2) scoreFiscalBalance = 50; else if (fiscalBalanceGdp < 0) scoreFiscalBalance = 25; let scoreFxReserves = 0; if (fxReservesMonthsImports < 1.5) scoreFxReserves = 100; else if (fxReservesMonthsImports < 3) scoreFxReserves = 80; else if (fxReservesMonthsImports < 4.5) scoreFxReserves = 50; else if (fxReservesMonthsImports < 6) scoreFxReserves = 20; let scoreInterestSpread = 0; if (interestRateSpread > 8) scoreInterestSpread = 100; else if (interestRateSpread > 5) scoreInterestSpread = 80; else if (interestRateSpread > 3) scoreInterestSpread = 50; else if (interestRateSpread > 1) scoreInterestSpread = 20; let scoreGdpGrowth = 0; if (gdpGrowthRate < -2) scoreGdpGrowth = 100; else if (gdpGrowthRate < 0) scoreGdpGrowth = 80; else if (gdpGrowthRate < 2) scoreGdpGrowth = 50; else if (gdpGrowthRate < 4) scoreGdpGrowth = 20; let scoreInflation = 0; if (inflationRate > 20) scoreInflation = 100; else if (inflationRate > 10) scoreInflation = 80; else if (inflationRate > 5) scoreInflation = 50; else if (inflationRate > 2) scoreInflation = 20; let scoreExternalDebt = 0; if (externalDebtGdp > 100) scoreExternalDebt = 100; else if (externalDebtGdp > 70) scoreExternalDebt = 75; else if (externalDebtGdp > 40) scoreExternalDebt = 40; else if (externalDebtGdp > 20) scoreExternalDebt = 15; let scoreCurrentAccount = 0; if (currentAccountBalanceGdp < -10) scoreCurrentAccount = 100; else if (currentAccountBalanceGdp < -5) scoreCurrentAccount = 75; else if (currentAccountBalanceGdp < -2) scoreCurrentAccount = 40; else if (currentAccountBalanceGdp < 0) scoreCurrentAccount = 10; let scorePoliticalStability = (5 - politicalStability) * 20; let scoreGovernanceQuality = (5 - governanceQuality) * 20; let scoreInstitutionalStrength = (5 - institutionalStrength) * 20; let scoreExternalShocksVulnerability = externalShocksVulnerability * 20; let combinedQualitativeScore = (scorePoliticalStability + scoreGovernanceQuality + scoreInstitutionalStrength + scoreExternalShocksVulnerability) / 4; let defaultProbability = ( (scoreDebtGdp * weightDebtGdp) + (scoreFiscalBalance * weightFiscalBalance) + (scoreFxReserves * weightFxReserves) + (scoreInterestSpread * weightInterestSpread) + (scoreGdpGrowth * weightGdpGrowth) + (scoreInflation * weightInflation) + (combinedQualitativeScore * weightQualitative) + (scoreExternalDebt * weightExternalDebt) + (scoreCurrentAccount * weightCurrentAccount) ); defaultProbability = Math.max(0, Math.min(100, defaultProbability)); let riskLevel = "Low"; let recommendation = "The model suggests a low probability of sovereign debt default. Continued adherence to prudent fiscal and monetary policies, and strengthening of institutions, will help maintain this stability."; if (defaultProbability >= 50) { riskLevel = "High"; recommendation = "The model indicates a high probability of sovereign debt default. This suggests significant vulnerabilities. Urgent and comprehensive policy reforms are likely needed to address high debt burdens, unsustainable fiscal paths, low reserves, or severe external imbalances. Seeking international assistance or debt restructuring might be necessary to avert a crisis."; } else if (defaultProbability >= 20) { riskLevel = "Medium"; recommendation = "The default probability is moderate. While not immediately critical, it signals underlying vulnerabilities. It is crucial to monitor fiscal trends, debt sustainability, and external accounts closely. Implementing reforms to boost economic growth, diversify the economy, and build robust foreign exchange reserves should be a priority to improve resilience."; } // PDF Content Setup doc.setFontSize(22); doc.setTextColor(30, 64, 138); // Dark Blue doc.text("Sovereign Debt Default Probability Report", 105, 20, null, null, "center"); doc.setFontSize(12); doc.setTextColor(55, 65, 81); // Gray-700 let y = 30; // Inputs Section doc.setFontSize(16); doc.setTextColor(30, 64, 138); // Dark Blue doc.text("1. Economic Data Inputs", 20, y += 15); doc.setFontSize(12); doc.setTextColor(55, 65, 81); // Gray-700 doc.autoTable({ startY: y + 5, head: [['Parameter', 'Value']], body: [ ['Annual GDP', `$${countryGdp.toLocaleString('en-US', { maximumFractionDigits: 0 })}`], ['Total Public Debt', `$${totalPublicDebt.toLocaleString('en-US', { maximumFractionDigits: 0 })}`], ['Annual Fiscal Deficit/Surplus', `$${fiscalDeficit.toLocaleString('en-US', { maximumFractionDigits: 0 })}`], ['Foreign Exchange Reserves', `$${fxReserves.toLocaleString('en-US', { maximumFractionDigits: 0 })}`], ['Average Monthly Imports', `$${monthlyImports.toLocaleString('en-US', { maximumFractionDigits: 0 })}`], ['Real GDP Growth Rate', `${gdpGrowthRate.toFixed(2)}%`], ['Inflation Rate', `${inflationRate.toFixed(2)}%`], ['10-Year Sovereign Bond Yield', `${sovereignBondYield.toFixed(2)}%`], ['Risk-Free Rate (e.g., US Treasury Yield)', `${riskFreeRate.toFixed(2)}%`], ['Total External Debt', `$${externalDebt.toLocaleString('en-US', { maximumFractionDigits: 0 })}`], ['Current Account Balance', `$${currentAccountBalance.toLocaleString('en-US', { maximumFractionDigits: 0 })}`] ], theme: 'grid', styles: { fillColor: [243, 244, 246] }, headStyles: { fillColor: [59, 130, 246], textColor: [255, 255, 255] }, margin: { left: 20, right: 20 } }); y = doc.autoTable.previous.finalY; // Risk Factors & Weighting Section doc.setFontSize(16); doc.setTextColor(30, 64, 138); doc.text("2. Qualitative Risk Factors & Weighting", 20, y += 15); doc.setFontSize(12); doc.setTextColor(55, 65, 81); doc.autoTable({ startY: y + 5, head: [['Factor', 'Score (1-5, 5=Best)', 'Weight (%)']], body: [ ['Political Stability', politicalStability.toFixed(0), (weightDebtGdp * 100).toFixed(0)], ['Governance Quality', governanceQuality.toFixed(0), (weightFiscalBalance * 100).toFixed(0)], ['Institutional Strength', institutionalStrength.toFixed(0), (weightFxReserves * 100).toFixed(0)], ['Vulnerability to External Shocks', externalShocksVulnerability.toFixed(0), (weightInterestSpread * 100).toFixed(0)], ['GDP Growth', '-', (weightGdpGrowth * 100).toFixed(0)], ['Inflation', '-', (weightInflation * 100).toFixed(0)], ['Qualitative Factors (Combined)', '-', (weightQualitative * 100).toFixed(0)], ['External Debt', '-', (weightExternalDebt * 100).toFixed(0)], ['Current Account', '-', (weightCurrentAccount * 100).toFixed(0)] ], theme: 'grid', styles: { fillColor: [243, 244, 246] }, headStyles: { fillColor: [59, 130, 246], textColor: [255, 255, 255] }, margin: { left: 20, right: 20 } }); y = doc.autoTable.previous.finalY; // Calculated Ratios doc.setFontSize(16); doc.setTextColor(30, 64, 138); doc.text("3. Calculated Financial Ratios", 20, y += 15); doc.setFontSize(12); doc.setTextColor(55, 65, 81); doc.autoTable({ startY: y + 5, head: [['Ratio', 'Value']], body: [ ['Debt-to-GDP Ratio', `${debtToGdpRatio.toFixed(2)}%`], ['Fiscal Balance (% of GDP)', `${fiscalBalanceGdp.toFixed(2)}%`], ['FX Reserves (Months of Imports)', `${fxReservesMonthsImports.toFixed(2)} months`], ['Interest Rate Spread (Sovereign vs. Risk-Free)', `${interestRateSpread.toFixed(2)}%`], ['External Debt (% of GDP)', `${externalDebtGdp.toFixed(2)}%`], ['Current Account Balance (% of GDP)', `${currentAccountBalanceGdp.toFixed(2)}%`] ], theme: 'grid', styles: { fillColor: [243, 244, 246] }, headStyles: { fillColor: [59, 130, 246], textColor: [255, 255, 255] }, margin: { left: 20, right: 20 } }); y = doc.autoTable.previous.finalY; // Results Section doc.setFontSize(16); doc.setTextColor(30, 64, 138); doc.text("4. Default Probability Assessment", 20, y += 15); doc.setFontSize(14); let pdfRiskColor; if (riskLevel === "High") { pdfRiskColor = [220, 38, 38]; // Red } else if (riskLevel === "Medium") { pdfRiskColor = [234, 88, 12]; // Orange } else { pdfRiskColor = [22, 163, 74]; // Green } doc.setTextColor(pdfRiskColor[0], pdfRiskColor[1], pdfRiskColor[2]); doc.text(`Estimated Default Probability: ${defaultProbability.toFixed(2)}%`, 20, y += 10); doc.text(`Risk Level: ${riskLevel}`, 20, y += 8); doc.setTextColor(55, 65, 81); doc.setFontSize(12); doc.text("Recommendation:", 20, y += 15); const splitRecommendation = doc.splitTextToSize(recommendation, 170); doc.text(splitRecommendation, 20, y += 7); y += (splitRecommendation.length * 5) + 5; doc.setFontSize(10); doc.setTextColor(107, 114, 128); const disclaimer = "Note: This model provides a simplified, conceptual estimate of sovereign debt default probability based on user inputs and assumed relationships. Actual sovereign default risk assessment is a highly complex process involving in-depth analysis of economic, political, and social factors, often employing sophisticated quantitative models and qualitative expert judgment. This tool should be used for illustrative purposes only and not as a substitute for professional financial or economic analysis."; const splitDisclaimer = doc.splitTextToSize(disclaimer, 170); doc.text(splitDisclaimer, 20, y += 15); doc.save('Sovereign_Debt_Default_Probability_Report.pdf'); }); // Initialize the first tab as active on load activateTab(0); checkTotalWeights(); // Initial check for weights });