时间序列模型stata 基本命令汇总 - 图文

实证研究中应用广泛,使人们能更加准确地把握风险(波动性),尤其是应用在风险价值(VALUE AT RISK)理论中,在华尔街是人尽皆知的工具。

所谓ARCH模型,按照英文直译是自回归条件异方差模型。粗略地说,该模型将当前一切可利用信息作为条件,并采用某种自回归形式来刻划方差的变异,对于一个时间序列而言,在不同时刻可利用的信息不同,而相应的条件方差也不同,利用ARCH 模型,可以刻划出随时间而变异的条件方差。

ARCH(m)模型:

yt?xt???t?t2??0??1?t2?1??2?t2?2????m?t2?m其中,?2是残差平方和(波动率) ?i是ARCH模型的系数 GARCH(m,k)模型:

(条件平均值)

(条件方差)yt?xt???t???0???2t21t?1???22t?2?????2mt?m??1?2t?1??2?2t?2????k?2t?k

其中,?i是ARCH模型的系数;?i是GARCH系数 3.1 ARCH模型应用 例子:

. use http://www.stata-press.com/data/r11/wpi1,clear . regress D.ln_wpi

Source | SS df MS Number of obs = 123 -------------+------------------------------ F( 0, 122) = 0.00 Model | 0 0 . Prob > F = . Residual | .02521709 122 .000206697 R-squared = 0.0000 -------------+------------------------------ Adj R-squared = 0.0000 Total | .02521709 122 .000206697 Root MSE = .01438

------------------------------------------------------------------------------ D.ln_wpi | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _cons | .0108215 .0012963 8.35 0.000 .0082553 .0133878 ------------------------------------------------------------------------------

. estat archlm,lags(1)

LM test for autoregressive conditional heteroskedasticity (ARCH)

--------------------------------------------------------------------------- lags(p) | chi2 df Prob > chi2 -------------+------------------------------------------------------------- 1 | 8.366 1 0.0038

--------------------------------------------------------------------------- H0: no ARCH effects vs. H1: ARCH(p) disturbance

通过对WPI的对数差分进行常数回归,接着用LM检验来判断ARCH(1)效应,在该例子中,检验的结果PROB > CHI2=0.0038<0.05,所以拒绝没有ARCH(1)效应的虚无假设。因此,我们可以通过指定ARCH(1)模型来估计ARCH(1)的系数。

. arch D.ln_wpi,arch(1) garch(1) ARCH family regression

Sample: 1960q2 - 1990q4 Number of obs = 123 Distribution: Gaussian Wald chi2(.) = . Log likelihood = 373.234 Prob > chi2 = .

------------------------------------------------------------------------------ | OPG

D.ln_wpi | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ln_wpi |

_cons | .0061167 .0010616 5.76 0.000 .0040361 .0081974 -------------+---------------------------------------------------------------- ARCH | arch |

L1. | .4364123 .2437428 1.79 0.073 -.0413147 .9141394 | garch |

L1. | .4544606 .1866605 2.43 0.015 .0886126 .8203085 |

_cons | .0000269 .0000122 2.20 0.028 2.97e-06 .0000508 ------------------------------------------------------------------------------

这样,我们就可以估计出了ARCH(1)的系数是0.436,GARCH(1)的系数是0.454,所以我们可以拟合出GARCH(1,1)模型:

yt?0.0061??t??0.436?2t2t?1?0.454?2t?1 其中,yt?ln(wpit)?ln(wpit?1)

接下来我们可以对变量的进行预测:

predict xb,xb /*对差分变量的预测*/ predict y,y /*对未差分变量的预测*/

predict variance,var /*对条件方差的预测 */

predict res,residuals /*对差分变量残差的预测*/

predict yres,yresiduals /*对未差分变量残差的预测*/

3.2 ARCH模型的确定以及检验

例子:

use http://www.stata-press.com/data/r11/wpi1,clear

*- 检验 ARCH 效应是否存在:archlm 命令 regress D.ln_wpi archlm, lag(1/20)

regress D.ln_wpi L(1/3).D.ln_wpi archlm, lag(1/20)

* 图形法——自相关函数图 (ac) reg D.ln_wpi predict e, res gen e2 = e^2 ac e2, lag(40)

gen dlnwpi=D.ln_wpi gen dlnwpi2 = dlnwpi^2 ac dlnwpi2, lag(40) * 精简模型:ARCH(1) * 保守模型:ARCH(4)

*- 预测值

arch D.ln_wpi, arch(1/4)

predict ht, variance /*条件方差*/

* ht = c + a_1*e2_t-1 + a_2*e2_t-2 + ... + a_5*e2_t-5 line ht t

predict et, residual /*均值方程的残差*/

*- 模型的评估 * 基本思想:

* 若模型设定是合适的,那么标准化残差 * z_t = e_t/sqrt(h_t)

* 应为一个 i.i.d 的随机序列,即不存在序列相关和ARCH效应;

gen zt = et / sqrt(ht) /*标准化残差*/

gen zt2 = zt^2 /*标准化残差的平方*/

* 序列相关检验 pac zt

corrgram zt /*Ljung-Box 统计量*/

pac zt2

corrgram zt2

* 正态分布检验

histogram zt, normal wntestb zt wntestb zt2

* 评论:均值方程的设定可能需要改进,因为 zt 仍然表现出明显的序列相关。 * 条件方差方程的设定基本满足要求,zt2 不存在明显的序列相关。

3.3 ARIMA过程的ARCH模型

我们可以对条件方差模型保持ARCH(1,1)模型而均值模型采用ARMA过程的自回归一阶和移动平均一阶农以及移动平均四阶来控制季节影响:

. use http://www.stata-press.com/data/r11/wpi1,clear . arch D.ln_wpi,ar(1) ma(1 4) arch(1) garch(1)

ARCH family regression -- ARMA disturbances

Sample: 1960q2 - 1990q4 Number of obs = 123 Distribution: Gaussian Wald chi2(3) = 153.56 Log likelihood = 399.5144 Prob > chi2 = 0.0000

------------------------------------------------------------------------------ | OPG

D.ln_wpi | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ln_wpi |

_cons | .0069541 .0039517 1.76 0.078 -.000791 .0146992 -------------+---------------------------------------------------------------- ARMA | ar |

L1. | .7922673 .1072225 7.39 0.000 .582115 1.002419 | ma |

L1. | -.3417738 .1499944 -2.28 0.023 -.6357574 -.0477902 L4. | .2451725 .1251131 1.96 0.050 -.0000446 .4903896 -------------+---------------------------------------------------------------- ARCH | arch |

L1. | .2040451 .1244992 1.64 0.101 -.039969 .4480591 | garch |

L1. | .694968 .189218 3.67 0.000 .3241075 1.065829 |

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4