Intel公司股票收益率的波动率建模实例
library(readr)
library(zoo)
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(xts)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
d.intel <- read_table(
  "D:/齐安静 教学/时间序列分析/北大/ftsdata/m-intcsp7309.txt",
  col_types=cols(
    .default=col_double(),
    date=col_date("%Y%m%d")
  ))
xts.intel <- xts(
  log(1 + d.intel[["intc"]]), d.intel[["date"]]
)
tclass(xts.intel) <- "yearmon"
ts.intel <- ts(c(coredata(xts.intel)), start=c(1973,1), frequency=12)
at <- ts.intel - mean(ts.intel)
plot(ts.intel, ylab="log return", main="Intel Stock Price Monthly Log Return")

使用条件正态分布
library(fGarch, quietly = TRUE)
## NOTE: Packages 'fBasics', 'timeDate', and 'timeSeries' are no longer
## attached to the search() path when 'fGarch' is attached.
## 
## If needed attach them yourself in your R script by e.g.,
##         require("timeSeries")
mod1 <- garchFit(~ 1 + garch(1,1), data=ts.intel, trace=FALSE)
summary(mod1)
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~1 + garch(1, 1), data = ts.intel, trace = FALSE) 
## 
## Mean and Variance Equation:
##  data ~ 1 + garch(1, 1)
## <environment: 0x00000192ba4c3b28>
##  [data = ts.intel]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##         mu       omega      alpha1       beta1  
## 0.01126568  0.00091902  0.08643831  0.85258554  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##         Estimate  Std. Error  t value Pr(>|t|)    
## mu     0.0112657   0.0053931    2.089  0.03672 *  
## omega  0.0009190   0.0003888    2.364  0.01808 *  
## alpha1 0.0864383   0.0265439    3.256  0.00113 ** 
## beta1  0.8525855   0.0394322   21.622  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  312.3307    normalized:  0.7034475 
## 
## Description:
##  Tue Dec 19 17:59:09 2023 by user: qaj 
## 
## 
## Standardised Residuals Tests:
##                                   Statistic      p-Value
##  Jarque-Bera Test   R    Chi^2  174.9040137 0.000000e+00
##  Shapiro-Wilk Test  R    W        0.9709615 1.030281e-07
##  Ljung-Box Test     R    Q(10)    8.0168436 6.271916e-01
##  Ljung-Box Test     R    Q(15)   15.5006010 4.159946e-01
##  Ljung-Box Test     R    Q(20)   16.4154862 6.905368e-01
##  Ljung-Box Test     R^2  Q(10)    0.8746345 9.999072e-01
##  Ljung-Box Test     R^2  Q(15)   11.3593520 7.267295e-01
##  Ljung-Box Test     R^2  Q(20)   12.5599382 8.954573e-01
##  LM Arch Test       R    TR^2    10.5140057 5.709617e-01
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -1.388877 -1.351978 -1.389037 -1.374326
vola <- volatility(mod1)
plot(ts(vola, start=start(ts.intel), frequency=frequency(ts.intel)), 
     xlab="年", ylab="波动率")
abline(h=sd(ts.intel), col="green")

sd(ts.intel)
## [1] 0.1269101
tmpx <- coef(mod1)
unname(sqrt(tmpx["omega"]/(1 - tmpx["alpha1"] - tmpx["beta1"])))
## [1] 0.122767
##plot(mod1, which=9)
resi <- residuals(mod1, standardize=TRUE)
plot(ts(resi, start=start(ts.intel), frequency=frequency(ts.intel)), 
     xlab="年", ylab="标准化残差")

标准化残差的ACF:

plot(mod1, which=10)

plot(mod1, which=11)

plot(mod1, which=3)

vola <- volatility(mod1)
hatmu <- coef(mod1)["mu"]
lb.intel <- hatmu - 2*vola
ub.intel <- hatmu + 2*vola
ylim <- range(c(ts.intel, lb.intel, ub.intel))
x.intel <- c(time(ts.intel))
plot(x.intel, c(ts.intel), type="l",
     xlab="年", ylab="对数收益率")
lines(x.intel, c(lb.intel), col="red")
lines(x.intel, c(ub.intel), col="red")

