et <- rnorm(10)
yt <- 1+2*(1:10)+et
plot(yt, type = "l")
curve(1+2*x, from = 1, to = 10, add = TRUE, lty = 2, col = "red")8 Worksheet 08: Digging into the underlying time series concepts, Part 1
Before proceeding, make sure that you have finished the preceding worksheets.
If you reached this stage of the workbook, that means you have reviewed enough probability theory, got introduced to financial modeling, and have been used to designing simulations in R. All the knowledge, skills, and attitudes embedded in the previous worksheets are meant for you to see the applications first with a small dash of theory.
In the next worksheets, you will discover how to start modifying the underlying financial model explored in the worksheets to account for violations of the IID normality assumption on the distribution of log returns.
You have already ventured into removing the normality assumption in Section 6.8, but this requires us to think of an alternative distribution for log returns. In addition, we have to somehow motivate the specification of such alternative distribution. I just invented the distribution specified in Section 6.8, but I wished to capture the relatively low frequency of movements in stock prices commonly seen in the Philippines. But the other possible log returns seem to unrealistic and extreme. There is definitely a lot of improvement which could be done so that we could match what we observe for the Philippines.
8.1 Violations of the identical distribution assumption
Unfortunately, such strong and precise information about the distribution may not be forthcoming and we may ultimately rely on historical information instead. We will explore this aspect in a future worksheet or as part of a project.
How about removing the assumption of identical distribution for log returns? This turns out to be even more difficult because if we do not have complete knowledge of the specification of the distribution of log returns even under the identical distribution assumption, how can we even have a complete specification in the case where we don’t have the identical distribution assumption?
8.2 Exercise A
It does not have to be the case that log returns for every trading period will have a different distribution. Perhaps before we move on from discussing violations of the identical distribution assumption, can you think of situations where a violation of identical distribution assumption only occurs temporarily? Or perhaps where it becomes permanent after a particular point in time? Try to provide specific and concrete examples in the context of stock returns of companies.
8.3 Violations of the independence assumption
In Chapter 4, you have worked on the independence assumption and its potential violations. But the work has been on verifying whether independence is violated or not with full knowledge of the joint distribution of two random variables.
For our model of stock returns, we assumed that log returns were independently distributed across trading periods. That means we are not considering only a pair of random variables. We now have more than two random variables to think about.
To begin thinking about how exactly to encode violations of independence for distributions, continue with the next exercise.
8.4 Exercise B
Revisit Section 4.9.
- Can you fill the entries marked “?” if you want \(X\) and \(Y\) to be dependent but have identical distributions? If you can, share with a classmate how you were able to create a desired distribution? If you cannot, discuss with a classmate what additional information you may need in order to create a desired distribution?
- Would it help if we change the question to “Can you fill the entries marked”?” if you want \(X\) and \(Y\) to be dependent and non-identical distributions?” Discuss.
8.5 Exercise C
Revisit Section 4.8. You should be able to show that \(X\) and \(Y\) are not independent and do not have identical distributions. But do you know how to simulate draws from this joint distribution? In other words, you will be drawing pairs of values of \(X\) and \(Y\) satisfying the given distribution.
- What is the marginal distribution of \(X\)? Do you know how to draw random numbers from this marginal distribution?
- Because \(X\) and \(Y\) are dependent, the conditional distribution of \(Y\) given \(X=x\) will be different for every possible outcome \(x\). Compute all these conditional distributions. How many would there be?
- If you knew which value \(x\) was drawn in item a, would you know how to draw random numbers from the conditional distribution of \(Y\)? Write down the lines of R code for you to do this.
- Refine the lines of R code to reflect the fact that you have to generate draws for \(Y\) depends on what was drawn for \(X\). You may want to look into how to use the
ifelse(). To get a feel for the command, I suggest Lesson 20 of fasteR. - To start testing your lines of code, explore drawing one pair of random numbers from the joint distribution of \(X\) and \(Y\). You can then repeatedly draw pairs of random numbers until you have a large number of draws. How do you check whether your random pairs really came from the given joint distribution? You may have to explore how to use
table()here.
8.6 Exercise D
Revisit Section 4.8 and the previous exercise. Think of \(X\) as a random variable representing the log return for the first trading period (call this \(r_1\)) and \(Y\) as a random variable representing the log return for the second trading period (call this \(r_2\)).
If you have done the previous exercise, then you would have known how to draw from the joint distribution of \(r_1\) and \(r_2\) and these two random variables are dependent and they even have non-identical distributions! Because we are moving forward in time as we look toward the future, we have to have a record of the past history. In addition, we needed to start with how to generate log returns for the first trading period, and then followed by how to generate log returns for the second trading period given what you have observed in the past (which was the value drawn for the first trading period).
Now think about what happens when there is another trading period, so that this time you are thinking about the joint distribution of \(r_1,r_2, r_3\), where the latter is the distribution of log returns for the third trading period.
- If we have independence of \(r_1\), \(r_2\), and \(r_3\), would generating random triples be straightforward? Explain.
- If we want to allow for dependence, how would you generate random triples? Extend the idea from the case of only two trading periods.
- What if there are four trading periods? Discuss what difficulties you will encounter as you try to generate paths of future returns (hence, prices). How much information and how much more lines of R code (with what you have so far) would be needed to even generate a random quartet?
8.7 Exercise E
Revisit Section 8.5. Can you start drawing from the marginal distribution of \(Y\) first and then draw next from the conditional distribution of \(X\) given \(Y\)? Write lines of R code which will achieve this goal.
8.8 Building the relevant concepts
For our financial context, we need to account for the dependence of log returns across different trading periods. But because we are simulating future returns, we somehow want the future to be similar to the past. Otherwise, it would be difficult to specify what the future would look like. Therefore, we need a concept which allows dependence and at the same time allows for some form of “stability” over time.
We now introduce the concept of stationarity. Refer to Section 11-1a of Wooldridge (2020) for what follows. You will be making sense of a rather abstract definition.
8.9 Exercise F
Note that in Wooldridge (2020) random variables are not capitalized, which is a bit different from your past experiences. Make sure you understand the difference between random variables, their possible outcomes, and their observed realizations.
How is stationarity defined in Wooldridge (2020)?
Make sure you can understand the definition by first understanding the notation.
- What does \(m\) represent? What values can it take?
- What do \(t_1, \ldots, t_m\) represent? Can they take on any value? Are there restrictions on the values these indices could take? Can you give an example?
- What does \(h\) represent? What values can it take?
- What do the \(x\)’s represent? For example, what does \(x_{t_1}\) mean? Is it a random variable?
- Does the definition tell you what the joint distribution of \(\left(x_{t_1},\ldots, x_{t_m}\right)\) looks like?
- Let’s say you have a stationary stochastic process. Set \(m=1\), \(h=1\), and \(t_1=1\). Apply the definition of stationarity to determine which random variables have the same distribution?
- Can you come to the conclusion that \(x_1,x_2, \ldots\) are identically distributed? To answer how and why, make sure you set the values for \(m\), \(h\), and \(t_1\).
- But stationarity is even more stringent than identically distributed. Set \(m=2\), \(h=1\), and \(t_1=1\). Which pairs of random variables now have the same distribution? Can you generalize this further?
- If you have a stationary stochastic process, can you conclude that the random vector \(\left(x_1,x_2,x_5\right)\) and \(\left(x_3,x_4,x_8\right)\) have the same joint distribution? Show why or why not.
- Revisit the paragraph in Section 11-1a starting with “This definition is a little abstract”. Can you now make sense of what is written in the book now?
- Based on Section 2.3 where you collected data on returns, do you think returns look like they were generated by a stationary stochastic process? How about stock prices?
How is nonstationarity defined in Wooldridge (2020)?
8.10 Exercise G
The stationarity concept explored int he previous exercise is technically called strict stationarity. There is another concept called covariance stationarity. Refer to the paragraph where covariance stationarity is being discussed in Wooldridge (2020).
What are the common features between the definitions of strict stationarity and covariance stationarity? What are the differences?
The definition of covariance stationarity include the finite second moment \(\mathrm{E}\left(x_t^2\right)<\infty\). This is a technical requirement because it is possible for distributions to have infinite variance. An example is the Cauchy distribution.
- Read up on the
rcauchy()command and draw independently 10000 random numbers from the Cauchy distribution. Feel free to use the default settingslocation = 0andscale = 1. Store the draws into an objectx. - Find the sample average of the draws using the relevant R commands.
- Repeat the previous two items. Do you notice something about the sample averages? Repeat a few more times to convince yourself of the resulting pattern (or lack thereof) for the sample averages. You can also compute the sample variance for every set of 10000 random draws you have.
- How does your finding in the previous item affect the existence of a population mean and a population variance?
- Read up on the
What are the requirements for covariance stationarity?
Can you express the reason why “It follows immediately that the correlation between \(x_t\) and \(x_{t+h}\) also depends only on \(h\).”?
Refer to Problem 1 of Chapter 11 of Wooldridge (2020). Use the definition of the (population) correlation coefficient found in Appendix Equation (B.29) to come to the conclusion that under stationarity, the correlation coefficient between \(x_t\) and \(x_{t+h}\) is the ratio of \(\gamma_h=\mathsf{Cov}\left(x_t,x_{t+h}\right)\) and \(\gamma_0=\mathsf{Var}\left(x_t\right)\).
8.11 Exercise H
Consider the exercise found in Going Further 11.1. This is an example of a time series model with a linear time trend.
To explore what data from a time series model with a linear time trend would look like, consider the following lines of R code:
What is \(\mathrm{E}\left(y_1\right)\)? \(\mathrm{E}\left(y_2\right)\)? What is \(\mathrm{E}\left(y_t\right)\)for every \(t\)?
Can you articulate what each line is trying to do? How is the code reflective of a time series model with a linear time trend? Specifically, what are \(\delta_0\), \(\delta_1\), and the specification for the IID sequence \(\{e_t:\ t=1,2,\ldots\}\)?
Run the lines of R code multiple times. Notice what changes and what stays the same. How can you find \(e_t\) in the graph? Where is \(y_t\)? Where is \(\mathrm{E}\left(y_t\right)\)?
Change all the
10’s into100’s. Repeatedly draw new simulated data to get a feel for what the linear time trend model is all about. Do you think this could be a good model for stock prices you have seen so far? Explain.Now you are in a position to completely answer the exercises in Going Further 11.1. Do this.
8.12 A technical matter
Stationarity is different from independence, in the same way that independence and identical distribution are two separate concepts.
When we assume finite second moments (meaning again, that the population variance exists), then any strictly stationary process is automatically covariance stationary. If we do not have the finite second moments assumption, then strict stationarity is not necessarily stronger than covariance stationarity.