NV Analytics Logo Noah Vachon

Retirement Model Lab

This project helps calculate the years until retirement based on savings rate and investment return.

Python Code


# Imports / Variables

## Imports

import numpy
import numpy_financial as np

## Variables

salary = 60000
savings_rate = [0.10, 0.25, 0.40]
investment_rate = [0.04, 0.05, 0.06]
desired_cash = 1500000
saved_cash = 0

## Calculations

for s_rate in savings_rate:
    annual_cash = salary * s_rate
    for i_rate in investment_rate:
        years_to_retirement = np.nper(i_rate,-annual_cash,saved_cash,desired_cash)
        print(f'Martha has {years_to_retirement:.1f} years to retirement if she earns a {i_rate:.0%} return and saves {s_rate:.0%}.')
            

Python Code Output


# Output of the calculation
Martha has 61.1 years to retirement if she earns a 4% return and saves 10%.
Martha has 53.3 years to retirement if she earns a 5% return and saves 10%.
Martha has 47.6 years to retirement if she earns a 6% return and saves 10%.
Martha has 41.0 years to retirement if she earns a 4% return and saves 25%.
Martha has 36.7 years to retirement if she earns a 5% return and saves 25%.
Martha has 33.4 years to retirement if she earns a 6% return and saves 25%.
Martha has 31.9 years to retirement if she earns a 4% return and saves 40%.
Martha has 29.0 years to retirement if she earns a 5% return and saves 40%.
Martha has 26.7 years to retirement if she earns a 6% return and saves 40%.
        

Other Python Projects

My Dynamic Salary Model

A salary over time retirement model

Retirement Model Lab

A years until retirement calculator

TVM Project

A Time Value of Money Manufacturing Project