使用条件t分布
library(fGarch, quietly = TRUE)
mod2 <- garchFit(~ 1 + garch(1,1), data=ts.intel, 
                 cond.dist="std", trace=FALSE)
summary(mod2)
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~1 + garch(1, 1), data = ts.intel, cond.dist = "std", 
##     trace = FALSE) 
## 
## Mean and Variance Equation:
##  data ~ 1 + garch(1, 1)
## <environment: 0x00000192b12d95d0>
##  [data = ts.intel]
## 
## Conditional Distribution:
##  std 
## 
## Coefficient(s):
##        mu      omega     alpha1      beta1      shape  
## 0.0165076  0.0011576  0.1059029  0.8171298  6.7723926  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##         Estimate  Std. Error  t value Pr(>|t|)    
## mu     0.0165076   0.0051031    3.235 0.001217 ** 
## omega  0.0011576   0.0005782    2.002 0.045287 *  
## alpha1 0.1059029   0.0372046    2.846 0.004420 ** 
## beta1  0.8171298   0.0580150   14.085  < 2e-16 ***
## shape  6.7723926   1.8572665    3.646 0.000266 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  326.2264    normalized:  0.734744 
## 
## Description:
##  Tue Dec 19 17:59:10 2023 by user: qaj 
## 
## 
## Standardised Residuals Tests:
##                                   Statistic      p-Value
##  Jarque-Bera Test   R    Chi^2  203.4935971 0.000000e+00
##  Shapiro-Wilk Test  R    W        0.9687607 3.970512e-08
##  Ljung-Box Test     R    Q(10)    7.8777964 6.407723e-01
##  Ljung-Box Test     R    Q(15)   15.5522542 4.124162e-01
##  Ljung-Box Test     R    Q(20)   16.5048039 6.848548e-01
##  Ljung-Box Test     R^2  Q(10)    1.0660526 9.997694e-01
##  Ljung-Box Test     R^2  Q(15)   11.4988561 7.164967e-01
##  Ljung-Box Test     R^2  Q(20)   12.6150651 8.932826e-01
##  LM Arch Test       R    TR^2    10.8074911 5.454849e-01
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -1.446966 -1.400841 -1.447215 -1.428776
tmpx <- coef(mod2)
unname(sqrt(tmpx["omega"]/(1 - tmpx["alpha1"] - tmpx["beta1"])))
## [1] 0.1226396
  plot(mod2, which=13)

使用条件有偏t分布
skewness.test <- function(x, na.rm=TRUE){
  if(na.rm) x <- x[!is.na(x)]
  z <- (x - mean(x))/sd(x)
  n <- length(x)
  sk <- n/(n-1)/(n-2) * sum(z^3)
  t.sk <- sk / sqrt(6/n)
  p.sk <- 2*(1 - pnorm(abs(t.sk)))
  c(estimate=sk, statistic=t.sk, pvalue=p.sk)
}
skewness.test(as.vector(ts.intel))
##      estimate     statistic        pvalue 
## -5.563719e-01 -4.786092e+00  1.700598e-06
library(fGarch, quietly = TRUE)
mod3 <- garchFit(~ 1 + garch(1,1), data=ts.intel, 
  cond.dist="sstd", trace=FALSE)
