Homework #2: Financial Modeling

This notebook contains the second homework for this class, and is due on Friday, February 19th, 2016 at 5:00 p.m.. Please make sure to get started early, and come by the instructors' office hours if you have any questions. Office hours and locations can be found in the course syllabus. IMPORTANT: While it's fine if you talk to other people in class about this homework - and in fact we encourage it! - you are responsible for creating the solutions for this homework on your own, and each student must submit their own homework assignment.

Some links that you may find helpful:

Your name

Put your name here!


Some background: Investing basics.

Investing in the stock market can produce tremendous gains over time -- somewhere in the range of 8-10% annual returns on average (see this link for a graph of this trend). However, there is also tremendous volatility in the stock market (i.e., huge change in stock prices), with huge market swings over time. This has happened several times over the past 40 years; see the Google Stock Ticker for the S&P 500 for the behavior of the stock market from 1975 through today. The opportunity for huge financial return compared to a savings account is why many people invest much of their money for retirement in the stock exchange; however, the huge volatility and varied rate of return can profoundly affect returns, and in the worst case scenario can completely wipe out peoples' investments and keep them from retiring.

To help deal with this risk to their retirement savings, investors often put some of their money stocks and the rest in investments such as bonds, which are safer than stocks - in other words, they have a much lower risk of going down in value than a stock would. However, they also have much lower rates of return, meaning that their value is much less likely to go up substantially compared to stocks. Depending on an individual investor's ability to tolerate uncertainty, they may choose different ratios of stocks to bonds, and stocks with varied amounts of risk - riskier stocks can both make more money and lose more money!

An additional concern when investing is inflation - the tendency in the price of goods and services to go up over time. This gradual increase in cost means that, over time, a dollar buys less and less. In the United States over the past 50 years, inflation has hovered around 2% per year, although with significant swings (see this chart for more information). As a result, investments with rates of return lower than inflation are typically not a smart choice if you're trying to increase the amount of money available to you for retirement!


Section 1 - A simple model for investment

In this section, we're going to make a simple model of the investment returns of an individual who is saving for retirement. This model assumes that they put money into their investment portfolio at a constant rate, and that their stock portfolio grows at a constant rate. Our assumptions are:

  1. This investor starts saving for retirement at age 25, and plans to retire at age 65.
  2. When they are 25 they have a salary of \$50,000/year and invest either 5% or 10% of their salary in their retirement account each year. (We will call these the "low investment" and "high investment" options.)
  3. Their salary goes up 3% a year until they retire at age 65, meaning that they contribute 3% more to their retirement account each year (in other words, the investor contributes a fixed percentage of their salary to their retirement account each year).
  4. Inflation is a constant 2% a year, meaning that the effective purchasing power of their money goes down 2% each year compared to what you can buy today.
  5. Their investments grow at a steady rate of 5%, 8%, or 11% per year (low, medium, or high growth rate)
  6. When they retire, they will be able to spend 5% of their retirement account each year.

Using these assumptions, make a simple program to calculate (A) how much money will be in their retirement account every year from age 25 through 65 for all six possible options (low vs. high investment, and low/medium/high growth rate of the stock market); (B) how much inflation decreases the effective value of their investment each year; and, (C) how much money will be available to this person per year when they retire, in today's dollars (in other words, taking into account how inflation changes the purchasing power of their savings). Show all of this information in three ways:

  1. By printing out a table showing how investments and inflation grow over time.
  2. With a plot that shows the size of their investment portfolio with their age, with line colors and types chosen so that one can tell the difference between the six options.
  3. By creating a markdown cell explaining how much money is available to this person per year when they retire, in today's dollars, for each of the six scenarios.

Some coding hints to get you started:

Hint 1: You can create an empty list by typing my_list = [], and can append items to that list with my_list.append(val), where val is a number or string.

Hint 2: You can append an element to the end of a numpy array using the append method, though the syntax is different. For example: my_array = np.append(my_array,13.0) will append the number 13 to the end of the numpy array my_array.

Hint 3: You can create functions that take lists, arrays, and other types of variables as inputs, and also returns several variables (even of different types). For example:

def example_func(my_list, my_array):
    my_list.append(2)
    my_array ** 2
    return my_list, my_array

will take a list and an array as an input, and return a new list and array that are modified versions of the originals. For example:

new_list, new_array = example_func(my_old_list, my_old_array)

will return new_list and new_array, which are modified versions of my_old_list and my_old_array.

It is important to know that if you modify a list or an array within a function, it will stay modified after you call the function even if you don't return it explicitly! (So, in the example above, both my_old_list and my_old_array will be changed.)

If you want to actually copy the list or an array and only modify the copies, you have to use new_list = list(old_list) for lists, and new_array = np.copy(old_array) for numpy arrays.


