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:
Put your name here!
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!
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:
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:
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:
Put your answers here!
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:
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!
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:
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:
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!
Write your answer here
Write your answer here