summary(mod3)
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(formula = ~1 + garch(1, 1), data = ts.intel, cond.dist = "sstd", 
##     trace = FALSE) 
## 
## Mean and Variance Equation:
##  data ~ 1 + garch(1, 1)
## <environment: 0x00000192b66f3548>
##  [data = ts.intel]
## 
## Conditional Distribution:
##  sstd 
## 
## Coefficient(s):
##        mu      omega     alpha1      beta1       skew      shape  
## 0.0133343  0.0011621  0.1049294  0.8177869  0.8717222  7.2344212  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##         Estimate  Std. Error  t value Pr(>|t|)    
## mu     0.0133343   0.0053430    2.496 0.012572 *  
## omega  0.0011621   0.0005587    2.080 0.037520 *  
## alpha1 0.1049294   0.0358862    2.924 0.003456 ** 
## beta1  0.8177869   0.0559866   14.607  < 2e-16 ***
## skew   0.8717222   0.0629130   13.856  < 2e-16 ***
## shape  7.2344212   2.1018126    3.442 0.000577 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  328.0995    normalized:  0.7389628 
## 
## Description:
##  Tue Dec 19 17:59:10 2023 by user: qaj 
## 
## 
## Standardised Residuals Tests:
##                                   Statistic      p-Value
##  Jarque-Bera Test   R    Chi^2  195.2180903 0.000000e+00
##  Shapiro-Wilk Test  R    W        0.9692506 4.892633e-08
##  Ljung-Box Test     R    Q(10)    7.8821240 6.403498e-01
##  Ljung-Box Test     R    Q(15)   15.6249576 4.074053e-01
##  Ljung-Box Test     R    Q(20)   16.5774063 6.802192e-01
##  Ljung-Box Test     R^2  Q(10)    1.0784338 9.997569e-01
##  Ljung-Box Test     R^2  Q(15)   11.9515703 6.826911e-01
##  Ljung-Box Test     R^2  Q(20)   13.0379307 8.757507e-01
##  LM Arch Test       R    TR^2    11.1882790 5.128558e-01
## 
## Information Criterion Statistics:
##       AIC       BIC       SIC      HQIC 
## -1.450899 -1.395550 -1.451257 -1.429071
z <- (0.8717220 - 1) / 0.0629129
pv <- 2*(1 - pnorm(abs(z)))
c(statistic=z, pvalue=pv)
##   statistic      pvalue 
## -2.03897770  0.04145225
plot(mod3, which=13)

讨论和比较
x.intel <- as.vector(time(ts.intel))
vola1 <- volatility(mod1)
vola2 <- volatility(mod2)
vola3 <- volatility(mod3)
matplot(x.intel, cbind(vola1, vola2, vola3),
        type="l",
        lty=1, col=c("green", "blue", "red"), 
        xlab="年", ylab="波动率")
legend("top", lty=1, col=c("green", "blue", "red"), 
       legend=c("标准正态分布", "对称标准化t分布", "有偏标准化t分布"))

library(tibble)
p1 <- predict(mod1, n.ahead=12)[["standardDeviation"]]
p2 <- predict(mod2, n.ahead=12)[["standardDeviation"]]
p3 <- predict(mod3, n.ahead=12)[["standardDeviation"]]
pred.tab <- tibble(
  "预测步数"=1:12,
  "正态"=p1,
  "对称t"=p2,
  "有偏t"=p3
)
knitr::kable(pred.tab, digits=4)
预测步数 正态 对称t 有偏t
1 0.0975 0.0951 0.0955
2 0.0993 0.0975 0.0979
3 0.1009 0.0997 0.1000
4 0.1023 0.1016 0.1019
5 0.1037 0.1034 0.1037
6 0.1050 0.1050 0.1053
7 0.1061 0.1065 0.1067
8 0.1072 0.1078 0.1080
9 0.1082 0.1090 0.1092
10 0.1092 0.1101 0.1103
11 0.1100 0.1111 0.1113
12 0.1109 0.1121 0.1122
使用rugarch包
library(rugarch)
## Loading required package: parallel
## 
## Attaching package: 'rugarch'
## The following object is masked from 'package:stats':
## 
##     sigma
spec1 <- ugarchspec(
  mean.model = list(
    armaOrder=c(0,0),
    include.mean=TRUE  ),
  variance.model = list(
    model = "sGARCH", # standard GARCH model
    garchOrder = c(1,1) ),
  distribution.model="sstd" ) 
mod2ru <- ugarchfit(spec = spec1, data = ts.intel)
show(mod2ru)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : sstd 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.013349    0.005344   2.4980 0.012491
## omega   0.001161    0.000559   2.0783 0.037684
## alpha1  0.104594    0.035883   2.9149 0.003558
## beta1   0.817923    0.056053  14.5919 0.000000
## skew    0.871842    0.062835  13.8750 0.000000
## shape   7.249884    2.107753   3.4396 0.000583
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.013349    0.005724   2.3321 0.019694
## omega   0.001161    0.000508   2.2865 0.022227
## alpha1  0.104594    0.030754   3.4010 0.000671
## beta1   0.817923    0.048372  16.9090 0.000000
## skew    0.871842    0.061014  14.2891 0.000000
## shape   7.249884    1.994299   3.6353 0.000278
## 
## LogLikelihood : 328.1036 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -1.4509
## Bayes        -1.3956
## Shibata      -1.4513
## Hannan-Quinn -1.4291
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.5396  0.4626
## Lag[2*(p+q)+(p+q)-1][2]    0.7088  0.6032
## Lag[4*(p+q)+(p+q)-1][5]    1.8503  0.6542
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.2528  0.6151
## Lag[2*(p+q)+(p+q)-1][5]    0.3020  0.9835
## Lag[4*(p+q)+(p+q)-1][9]    0.4598  0.9988
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]  0.005876 0.500 2.000  0.9389
## ARCH Lag[5]  0.038484 1.440 1.667  0.9966
## ARCH Lag[7]  0.068420 2.315 1.543  0.9997
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.337
## Individual Statistics:              
## mu     0.15846
## omega  0.13798
## alpha1 0.10628
## beta1  0.10705
## skew   0.04290
## shape  0.06739
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.49 1.68 2.12
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value   prob sig
## Sign Bias          0.17515 0.8610    
## Negative Sign Bias 0.26118 0.7941    
## Positive Sign Bias 0.07641 0.9391    
## Joint Effect       0.09363 0.9926    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     16.27       0.6392
## 2    30     29.78       0.4249
## 3    40     35.28       0.6403
## 4    50     52.17       0.3517
## 
## 
## Elapsed time : 0.2774439
plot(mod2ru, which=9)

