EF 5070辅导、讲解Financial Econometrics、辅导R程序设计、R讲解 讲解R语言编程|解析C/C++编程

- 首页 >> 其他
PS 2 EF 5070: Financial Econometrics
EF 5070: Financial Econometrics
Problem Set 2
Due 5:00 pm, Nov 1st, 2019
Notes
1. Due Friday, 5:00pm, Nov 1st.
2. Han Zhang, the TA of this course, will collect problem sets in her office, (AC3) 9-233,
on Friday Oct 11th from 3:30 pm-5:00 pm.
3. If you cannot hand in your problem set in person, please scan and send your problem set to
the TA at hzhang368@cityu.edu.hk before the deadline.
4. Hand in your problem set together with the i) R codes that you used to generate the results,
ii) the associated R log file, and iii) your written solution.
5. Each student needs to write his/her own solutions, even though discussions of the assignments
between students are encouraged.
6. If not specifically specified, use 5% significance level (the associated critical value is 1.96 for
standard normal distribution) to draw conclusions in this problem set.
7. Some useful R strategies:
(1) For LB test, first using the R command
tsdiag(model)
to examine whether there are any serial dependency in residuals.
(2) For LB test, now use another R build-in command,
Box.test(model$residuals,lag=12,type=’Ljung’)
Compare the reported p-value with 5% significance level.
(3) To fit the data with an AR model, consider the build-in R code
m=ar(data,method="mle")
m_order=m$order
m_aic=m$aic
m_1=arima(data,order=c(m_order,0,0))
m_1
Page 1
PS 2 EF 5070: Financial Econometrics
par(mfrow=c(2,1))
plot(data,xlab=’Time’,ylab=’Returns’)
plot(m_aic)
(4) To plot the ACF and PACF of a series, consider the build-in command
data_acf<-acf(data)
data_pacf<-pacf(data)
(5) To fit the data with an MA model, consider the build-in R code
m_1=arima(data,order=c(0,0,m_order))
(6) To perform forecast and construct the 95% confidence interval, consider the following command
R codes:
pred<-predict(m_1,n.ahead=8)
lines(pred$pred,col="blue", lwd=5)
lines(pred$pred+2*pred$se,col="red",lty=3, lwd=5)
lines(pred$pred-2*pred$se,col="red",lty=3, lwd=5)
(7) Plot several graphs, say m × n, in one page with the same scale and arrange them into m
rows and n columns.
par(mfcol=c(m,n))
plot(...)
plot(...)
Page 2
PS 2 EF 5070: Financial Econometrics
(8) To detect a unit root process in the series, consider the following R code (the value of m in
the option k=m can be any reasonable positive integer):
library("tseries")
adf.test(data, k=10)
1. Suppose that simple return of a monthly bond index follows an MA(2) model,
Rt = 0.1 + νt − 0.8νt−1 + 0.1νt−2, (1)
where νt ∼ N(0, 4).
(a) What is the mean of the simple return of this monthly bond?
(b) What is the variance of the simple return of this monthly bond?
(c) Consider the forecast origin h = 100 with ν100 = 0.2, ν99 = −0.1 and ν98 = 1.
Compute the 1-step-ahead forecast of the simple return at the forecast origin h = 100
and the variance of your forecast error.
(d) Based on part (c), compute the 2-step-ahead forecast of the simple return at the
forecast origin h = 100 and the variance of your forecast error.
(e) Based on part (c), how long do you expect the forecast value converge to its mean
level? Explain it briefly.
2. Suppose the simple daily log return of a stock follows the dynamics,
rt = −0.3 + 0.1rt−3 + t
, (2)
where t ∼ N(0, 2).
(a) What is the mean of the simple daily log return of this stock?
(b) What is the variance of the simple daily log return of this stock?
(c) Based on Part (a) and (b), is the stock simple log return stationary (with E(rt) =
µ < ∞ and var(Xt) = δ
2 < ∞)?
(d) Consider the forecast origin h = 100 with r100 = 0.5, r99 = 0.5, r98 = −1 and
r97 = −0.2. Compute the 1-step-ahead forecast (hint: rh(1) = E(rh+1|Ih))of the
simple return at the forecast origin h = 100 and the variance of your forecast error.
Page 3
PS 2 EF 5070: Financial Econometrics
(e) Based on part (d), compute the 2-step-ahead forecast (hint: ˆrh(2) = E(rh+2|Ih)) of
the simple return at the forecast origin h = 100 and the variance of your forecast
error.
(f) Based on part (d), compute the 3-step-ahead forecast (hint: ˆrh(3) = E(rh+3|Ih)) of
the simple return at the forecast origin h = 100 and the variance of your forecast
error.
3. Consider the simple log returns of Starbucks stock from 2009 Jan 1st to 2019 Oct 1st.
(a) Download the according data using the quantmod command in R.
(b) Report summary statistics, including sample mean, sample variance, skewness, kurtosis,
minimum and maximum of the raw data.
(c) Build an AR model for the series and decide the best order p using AIC and PACF,
respectively.
(d) Estimate your proposed AR(p) model and provide forecasts from Oct to Oct 17th and
compare your forecast with the actual stock returns during that period.
(e) Build an MA model for the series and decide the best order q using ACF. Briefly
explain why we can choose the best order using ACF?
(f) Estimate your proposed MA(q) model and provide forecast from Oct to Oct 17th and
compare your forecast with the actual stock returns during that period.
(g) Is your AR(p) or MA(q) model adequate? Perform Ljung-Box test separately.
4. Consider the daily VIX index. VIX, calculated and published by the Chicago Board Options
Exchange (CBOE), is widely used as a measure for market level uncertainty.
(a) Please download the daily VIX index from January 1, 2009 to Oct 1, 2018 using the
quantmod command in R.
hint
#To use a specific column of your dataset, say the 6th column in
this question, and transform it into numeric format, consider
the following command:
vix<-as.numeric(VIX[,6])
(b) Plot the daily VIX index, the distribution of VIX index and its ACF in one page.
(c) Is the series a nonstationary process? Why? (Consider the ADF test)
Page 4
PS 2 EF 5070: Financial Econometrics
(d) Is the differenced series a stationary process? Why? (Consider the ADF test)
(e) Build a ARMA model for the differenced VIX index, including your analysis on model
adequacy.
Now, we introduce another way to identify the best order for a ARIMA model by
using a build-in command in R:
auto.arima(vix)
(f) Write down the fitted model.
(g) Obtain 1-step to 20-step ahead forecast of the VIX index based on your model in part
(c) at the forecast origin May 01, 2019. Plot your forecasting result and compare with
the true data.
Page 5