1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| clear
insheet using "Bindex.csv" gen datevar = date(date,"YMD") format datevar %td label variable datevar "日期" tsset datevar gen time=_n tsset time
line index datevar graph export "深成B指的时间序列图.png", as(png) replace
gen r=100*(index-L.index)/L.index
summarize r
line r datevar graph export "深成B指日收益率的时间序列图.png", as(png) replace
dfuller r
ac r,lags(20) graph export "自相关系数图.png", as(png) replace
pac r,lags(20) graph export "偏自相关系数图.png", as(png) replace
set matsize 1500 arima r,arima(3,0,3) estat ic arima r,arima(8,0,8) estat ic arima r,arima(3,0,8) estat ic arima r,arima(8,0,3) estat ic
arima r,arima(3,0,3)
predict residess, residuals hist residess,norm freq graph export "残差分布直方图.png", as(png) replace
wntestq residess, lag(12)
gen ressq = residess^2 wntestq ressq, lag(12)
reg ressq l.ressq l2.ressq l3.ressq l4.ressq l5.ressq gen LM_STAT=e(N)*e(r2) display LM_STAT display chiprob(e(df_m),LM_STAT)
arch r,arima(3 0 3) arch(1) garch(1) estat ic
arch r,arima(3 0 3) arch(1) garch(1) distribution(t 3) estat ic
arch r,arima(3 0 3) arch(2) garch(2) estat ic
arch r,arima(3 0 3) arch(2) garch(2) distribution(t 3) estat ic
arch r,arima(3 0 3) arch(1) garch(1) distribution(t 3) tsappend ,add(10) predict result tsline result r, legend(label(1 "预测值") label(2 "真实值")) graph export "预测结果图.png", as(png) replace
|