How the Decision tools emergency fund sizing calculator is verified

Inputs

InputFieldType
Monthly essential expensesmonthlyEssentialExpensesnumber
Current emergency savingscurrentSavingsnumber
Can save toward it each monthmonthlySavingsCapacitynumber
Income stabilityincomeStabilitystring
Dependentsdependentsinteger
I have income-protection or critical-illness insurancehasIncomeProtectionInsuranceboolean

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 valueFieldFormula (JSONata)
Recommended monthsrecommendedMonths$max([3 + (incomeStability = "variable" ? 2 : incomeStability = "freelance" ? 3 : 0) + $min([dependents, 3]) - (hasIncomeProtectionInsurance ? 1 : 0), 3])
Target fund sizetargetFundSize$round(monthlyEssentialExpenses * recommendedMonths, 2)
Current Coverage MonthscurrentCoverageMonths$round(monthlyEssentialExpenses > 0 ? currentSavings / monthlyEssentialExpenses : 0, 2)
Amount still neededshortfall$round($max([0, targetFundSize - currentSavings]), 2)
Months To TargetmonthsToTarget$round(shortfall <= 0 ? 0 : (monthlySavingsCapacity > 0 ? shortfall / monthlySavingsCapacity : -1), 1)
Percent fundedpercentFunded$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 monthlyEssentialExpenses2500
given currentSavings3000
given monthlySavingsCapacity500
given incomeStabilityfreelance
given dependents1
given hasIncomeProtectionInsuranceno
expect recommendedMonths7
expect targetFundSize17500
expect currentCoverageMonths1.2
expect shortfall14500
expect monthsToTarget29
expect percentFunded17.1

Case 2 — stable income, insured, no dependents, already over target — floor and cap both bind

given monthlyEssentialExpenses2000
given currentSavings8000
given monthlySavingsCapacity200
given incomeStabilitystable
given dependents0
given hasIncomeProtectionInsuranceyes
expect recommendedMonths3
expect targetFundSize6000
expect currentCoverageMonths4
expect shortfall0
expect monthsToTarget0
expect percentFunded100

Case 3 — freelancer with several dependents starting from zero savings — the worst-case shape

given monthlyEssentialExpenses3000
given currentSavings0
given monthlySavingsCapacity300
given incomeStabilityfreelance
given dependents5
given hasIncomeProtectionInsuranceno
expect recommendedMonths9
expect targetFundSize27000
expect currentCoverageMonths0
expect shortfall27000
expect monthsToTarget90
expect percentFunded0

Case 4 — zero saving capacity with a real shortfall — the gap cannot close, monthsToTarget is the -1 sentinel rather than a false 0

given monthlyEssentialExpenses2000
given currentSavings1000
given monthlySavingsCapacity0
given incomeStabilitystable
given dependents0
given hasIncomeProtectionInsuranceno
expect recommendedMonths3
expect targetFundSize6000
expect shortfall5000
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.