Last active
August 29, 2015 13:59
-
-
Save kongscn/10532853 to your computer and use it in GitHub Desktop.
Solution of 3.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 3.5 | |
setwd("D:/") | |
a = read.table("m-intc7308.txt", head = T) | |
# 调整成时间序列数据 | |
ts1 = ts(data = a[[2]], start = 1973, frequency = 12) | |
lts1 = log(1 + ts1) | |
# 转化成对数收益率 | |
acf(lts1) | |
# 观察 ARIMA 模型的阶数 (定阶) | |
pacf(lts1) | |
# acf 定 MA(q) 的阶数, pacf 定 AR(p) 的阶数 | |
# 检验是否存在条件异方差 | |
plot(lts1^2) | |
# 检验是否存在条件异方差 | |
Box.test(lts1^2) | |
myspec = ugarchspec(variance.model=list(garchOrder = c(1,1)), | |
mean.model=list(armaOrder = c(0,0))) | |
# 建立 GARCH 模型 | |
myfit = ugarchfit(myspec, lts1) | |
myfit | |
# 向前 5 步预测 | |
fc = ugarchforecast(myfit, lts1, n.ahead = 5) | |
fc | |
# Now try a very very very long long long long long long long long long long long long long long long long long long long long long long line. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment