全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3235 2
2012-05-25
程序如下,数据和doc文件在附件中
sp500.rar
大小:(42 KB)

 马上下载



sp500=read.table("sp500.txt")
sp500.returns=diff(log(sp500$V1))*100
auto.arima(sp500.returns) #要加载forecast包
m1=auto.arima(sp500.returns)
res1=residuals(m1)
Box.test(res1) #为白噪声
ArchTest(res1) #要加载FinTS包 有异方差
ArchTest(res1^2) #居然没有了异方差,很奇怪

以下用GARCH(1,1)-M模型拟合,要用到rugarch包
variance.model=list(model="fGARCH",garchOrder=c(1,1), submodel="GARCH") #方差模型
mean.model=list(armaOrder=c(0,2),include.mean=TRUE,garchInMean=TRUE,inMeanType=2,arfima=FALSE) #均值模型
spec=ugarchspec(variance.model=variance.model,mean.model=mean.model, distribution.model="std") #两个模型结合
fit=ugarchfit(data=sp500.returns,spec=spec,out.sample=0,solver="solnp")
fit
这段GARCH(1,1)-M模型拟合的返回结果放在了doc文件中

以下单独对fit残差
ArchTest(residuals(fit))
McLeod.Li.test(residuals(fit)) #要加载TSA包
都显示有方差异性,我认为和doc文件中的红色加深部分矛盾

ArchTest(residuals(fit)^2)
McLeod.Li.test(y=residuals(fit)^2) #奇了怪了,残差平方后,就方差齐性了

McLeod.Li.test(y=residuals(fit)^2.1) #但这又方差异性了

Box.test(residuals(fit)) #原来ma2模型残差已是白噪声,但ma2+GARCH(1,1)-M 模型的残差反而不是白噪声了,很奇怪

GARCH(1,1)-M模型拟合返回结果

*---------------------------------*

*         GARCH Model Fit        *

*---------------------------------*


Conditional Variance Dynamics   

-----------------------------------

GARCH Model     : fGARCH(1,1)

fGARCH Sub-Model        : GARCH

Mean Model      : ARFIMA(0,0,2)

Distribution    : std


Optimal Parameters

------------------------------------

       Estimate  Std. Error  t value Pr(>|t|)

mu     0.054826    0.005660   9.6858 0.0e+00

ma1    0.098061    0.008087  12.1255 0.0e+00

ma2   -0.028445    0.007261  -3.9177 8.9e-05

omega  0.005980    0.000932   6.4160 0.0e+00

alpha1 0.075629    0.005047  14.9856 0.0e+00

beta1  0.919790    0.005039 182.5500  0.0e+00

shape  6.834882    0.354538  19.2783 0.0e+00


Robust Standard Errors:

       Estimate  Std. Error  t value Pr(>|t|)

mu      0.054826    0.005960  9.1991    0e+00

ma1     0.098061   0.009211  10.6464    0e+00

ma2    -0.028445   0.006324  -4.4981    7e-06

omega   0.005980   0.001138   5.2542    0e+00

alpha1  0.075629   0.006830  11.0737    0e+00

beta1   0.919790   0.006785 135.5722    0e+00

shape   6.834882   0.437600  15.6190    0e+00


LogLikelihood : -18376.05


Information Criteria

------------------------------------


Akaike      2.3434

Bayes       2.3468

Shibata     2.3434

Hannan-Quinn 2.3446


Q-Statistics on Standardized Residuals

------------------------------------

     statistic p-value

Lag10    17.79 0.02289

Lag15    22.12 0.05351

Lag20    27.49 0.07017


H0 : No serial correlation


Q-Statistics on Standardized SquaredResiduals

------------------------------------1

     statistic p-value

Lag10    17.53 0.02502

Lag15    20.28 0.08847

Lag20    24.12 0.15100


ARCH LM Tests

------------------------------------

             StatisticDoF  P-Value

ARCH Lag[2]     12.80   2 0.001666

ARCH Lag[5]      12.97  5 0.023657

ARCH Lag[10]    17.31  10 0.067792


Nyblom stability test

------------------------------------

Joint Statistic:  22.4136

Individual Statistics:              

mu     0.2276

ma1   16.6716

ma2    0.6400

omega  2.0735

alpha1 1.9789

beta1  2.6989

shape  1.4570


Asymptotic Critical Values (10% 5% 1%)

Joint Statistic:         1.69 1.9 2.35

Individual Statistic:    0.35 0.47 0.75


Sign Bias Test

------------------------------------

                   t-value      prob sig

Sign Bias          0.5886 5.561e-01   

Negative Sign Bias  4.0662 4.802e-05 ***

Positive Sign Bias  2.5898 9.611e-03 ***

Joint Effect       48.4371 1.719e-10 ***



Adjusted Pearson Goodness-of-Fit Test:

------------------------------------

group statistic p-value(g-1)

1   20     65.28    5.493e-07

2   30     88.29    6.657e-08

3   40     85.56    2.458e-05

4   50    113.59    4.827e-07



Elapsed time : 10.82462



望各位高手赐教,谢谢!


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-5-27 01:17:22
there are a lot of standard method in using arch and garch for sp500. use that.  there are a lot of delicate issues. Do not trust r, r is only a program, we need to set up a standard analysis procedure using the ARCH and GARCH model before using r.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-5-28 23:42:50
谢谢823317513的回答,若能更详细就更好了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群