4.6.6 两步估计法

例如,对Intel月对数收益率序列, 先用常数作为均值方程,计算残差\(a_t\):

hatmu <- mean(ts.intel); hatmu
## [1] 0.0143273
at <- ts.intel - hatmu
at2 <- at^2
mod4 <- arima(at2, order=c(1,0,1)); mod4
## 
## Call:
## arima(x = at2, order = c(1, 0, 1))
## 
## Coefficients:
##          ar1      ma1  intercept
##       0.9119  -0.7915     0.0161
## s.e.  0.0430   0.0635     0.0039
## 
## sigma^2 estimated as 0.001223:  log likelihood = 858.64,  aic = -1709.28
vola4 <- sqrt(at2 - mod4$residuals)
cor(vola3, vola4)
## [1] 0.9976243

4.6.7 IGARCH模型

library(rugarch)
speci <- ugarchspec(
  mean.model = list(
    armaOrder=c(0,0),
    include.mean=TRUE  ),
  variance.model = list(
    model = "iGARCH", # itegrated GARCH model
    garchOrder = c(1,1) ) )
mod5ru <- ugarchfit(spec = speci, data = xts.intel)
show(mod5ru)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : iGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.009665    0.005340   1.8100 0.070298
## omega   0.000345    0.000182   1.8990 0.057561
## alpha1  0.127533    0.033626   3.7927 0.000149
## beta1   0.872467          NA       NA       NA
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.009665    0.006240   1.5488 0.121425
## omega   0.000345    0.000191   1.8060 0.070925
## alpha1  0.127533    0.031820   4.0079 0.000061
## beta1   0.872467          NA       NA       NA
## 
## LogLikelihood : 308.1861 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -1.3747
## Bayes        -1.3470
## Shibata      -1.3748
## Hannan-Quinn -1.3638
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.6333  0.4261
## Lag[2*(p+q)+(p+q)-1][2]    0.8602  0.5459
## Lag[4*(p+q)+(p+q)-1][5]    1.8181  0.6620
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.2326  0.6296
## Lag[2*(p+q)+(p+q)-1][5]    0.5702  0.9463
## Lag[4*(p+q)+(p+q)-1][9]    0.8666  0.9911
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.1295 0.500 2.000  0.7190
## ARCH Lag[5]    0.2649 1.440 1.667  0.9495
## ARCH Lag[7]    0.3838 2.315 1.543  0.9877
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.1698
## Individual Statistics:              
## mu     0.22485
## omega  0.03416
## alpha1 0.21842
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          0.846 1.01 1.35
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value   prob sig
## Sign Bias          0.24275 0.8083    
## Negative Sign Bias 0.06684 0.9467    
## Positive Sign Bias 0.25664 0.7976    
## Joint Effect       0.10895 0.9907    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     27.71      0.08914
## 2    30     37.08      0.14416
## 3    40     57.98      0.02571
## 4    50     59.38      0.14717
## 
## 
## Elapsed time : 0.07020092
Intel股票月对数收益率的GARCH-M建模
  • 用rugarch包估计GARCH-M模型:
