How the Decision tools emergency fund sizing calculator is verified
Inputs
| Input | Field | Type |
|---|---|---|
| Monthly essential expenses | monthlyEssentialExpenses | number |
| Current emergency savings | currentSavings | number |
| Can save toward it each month | monthlySavingsCapacity | number |
| Income stability | incomeStability | string |
| Dependents | dependents | integer |
| I have income-protection or critical-illness insurance | hasIncomeProtectionInsurance | boolean |
The formula
Each derived value below is computed by the Valem engine from the expression shown, in this order. Nothing else runs — there is no hidden code path.
| Derived value | Field | Formula (JSONata) |
|---|---|---|
| Recommended months | recommendedMonths | $max([3 + (incomeStability = "variable" ? 2 : incomeStability = "freelance" ? 3 : 0) + $min([dependents, 3]) - (hasIncomeProtectionInsurance ? 1 : 0), 3]) |
| Target fund size | targetFundSize | $round(monthlyEssentialExpenses * recommendedMonths, 2) |
| Current Coverage Months | currentCoverageMonths | $round(monthlyEssentialExpenses > 0 ? currentSavings / monthlyEssentialExpenses : 0, 2) |
| Amount still needed | shortfall | $round($max([0, targetFundSize - currentSavings]), 2) |
| Months To Target | monthsToTarget | $round(shortfall <= 0 ? 0 : (monthlySavingsCapacity > 0 ? shortfall / monthlySavingsCapacity : -1), 1) |
| Percent funded | percentFunded | $round(targetFundSize > 0 ? $min([100, currentSavings / targetFundSize * 100]) : 0, 1) |
Test vectors (4)
Every case is executed against this model on each build, by the Java engine and independently by a JavaScript one. A mismatch of a single cent fails the build, so the page cannot ship advertising a figure the model no longer produces.
Case 1 — freelancer with a dependent, partially funded — the baseline scenario
given monthlyEssentialExpenses | 2500 |
|---|---|
given currentSavings | 3000 |
given monthlySavingsCapacity | 500 |
given incomeStability | freelance |
given dependents | 1 |
given hasIncomeProtectionInsurance | no |
expect recommendedMonths | 7 |
expect targetFundSize | 17500 |
expect currentCoverageMonths | 1.2 |
expect shortfall | 14500 |
expect monthsToTarget | 29 |
expect percentFunded | 17.1 |
Case 2 — stable income, insured, no dependents, already over target — floor and cap both bind
given monthlyEssentialExpenses | 2000 |
|---|---|
given currentSavings | 8000 |
given monthlySavingsCapacity | 200 |
given incomeStability | stable |
given dependents | 0 |
given hasIncomeProtectionInsurance | yes |
expect recommendedMonths | 3 |
expect targetFundSize | 6000 |
expect currentCoverageMonths | 4 |
expect shortfall | 0 |
expect monthsToTarget | 0 |
expect percentFunded | 100 |
Case 3 — freelancer with several dependents starting from zero savings — the worst-case shape
given monthlyEssentialExpenses | 3000 |
|---|---|
given currentSavings | 0 |
given monthlySavingsCapacity | 300 |
given incomeStability | freelance |
given dependents | 5 |
given hasIncomeProtectionInsurance | no |
expect recommendedMonths | 9 |
expect targetFundSize | 27000 |
expect currentCoverageMonths | 0 |
expect shortfall | 27000 |
expect monthsToTarget | 90 |
expect percentFunded | 0 |
Case 4 — zero saving capacity with a real shortfall — the gap cannot close, monthsToTarget is the -1 sentinel rather than a false 0
given monthlyEssentialExpenses | 2000 |
|---|---|
given currentSavings | 1000 |
given monthlySavingsCapacity | 0 |
given incomeStability | stable |
given dependents | 0 |
given hasIncomeProtectionInsurance | no |
expect recommendedMonths | 3 |
expect targetFundSize | 6000 |
expect shortfall | 5000 |
expect monthsToTarget | -1 |
Sources
Check it yourself — and reuse it
The whole model as JSON — inputs, outputs, formulas, vectors and sources in one re-runnable document.
This model is published under CC BY 4.0: use it, adapt it, build on it, with attribution. The licence covers the model — the expression of each rule and the arrangement of the catalog. The rates and thresholds are law, and nobody licenses those; the sources above are where they come from.
← Back to the Decision tools emergency fund sizing calculator
Built with Valem — a live, verifiable calculator you can fork and embed.