Sub topic 12
Raising Contributions Each Year
This chapter assumes you can already compute a nest egg target and solve for a flat monthly contribution with monthly_saving. It also assumes you are comfortable with the future value of an annuity and with reading short Python functions. Here you replace the flat contribution with one that rises each year, and you check the result by simulation.
Why a flat contribution is a poor model of real saving
The flat formula assumes you pay the same amount in year 30 as in year 1. Most people's pay rises over a career, so a contribution fixed at your first-year amount will usually be a smaller share of income later.
Raising contributions each year has two effects:
- The starting payment can be much lower, because later payments carry more of the load.
- The total you pay in is higher, because the later, larger payments come with less time to compound.
You trade a lighter start for a heavier finish. That is the right trade only if your income really will grow.
The model
The model makes these assumptions:
- You contribute at the end of each month.
- The contribution is constant within a year.
- It rises by a fixed fraction
gat the start of each new year, so yeark(counting from 0) paysc * (1 + g)^kper month. - The annual return is split into a monthly rate
r = annual_return / 12.
The simulate function from the plan implements this directly. The raise applies when month % 12 == 0 and month > 0, so the first raise lands in month 13, after a full year at the starting amount.
def simulate(monthly, years, annual_return, balance=0.0, annual_raise=0.0):
"""Month-by-month balance with end-of-month contributions that rise once a year."""
r = annual_return / 12
for month in range(years * 12):
if month > 0 and month % 12 == 0:
monthly *= 1 + annual_raise
balance = balance * (1 + r) + monthly
return balanceSimulation answers "what happens if I pay this?" It does not answer "what should I pay?" For that you need a closed form, or a numeric search over the starting payment. A closed form exists, and it is worth deriving.
Deriving the starting payment
Let q = (1 + r)^12. This is the growth factor over one year. Within year k, the 12 payments of c(1 + g)^k are worth the following at the end of that year:
c * (1 + g)^k * FV12, where FV12 = ((1 + r)^12 - 1) / rFV12 is the future value of 12 end-of-month payments of 1. After year k ends, that lump keeps compounding for years - 1 - k more years. The total at retirement is therefore:
total = c * FV12 * sum over k = 0..years-1 of (1 + g)^k * q^(years - 1 - k)The sum is a geometric series with ratio (1 + g) / q. It simplifies to:
S = (q^years - (1 + g)^years) / (q - (1 + g))Setting total = gap gives c = gap / (FV12 * S). As in the flat case, gap is the target minus your existing balance grown to the retirement date.
def starting_monthly(target, years, annual_return, annual_raise,
current_balance=0.0):
"""Month-1 contribution that reaches target when contributions
rise by annual_raise at the start of each year after the first."""
n = years * 12
r = annual_return / 12
gap = max(target - current_balance * (1 + r) ** n, 0.0)
q = (1 + r) ** 12
fv12 = 12.0 if r == 0 else (q - 1) / r
if abs(q - (1 + annual_raise)) < 1e-12:
s = years * q ** (years - 1)
else:
s = (q ** years - (1 + annual_raise) ** years) / (q - (1 + annual_raise))
return gap / (fv12 * s)
if __name__ == "__main__":
target, years, ret = 1_000_000, 30, 0.06
flat = starting_monthly(target, years, ret, 0.0)
rising = starting_monthly(target, years, ret, 0.03)
print(f"flat: {flat:,.2f}")
print(f"rising: {rising:,.2f}")
print(simulate(flat, years, ret))
print(simulate(rising, years, ret, annual_raise=0.03))The if branch handles the special case where the annual raise exactly equals the annual growth factor minus one. The ratio is then 1 and the denominator would be zero. The series collapses to years * q^(years - 1).
def simulate(monthly, years, annual_return, balance=0.0, annual_raise=0.0):
r = annual_return / 12
for month in range(years * 12):
if month > 0 and month % 12 == 0:
monthly *= 1 + annual_raise
balance = balance * (1 + r) + monthly
return balanceRun both blocks in one file (put simulate above the if __name__ block). Both simulated balances should print as about 1,000,000. If they do not, the closed form and the simulation disagree on timing, and one of them has a bug.
A worked comparison
The target is 1,000,000 in future dollars, the horizon is 30 years, and the return is 6% a year (0.5% a month). There is no existing balance.
| Annual raise | Starting monthly payment | Final-year monthly payment |
|---|---|---|
| 0% (flat) | about 996 | about 996 |
| 2% | about 802 | about 1,420 |
| 3% | about 714 | about 1,683 |
| 5% | about 557 | about 2,330 |
A 3% raise cuts the starting payment by roughly 28%. Over 30 years, though, you pay in about 408,000 instead of about 358,000 for the flat plan. The extra 50,000 you pay is the price of the lower start.
Nominal raises and real raises
The raise rate interacts with the inflation assumption you already chose, and mixing the two is a common error.
- If your target is in future dollars and your return is nominal, the raise should be a nominal raise: what your paycheck, and so your contribution, actually grows by.
- If you work in today's dollars with a real return, use a real raise. A raise equal to inflation is a 0% real raise, and the contribution stays flat in purchasing-power terms.
Choosing a raise rate
Pick a raise you will actually be able to make. These are three sensible sources:
- Expected pay growth. If you expect 3% annual raises and will send the same fraction of pay to savings, use 3%.
- A fixed step. Many plans escalate the contribution rate by 1 percentage point each year until it reaches a cap. That is a rising percentage of pay, not a constant growth rate. The model here approximates it if you treat the step as a rough percent increase.
- Windfalls only. If you only raise contributions when you get a promotion, model a smaller steady raise and treat the promotions as upside.
Edge cases and common errors
- Wrong timing of the first raise. If your employer applies raises in January but you start in July, the first year is partial. The closed form assumes full 12-month years. Use
simulatefor irregular schedules. - Horizon not divisible by 12.
yearsis an integer here. For a fractional horizon, simulate month by month and search for the starting payment numerically. - Applying the raise to the balance. The raise applies to the contribution, not to the existing balance. Adding it to the balance's growth rate overstates the result.
- Raise larger than the return. This is allowed. The formula still works, and the denominator
q - (1 + g)is simply negative. Check that the output is positive. - Capped contributions. Accounts have annual limits. If the schedule would pass the limit, the closed form is invalid for the later years. Simulate with a cap, for example
monthly = min(monthly, cap / 12). - Comparing starting amounts across plans. A lower starting payment does not mean a cheaper plan. Always compare total contributions and the last-year payment as well.
Checking the model
A good habit is to confirm the special case. With annual_raise = 0, starting_monthly should match monthly_saving from the earlier chapter. Both are solving the same equation, and the series S collapses to years * q^(years - 1) in that limit only through the guarded branch.
flat_a = starting_monthly(1_000_000, 30, 0.06, 0.0)
# monthly_saving(1_000_000, 30, 0.06) from the previous chapter
# should return the same value to within rounding.
print(round(flat_a, 2))You can also test the formula against simulate across many inputs. If the two ever differ by more than a cent or two, you have an off-by-one in the timing of the first raise or the end-of-month convention.
Exercise
Using the example above (target 1,000,000, 30 years, 6% return), explain why a 5% annual raise gives a starting payment of about 557 but a total of far more than 358,000 paid in. What does this tell you about when the extra money is paid?
Show answer
The 5% raise grows the payment about 4.3 times over 29 raises (1.05^29 is about 4.1), so late payments are large. Those large payments come close to retirement and have little time to compound, so you must pay more in total to reach the same target. The low start is paid for by the heavy finish.
Exercise
Your plan assumes a 3% raise, but after 10 years you have only raised contributions by 1% a year. How would you find the new starting payment needed to still hit the target?
Show answer
Simulate the 10 years you actually paid to get your current balance. Then treat that balance as current_balance, set years to the remaining 20, and call starting_monthly with the raise you will now follow. The result is the payment for the next month, and later payments rise from it.