library(rugarch)
specm <- ugarchspec(
  mean.model = list(
    armaOrder=c(0,0),
    include.mean=TRUE,
    archm=TRUE, archpow=2),
  variance.model = list(
    model = "sGARCH", # standard GARCH model
    garchOrder = c(1,1) ) )
mod6ru <- ugarchfit(spec = specm, data = xts.intel)
show(mod6ru)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error   t value Pr(>|t|)
## mu     -0.000182    0.013692 -0.013286 0.989400
## archm   0.855502    0.949132  0.901352 0.367401
## omega   0.000944    0.000392  2.408992 0.015997
## alpha1  0.087242    0.026658  3.272661 0.001065
## beta1   0.849716    0.039235 21.657192 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu     -0.000182    0.015261 -0.01192 0.990489
## archm   0.855502    1.097457  0.77953 0.435667
## omega   0.000944    0.000465  2.02966 0.042391
## alpha1  0.087242    0.029544  2.95293 0.003148
## beta1   0.849716    0.041846 20.30575 0.000000
## 
## LogLikelihood : 312.7599 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -1.3863
## Bayes        -1.3402
## Shibata      -1.3866
## Hannan-Quinn -1.3681
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.6479  0.4209
## Lag[2*(p+q)+(p+q)-1][2]    0.8671  0.5434
## Lag[4*(p+q)+(p+q)-1][5]    2.1293  0.5882
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.1373  0.7110
## Lag[2*(p+q)+(p+q)-1][5]    0.1496  0.9958
## Lag[4*(p+q)+(p+q)-1][9]    0.3174  0.9997
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3] 0.0002646 0.500 2.000  0.9870
## ARCH Lag[5] 0.0167632 1.440 1.667  0.9990
## ARCH Lag[7] 0.0530468 2.315 1.543  0.9999
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.5296
## Individual Statistics:              
## mu     0.15303
## archm  0.17083
## omega  0.07591
## alpha1 0.09511
## beta1  0.07486
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.28 1.47 1.88
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value   prob sig
## Sign Bias           0.2498 0.8029    
## Negative Sign Bias  0.4723 0.6370    
## Positive Sign Bias  0.1415 0.8875    
## Joint Effect        0.2692 0.9657    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     17.35       0.5661
## 2    30     22.76       0.7876
## 3    40     30.77       0.8236
## 4    50     49.47       0.4544
## 
## 
## Elapsed time : 0.3301179
标普500指数月超额收益率的GARCH-M建模
  • 考虑标普500指数从1926年到1991年的月超额收益率。 共792个观测。
x.sp <- scan("D:/齐安静 教学/时间序列分析/北大/ftsdata/sp500.txt", quiet=TRUE)*100
ts.sp <- ts(x.sp, start=c(1926,1), frequency = 12)
plot(ts.sp, main="标普500的月超额收益率(%)", xlab="年", ylab="超额收益率")

  • 用GARCH(1,1)模型:
library(rugarch)
spec.sp1 <- ugarchspec(
  mean.model = list(
    armaOrder=c(0,0),
    include.mean=TRUE  ),
  variance.model = list(
    model = "sGARCH", # standard GARCH model
    garchOrder = c(1,1) ) ) 
