Exam Solutions Please put your answers on these pages. Write very carefully and legibly. HIT Shenzhen Graduate School James E. Gentle, 2015 1. 3 points. There was a transcription error on the registrar s copy of the exam. I could not grade the full question. The model on the registrar s exam was X t = µ + β t + A t, Consider the time series model where {A t } is a white noise process. X t = µ + βt + A t, (a) Why is the {X t } process not stationary? (What property is violated?) The process is not stationary because the mean, µ + βt, is not constant. (b) Using the {X t } process, form a process {Y t } that is stationary. Y t = X t X t 1 (c) Determine the ACF of your {Y t } process. (Get γ Y (h) first; then get ρ Y (h).) The mean of this process is constant, β: E(X t X t 1 ) = µ+βt+a t µ+β(t 1)+A t 1 = β. Hence, γ Y (h) = E(Y t β)(y t h β) = E(Y t Y t h ) β 2 = E(β + A t A t 1 )(β + A t h A t h 1 ) β 2 2σA 2 h = 0 = σa 2 h = ±1 0 h > 1 (d) Instead of the model for X t above, suppose the model is W t = µ + β 1 t + β 2 t 2 + A t. How could you form a stationary process {Z t } from {W t } Form second order lag-1 differences: Z t = (X t X t 1 ) (X t 1 X t 2 ). 1
2. 18 points. Consider the time series model R t = µ + φr t 1 + A t, where {A t } is a white noise process, with variance σ 2 A. Assume the {R t} process is weakly stationary. (a) What is the mean of the {R t } process? The mean is E(R t ) = E(µ + φr t 1 + A t ) = µ + φe(r t 1 ), but it is the case that E(R t ) = E(R t 1 ), so E(R t ) = µ 1 φ (b) What is the variance of the {R t } process? For the variance, we follow the same steps as above: V(R t ) = V(µ + φr t 1 + A t ) = φ 2 V(R t 1 ) + V(A t ) = φ 2 V(R t 1 ) + σa 2, but it is the case that V(R t ) = V(R t 1 ), so V(R t ) = σ2 A 1 φ 2 (c) Based on your work above, what is a requirement on φ in order for the {R t } process to be stationary? (This is a necessary condition; it may not be sufficient.) For the mean to be constant and finite, it must be the case that φ 1, and for the variance to be positive, it must be the case that φ < 1. (d) The condition in the previous question is very important in analyzing a time series that follows an autoregressive process. In practice, we may have a time series from some process, but of course, we do not know what model it follows. What statistical test could be used to decide whether this condition applies? (You can describe the test or you can just give the name of a test.) This is a test for a unit root. The most commonly-used one is the augmented Dickey-Fuller test. (e) Determine the ACF of the {R t } process. (Although there are different ways of addressing the question of stationarity that is, we do not have to assume it we will continue as above, and assume the process is stationary. This means that we can consider ρ R (h) instead of ρ R (r, s).) Get γ R (h) and then get ρ R (h). The mean of this process is constant, as we have seen above. Let α represent the mean (i.e., α = µ/(1 φ)). The key idea is to derive a recursive relationship. γ R (h) = E(R t α)(r t h α) = E ((φ(r t 1 α) + A t )(φ(r t h 1 α) + A t h )) { φγr (1) + σ = A 2 h = 0 φγ R (h 1) h 1 We get the ACF by dividing by the variance. But notice first that we still just have a recursion relationship. We work with this recursion on the ACF to see that a general expression for the ACF is { 1 h = 0 ρ R (h) = φ h h 1 2
(f) At time t, consider the best forecast (or predicted value) for {R t+1 }. Call this ˆR t (1). i. Write the expression for ˆR t (1). Answer: ˆRt (1) = µ + φr t ii. Write the expression for error of ˆR t (1). Answer: e t = R t+1 ˆR t (1) = A t+1 iii. What is the variance of the error of ˆR t (1). This is just the variance of A t+1, which is σ 2 A 3
3. 16 points. Consider the time series model U t = µ + θa t 1 + A t, where {A t } is a white noise process, with variance σ 2 A. (a) What is the mean of the {U t } process? The mean is E(U t ) = E(µ) + θe(a t 1 ) + E(A t ) = µ. (b) What is the variance of the {U t } process? The variance is V(U t ) = V(µ) + θ 2 V(A t 1 ) + V(A t ) = (θ 2 + 1)σA 2. (c) Determine the ACF of the {U t } process. (Get γ U (r, s) first, because you do not know that it is stationary.) Give the expression for different values of r and s. At this point, you can say the process is stationary. Then get ρ U (h).) First of all, we notice that the constant mean is irrelevant for the autocovariance, so we will just let µ = 0. Now, we consider U t U t h = U t h A t + θu t h A t 1. All we have to do is take its expectation: E(U t h A t + θu t h A t 1 ). We get (θ 2 + 1)σA 2 h = 0 γ U (h) = θσa 2 h = 1 0 h > 1 So 1 h = 0 θ ρ U (h) = 1+θ h = 1 2 0 h > 1 (d) At time t, consider the best forecast (or predicted value) for {U t+2 }. (This is the two-step-ahead forecast. Call this Ût(2). i. Write the expression for Ût(2). We use the expression U t+2 = µ + A t+2 + θat + 1. Hence, Û t (2) = E(U t+2 F t ) = µ ii. Write the expression for error of Û t (2). The error is U t+2 Ût(2) = A t+2 + θa t+1. iii. What is the variance of the error of Ût(2). The variance is V(A t+2 + θa t+1 ) = (1 + θ 2 )σ 2 A 4. 8 points. The models in questions 2 and 3 are often extended and combined to form an ARMA(p, q) model. Some financial data fit this model fairly well, but often financial data does not fit an ARMA(p, q) model because the variance on the white noise is not constant. Sometimes the variance follows a process similar to an ARMA process (it s not exactly the same), and in that case, we can often form a better model. 4
(a) After fitting an ARMA(p, q) model to data, how could we decide whether the variance follows a process that we can model? We look at the residuals. In particular, we decide whether or not they are iid. If they are not iid, we see if there are autocorrelations that we can model. So we compute the ACF and the PACF of the squared residuals. (b) If the variance seems to follow an ARMA-like process, what should we do, and how do we proceed? We model the squared residuals with a GARCH(m, s) model. The full model is ARMA(p, q)+garch(m,s). 5
Use of R on the Computer 5 points each. In this part you must use the computer. All of the following questions refer to the same time series, but they are not strongly related; if you cannot get one, you can still get later ones. They all use the basic time series, which you generate using the R code below. Some of the statistical analyses will not be very meaningful. The data do not necessarily fit ARMA models very well. Do not let this concern you; just compute the statistics requested. (These data require more advanced methods of analysis than what what is suggested here.) You may want to use the fbasics package. (There are alternative functions in the base library.) Form a simulated time series using this R code (copy and paste or type very carefully): set.seed(1); x<-100+rt(1200,10)+.02*(1:1200) x<-ts(x[-(1:2)]+.1*x[c(-1,-1200)]+.2*x[c(-1199,-1200)],start=201) If you make a mistake, and need to start over, be sure to reset the seed. 5. After you have x, plot it. How would you describe this process? (What s its mean? What s its variance? Is it stationary?) It has a linear trend, so it is not stationary. If you can t see this from the R code that generates the data, you can clearly see it from the plot: x 130 140 150 160 200 400 600 800 1000 1400 Time The variance appears to be constant, however. The mean is 145.6676. The variance is 82.43464. 6. Now compute the log returns {r t } for this process, and put them in an R object r. Show your R code to do this. r <- diff(log(x)) or you could use the log.ratio function in the finance tools functions I gave you. Some you computed the simple returns. The R code to do this is sr <- diff(x)/x[-length(x)] I subtracted 3 points for simple returns instead of log returns, but if you computed the subsequent items correctly, I did not subtract any additional points. 7. Compute the historical (or statistical ) volatility of the log returns, {r t }. Show your R code to do this and give the value you compute. 6
This is just the annualized sample standard deviation computed over some time period. Computed over the whole period and annualized, it is given by sqrt(t)*stdev(r), where T is the number of the periods of the data in a year. For example if the observed data are on a monthly basis, T = 12, on a daily basis, T = 365, etc. For these data, stdev(r) = 0.01061324. Since the frequency was not mentioned in the problem, I did not count off for it, one way or another. The sample standard deviation of the simple returns is 0.01061377. The same comments about annualized volatility above apply to the simple returns; however, the simple returns do not scale up the same way. Some of you computed the standard deviation of the original x process. I gave 2 points for this. Some of you computed the variance of the original x process. I gave 0 points for this. 8. Make a q-q plot of the log returns versus quantiles of a normal distribution. (a) Show your R code. qqnorm(r) (b) What does the q-q plot indicate about the data? It is slightly heavy-tailed, but not far from normal. (The line is pretty straight.) 9. Compute the skewness and the excess kurtosis of the log returns. (a) What does the skewness tell you? We can use the skewness function in fbasics, or we can compute it directly. The easiest is library(fbasics); skewness(r). We get -0.04596814, so we could say it is very slightly negatively skewed. (b) What does the excess kurtosis tell you? We can use the kurtosis function in fbasics, or we can compute it directly. The easiest is kurtosis(r). We get 0.6712345, so we could say it is very slightly heavytailed. Some of you computed the skewness of the original x process, which is 0.03066, and the kurtosis of the original x process, which is -1.1436. I gave 3 points for this. 7
10. Perform a test of the null hypothesis that the log returns are from a normal distribution. (There are several possible tests; just choose one.) (a) Show your R code. We can use the normaltest function in fbasics, or we could use a K-S test, a chisquared test or others. The one we used in class most often is normaltest(r,method="jb"). (b) What is the p-value for the test you used? 8.688e-06 11. Compute the PACF of r. Describe what it shows about the data. We use the pacf(r). It does not die off until over 30 lags. This indicates the a low-order AR model will not fit the data well. 12. Compute the ACF of r. Describe what it shows about the data. We use the acf(r). There are very large autocorrelations for lags up to 3. 13. Perform a statistical test of the hypothesis that the ACFs for all lags up to lag 6 of r are 0. Show your R code, and give the p-value that is computed for the test. We use the Box.test(r, lag=6, type="ljung"). We get a p-value of 2.2e-16. So there are very significant autocorrelations in lags between 1 and 6. 14. Now fit r to an ARMA(2, 1) model. Show your R code, and give values of the AR and MA coefficients. Make sure to identify your coefficients clearly. We use arima(r, c(2,0,1)). We get parameter estimates ˆφ 1 = 0.1124, ˆφ 2 = 0.1924, and ˆθ 1 = 0.9928. 15. Now compute the ACF of the squared residuals from the ARMA(2, 1). Are any of them significant (other than the 0 one)? We use fit<-arima(r, c(2,0,1)) ressq<-fit$residuals^2 acf(ressq) Box.test(ressq, lag=6, type="ljung") The p-value from the Box test was 0.4252, indicating that the autocorrelations are not significant. 8