In [ ]:
# put your code for Section 1 here, adding additional cells right below this as necessary!

Some questions about this model:

  1. How big of a difference in money available at retirement does a relatively small difference in return rate (5% vs. 8% vs 11%) make? What about their savings rate (5% vs. 10%)?
  2. If you change the age that the investor starts investing, how does that affect their available income when they retire at age 65? (Try the ages of 20, 25, 30, and 35 and compare the differences in a table for a couple of the scenarios -- you can use the Mastering Markdown tutorial to see how to make tables.)
  3. More generally, what can you conclude about investing for retirement based on the model you've created here?

Put your answers here!

Section 2 - A slightly more complex model calculating investment returns

As you saw in the links above, the return from the stock market and the inflation rate both change significantly from year to year, as do the raises that people tend to get. This can result in substantial differences in investment return compared to the simple model in the previous section.

You're now going to improve upon your previous model by introducing one element of randomness into the modeling process: namely, the rate of return of their investments. We'll keep all of the assumptions from the previous section except #5. In this version of the model, the investment portfolio now fluctuates in growth every year, and the amount depends on the risk the investor chooses to take. The low growth rate/low risk version fluctuates between 2%-8%; the medium growth rate/medium risk version fluctuates between 3% and 13% each year; and the high growth rate/high risk version fluctuates between 1% and 21% each year. (Assume that the return in any given year is totally random, and varies linearly between the maximum and minimum number give.) The investor's yearly raises and inflation rate will stay constant.

Given that there is quite a bit of randomness, it's important to run each of the six investment scenarios (low vs. high investment fraction, low/medium/high growth/risk rate) many times to get a sense of the range of possible outcomes. We're going to explore this in several ways:

  • First, calculate the growth of savings for one possible outcome of each of the six scenarios and put them all together on a single plot.
  • Second, consider the two extreme scenarios - the low investment/low risk rate scenario and the high investment/high risk rate scenario. Run each of these scenarios at least 100 times and create a list or array that contains only one piece of information from each run - the amount of money is available to the investor to spend per year when they retire, in today's dollars - and show a histogram of those amounts. (You can either put both scenarios on one histogram with different colors, or use two separate ones.)

In [ ]:
# put your code for section 2 here, adding additional cells as necessary!

Question: How the outcomes for this model different, both qualitatively and quantitatively, than the model in section 1?

Write your answer here!

Section 3 - An even better model for calculating investment returns

In this section, we're going to build upon what you did in Section 2 and introduce some additional elements of randomness into our model to make it more realistic and to see how that affects the outcomes. We will keep assumptions #1, 2, and 6 from the first section the same, but we'll change the others as follows:

  • The investor's salary now goes up by some random amount between 1-5% each year (varying linearly between 1-5%).
  • Inflation is between 0% and 4% in any given year (varying linearly between 0-4%)
  • Their investment portfolio fluctuates in growth every year as described in Section 2.

Given that there is quite a bit of randomness, it's important to run each of the six investment scenarios (low vs. high investment fraction, low/medium/high growth/risk rate) many times to get a sense of the range of possible outcomes. We're going to explore this in several ways:

  • First, calculate the growth of savings for one possible outcome of each of the six scenarios and put them all together on a single plot. In a markdown cell below, explain how this is different than the plot you made in the previous section!
  • Second, consider the two extreme scenarios - the low investment/low risk rate scenario and the high investment/high risk rate scenario. Run each of these scenarios at least 100 times and create a list or array that contains only one piece of information from each run - the amount of money is available to the investor to spend per year when they retire, in today's dollars - and show a histogram of those amounts. (You can either put both scenarios on one histogram with different colors, or use two separate ones.)
  • Optionally do the same as in the previous section, but for all of the six investment scenarios.

In [ ]:
# put your code for section 3 here, adding additional cells as necessary!

Question: Think about the information that you get from the model in this section compared to both the original model in Section 1 and the somewhat more advanced model in Section 2. What parts of the models agree and disagree? What additional information do you get from this model? How does it differ from Section 2's model?

Write your answer here!

Question: Also, think about other information that you can get from this model. What can it tell you about how an investment portfolio might behave? And, if you were an investment advisor, how would you use these models to give your clients advice?

Write your answer here!

Question: Looking at the graphs of inflation and the stock market, and thinking about peoples' careers and savings habits, how might you improve your model to more accurately reflect the possible outcomes for an investor?

Write your answer here!


Section 3: Feedback (required!)

How long did you spend on the homework?

Write your answer here

What questions do you have after this assignment?

Write your answer here


Congratulations, you're done!

How to submit this assignment

Log into the course Desire2Learn website (d2l.msu.edu) and go to the "Homework assignments" folder. There will be a dropbox labeled "Homework 2". Upload this notebook there.