mod7ru <- ugarchfit(spec = spec.sp1, data = ts.sp)
show(mod7ru)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu       0.74497    0.153760   4.8450 0.000001
## omega    0.80400    0.284209   2.8289 0.004671
## alpha1   0.12226    0.022102   5.5315 0.000000
## beta1    0.85434    0.021813  39.1664 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu       0.74497    0.171721   4.3382 0.000014
## omega    0.80400    0.336109   2.3921 0.016753
## alpha1   0.12226    0.028162   4.3413 0.000014
## beta1    0.85434    0.026423  32.3329 0.000000
## 
## LogLikelihood : -2377.839 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       6.0147
## Bayes        6.0384
## Shibata      6.0147
## Hannan-Quinn 6.0238
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.6270  0.4284
## Lag[2*(p+q)+(p+q)-1][2]    0.6322  0.6347
## Lag[4*(p+q)+(p+q)-1][5]    2.7320  0.4582
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      0.622  0.4303
## Lag[2*(p+q)+(p+q)-1][5]     1.867  0.6502
## Lag[4*(p+q)+(p+q)-1][9]     3.671  0.6450
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.6535 0.500 2.000  0.4189
## ARCH Lag[5]    1.3390 1.440 1.667  0.6356
## ARCH Lag[7]    1.9549 2.315 1.543  0.7269
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.0291
## Individual Statistics:              
## mu     0.08926
## omega  0.20235
## alpha1 0.27140
## beta1  0.16486
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.07 1.24 1.6
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value      prob sig
## Sign Bias           3.1027 0.0019860 ***
## Negative Sign Bias  0.9191 0.3583444    
## Positive Sign Bias  0.7084 0.4788761    
## Joint Effect       17.6088 0.0005296 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     30.73      0.04324
## 2    30     40.27      0.07958
## 3    40     48.40      0.14373
## 4    50     61.41      0.10989
## 
## 
## Elapsed time : 0.1409812

模型很接近IGARCH条件。

  • 尝试对标普500超额收益率拟合GARCH-M(1,1)模型:
library(rugarch)
spec.sp2 <- ugarchspec(
  mean.model = list(
    armaOrder=c(0,0),
    include.mean=TRUE,
    archm=TRUE, archpow=2),
  variance.model = list(
    model = "sGARCH", # standard GARCH model
    garchOrder = c(1,1) ) )
mod8ru <- ugarchfit(spec = spec.sp2, data = ts.sp)
show(mod8ru)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.542035    0.236018   2.2966 0.021643
## archm   0.010081    0.008885   1.1347 0.256520
## omega   0.829651    0.293213   2.8295 0.004662
## alpha1  0.123124    0.022286   5.5247 0.000000
## beta1   0.852261    0.022400  38.0478 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.542035    0.243968   2.2217 0.026300
## archm   0.010081    0.008913   1.1311 0.258009
## omega   0.829651    0.347876   2.3849 0.017083
## alpha1  0.123124    0.027802   4.4286 0.000009
## beta1   0.852261    0.027061  31.4946 0.000000
## 
## LogLikelihood : -2377.192 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       6.0156
## Bayes        6.0451
## Shibata      6.0156
## Hannan-Quinn 6.0270
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.7246  0.3946
## Lag[2*(p+q)+(p+q)-1][2]    0.7501  0.5869
## Lag[4*(p+q)+(p+q)-1][5]    3.0243  0.4026
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.7589  0.3837
## Lag[2*(p+q)+(p+q)-1][5]    1.8690  0.6497
## Lag[4*(p+q)+(p+q)-1][9]    3.4842  0.6771
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.5048 0.500 2.000  0.4774
## ARCH Lag[5]    1.0892 1.440 1.667  0.7066
## ARCH Lag[7]    1.6862 2.315 1.543  0.7833
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.327
## Individual Statistics:              
## mu     0.06463
## archm  0.03109
## omega  0.21419
## alpha1 0.26216
## beta1  0.16482
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.28 1.47 1.88
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value      prob sig
## Sign Bias           3.5833 3.601e-04 ***
## Negative Sign Bias  1.1596 2.466e-01    
## Positive Sign Bias  0.6211 5.347e-01    
## Joint Effect       22.1806 5.982e-05 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     23.86      0.20163
## 2    30     41.11      0.06741
## 3    40     40.63      0.39861
## 4    50     56.86      0.20554
## 
## 
## Elapsed time : 0.3657961