# generate one time path
x <- rnorm(1, mean = 0.001, sd = 0.015)
y <- c(1000, 1000*exp(cumsum(x)))
plot(1:2, y, type = "l", xaxt = "n", yaxt = "n", ylim = c(900, 1100), ylab = "", xlab ="") # may have to adjust ylim to see paths completely
# generate another time path, superimpose on same graph
par(new = TRUE)
x <- rnorm(1, mean = 0.001, sd = 0.015)
y <- c(1000, 1000*exp(cumsum(x)))
plot(1:2, y, type = "l", xaxt = "n", yaxt = "n", ylim = c(900, 1100), ylab = "", xlab ="") # may have to adjust ylim to see paths completely7 Worksheet 07: Prying open our imperfect model, Part 4
Before proceeding, make sure that you have finished the preceding worksheets.
In the previous worksheet, you used a model to determine future behavior of asset returns or asset prices. You have seen how indispensable simulation methods can be once we depart from normality, while preserving independence and identical distribution. You have also tried to make sense of why many claim that stocks could be a good long-term investment.
In this worksheet, you will be exploring further modifications of our baseline setup of log returns being IID normal. So far, you have seen what could happen if you change normality to a discrete distribution as in Section 6.9. This distribution may not be the most realistic but it can account for inactive trading activity, similar to what you may have seen for some Philippine stocks. By now, you should also be painfully aware of how much convenience the IID normality assumption can provide.
Reiterating what was mentioned in the previous worksheets: We are prying open bits and pieces of a model of asset returns because it is an important step toward building in reflection as part of the model-building process.
7.1 Focusing on prices rather than on returns
In previous worksheets, we have mostly focused on log returns, even though the exercises you encountered so far involve what prices could look like in the future. You are now going to work on some lines of R code so that you can visualize alternative price paths via simulation and how imagining a lot of alternative price oaths enables you to make decisions about what to do with investments with uncertain outcomes.
7.2 Exercise A
Consider the following lines of R code. These lines of code use information from Section 5.13. Before running the lines of code, figure out first what these lines are doing. It is a good way to review what you have learned in the previous worksheets.
- What do lines 2 and 3 represent? How are they related to the time path of prices? How many time periods are there?
- Run lines 2 to 4 so that you can visualize one time path of prices.
- To see another price path, run lines 6 to 9. Repeated run lines 6 to 9 to see even more additional price paths.
- Revisit Section 5.13. Propose a way to find the desired probability by examining the visualization of multiple price paths.
- Modify the lines of R code so that you can simulate price paths over 5 trading days. Propose a way to find the probability that after five trading days your investment is worth less than \(\$990\) by examining the visualization of multiple price paths. What if you hold for a year? Note that you might need to adjust the
ylimsettings in the code to have a better visualization.
7.3 Exercise B
Based on the previous exercise, we could have collected simulated price paths, and check whether a particular event occurs, and compute an estimate of the probability that event. Consider the following lines of R code, based on the conditions of Section 5.13.
price.path <- function(init, ntd, mean.lret, sd.lret)
{
c(init, init*exp(cumsum(rnorm(ntd, mean = mean.lret, sd = sd.lret))))
}
collection <- replicate(10^4, price.path(1000, 5, 0.001, 0.015))
mean(collection[6, ] < 990)Here we created a user-defined function which take on arguments. These arguments are the inputs necessary to produce one simulated price path obeying the conditions of Section 5.13.
- Explain what is the output of the function
price.path(). - What do you expect
collectionto contain? How many entries do you expect to see? - What do you expect
collection[6,]to contain? How many entries do you expect to see? - What does
mean(collection[6, ] < 990)estimate?
7.4 What if the information about the distribution is incomplete?
So far, we have considered exercises where the distribution of log returns is completely specified. For example, both the mean and standard deviation of the distribution of log returns are given to you. Another example is when all the possible log returns along with their associated probabilities were completely given to you. What if some aspect is missing?
Let us consider Problem 16 of Ruppert and Matteson (2015).
Assume that McDonald’s log returns are normally distributed with mean and standard deviation equal to their estimates and that you have been made the following proposition by a friend: If at any point within the next 20 trading days, the price of McDonald’s falls below 85 dollars, you will be paid \(\$100\), but if it does not, you have to pay him \(\$1\). The current price of McDonald’s is at the end of the sample data, \(\$93.07\). Are you willing to make the bet?
Now, let us consider Problem 4 of Ruppert and Matteson (2015).
Suppose a hedge fund owns \(\$1,000,000\) of stock and used \(\$50,000\) of its own capital and \(\$950,000\) in borrowed money for the purchase. Suppose that if the value of the stock falls below \(\$950,000\) at the end of any trading day, then the hedge fund will sell all the stock and repay the loan. This will wipe out its \(\$50,000\) investment. The hedge fund is said to be leveraged 20:1 since its position is 20 times the amount of its own capital invested. What is the probability that the value of the stock will be below \(\$950,000\) at the close of at least one of the next 45 trading days?
7.5 Exercise C
Compare both Problems 16 and 4 described earlier to Section 5.13. Focus on the distribution of log returns.
- Specify the similarities and differences, especially when it comes to simulating log returns. What information seems to be missing which prevents you from simulating log returns?
- For Problem 16, what information would you need to be able to even begin solving the problem?
- For Problem 4, is the information you anticipated to be given in the “correct form”? Consult Section 6.4 for more. What assumptions were needed for you to be at a point where you can simulate log returns?
7.6 What if you have a different investment criterion?
So far, we have considered exercises where we are interested in the final outcome of an investment after a specified number of trading days. What if we are interested in what happens to the investment during the holding period?
7.7 Exercise D
Compare both Problems 16 and 4 described earlier to Section 5.13. Focus on the event is of interest.
- Was the event about the final outcome of the investment after holding the stock for some period of time?
- If you are going to check if the event of interest happened, how would you check it if you see a price path?
7.8 Exercise E
Consider the following lines of R code modified from the answer key of Ruppert and Matteson (2015). This is the code used to solve Problem 16. I have supplied the historical average and historical standard deviation of daily log returns of McDonald’s stock using data from 2010-01-04 to 2014-09-05.
Explain what every line of code is meant to do.
- The most critical lines which rely on previous worksheets would be lines 5 and 6. What output do you expect to see from these lines?
- What does line 7 have to do with the event of interest in Problem 16? What values do you expect
indto have? - Why would
value[i]involvei? What is the purpose of this step?
To determine whether you should accept the bet, there are many ways to proceed:
- How often do would you win \(\$100\)?
- How large is you average bet outcome?
- How risky is the bet, especially given the possible outcomes?
Modify the lines of code so that you can produce the probability that at any point within the next 20 trading days, the price of McDonald’s falls below 85 dollars.
Modify the lines of R code so that you can solve Problem 4.
Adapt the lines of R code in Section 7.3 to the setting of Problems 16 and 4.
Create a new version of this problem with more updated data. You may have to update the figures accordingly. Formulate bets which could be acceptable or unacceptable.