[R-SIG-Finance] rugarch and fGarch

alexios ghalanos alexios at 4dscape.com
Wed Jun 13 21:41:34 CEST 2012


Marco,

1. Use:
GAA3=ugarchfit(spec=modeltofit,data=last(SPY.log.ret,1371), 
fit.control=list(scale=1))
This should get a better result so that the evaluation of the robust
estimates does not fail.

2. Likelihoods are very close but omega and their s.e. is somewhat 
different.

To better compare the results use the coefficients from the 2 fits in 
rugarch:

spec1 = modeltofit
setfixed(spec1)<-as.list(coef(GA3))
spec2 = modeltofit
setfixed(spec2)<-as.list(coef(GAA3))

fit1 = ugarchfit(spec1, last(SPY.log.ret,1371), 
fit.control=list(fixed.se=1))

fit2 = ugarchfit(spec2, last(SPY.log.ret,1371), 
fit.control=list(fixed.se=1))


round(cbind(coef(fit1), coef(fit2)),4)
          fGarch rugarch
mu      0.0002  0.0002
ar1    -0.0873 -0.0861
omega   0.0004  0.0006
alpha1  0.0930  0.0904
beta1   0.9092  0.9161
gamma1  1.0000  1.0000
delta   0.9511  0.8431
skew    0.8360  0.8337
shape   7.1344  7.3343

Look at their long run sigma:
sqrt(uncvariance(fit1))
0.01391264

sqrt(uncvariance(fit2))
0.01378647

As i said in the earlier email, differences are likely related to the 
gamma parameter hitting its limit, but will investigate some alternate
strategies for the omega coefficient scaling when time permits.

3. I don't really understand what you want to do. If you just want the 
long run unconditional forecast then extract the coefficients from each fit:

cf = as.data.frame(volforecast, which = "coefmat", refit=2)
cfnames = rownames(cf)
cf = cf[,1]
names(cf)=cfnames
spec = modeltofit
setfixed(spec)<-as.list(cf)
uncvariance(spec)



sigma=as.data.frame(volforecast,which="sigma")

Is correct. It returns a n.ahead x n.roll matrix.
For the time being, it only support n.ahead<=refit.every.

If you want to create long run custom type forecasts just wrap your own 
ugarchfit+ugarchforecast function (after all that is all that ugarchroll 
does). Read the documentation on the proper use of the "out.sample" option.

4. NO. The forecast date shown is the ACTUAL future forecast date (since 
this is an out.of sample rolling forecast for which dates exists). In 
the ugarchforecast method, when there are no out.sample dates to draw 
from, the program generates actual future forecast dates (not taking 
into account holidays etc).

-Alexios


On 13/06/2012 14:13, Belgarath wrote:
> Hello Alexios,
>
> thank you for the quick reply! Apologies but yesterday yahoo finance was not
> working so could not follow up with an appropriate reproducible example:
>
> 1)
> ----
> getSymbols("^GSPC", src="yahoo")
> SPY.log.ret=ClCl(GSPC)
> GA3=garchFit(formula=~arma(1,0)+aparch(1,1),data=last(SPY.log.ret,1371),cond.dist="sstd")
> summary(GA3)
> modeltofit=ugarchspec(variance.model = list(model = "apARCH", garchOrder =
> c(1, 1),
>                      submodel = NULL, external.regressors = NULL,
> variance.targeting = FALSE),
>                      mean.model = list(armaOrder = c(1, 0), include.mean =
> TRUE, archm = FALSE,
>                      archpow = 1, arfima = FALSE, external.regressors = NULL,
> archex = FALSE),
>                      distribution.model = "sstd", start.pars = list(),
> fixed.pars = list())
>
> GAA3=ugarchfit(spec=modeltofit,data=last(SPY.log.ret,1371))
> show(GAA3)
> volforecast=ugarchroll(spec=modeltofit,data=last(SPY.log.ret,1371), n.ahead
> = 21,
>                         forecast.length = 420, refit.every = 21)
> sigma=as.data.frame(volforecast,which="density",n.ahead=21)
> sigmat <- as.POSIXct(strptime(sigma[,1],format="%Y-%m-%d"))
> sigma2 <- xts(sigma[,3],order.by=sigmat)*100*sqrt(252)
> plot(sigma2)
> ---
>
> Detailed results are below, but to reply to your points:
> 2) rugarch omega   is 0.000618    t:1.5062e+00 p:0.132023 while fGarch omega
> is 3.922e-04   t:3.970  p:7.19e-05 which is more significant.
>
> 3) Is the code above usage correct to extract the forecasts? I tried to use
> the sigma=as.data.frame(volforecast, which = "sigma") but it only return the
> first 21 forecasts. How do I extract the long term mean of the st dev?
>
> 4) I have one more question: the dates in the
> sigma=as.data.frame(volforecast,which="density",n.ahead=21) are alligned
> with the date the forecast refers to no the date the forcast is made (ie. it
> will be delayed by 21 days in a chart) correct?
>
> Thank you again for the help and the package!
> Marco
>
>
>
> *****************
>> show(GAA3)
>
> *---------------------------------*
> *          GARCH Model Fit        *
> *---------------------------------*
>
> Conditional Variance Dynamics 	
> -----------------------------------
> GARCH Model	: apARCH(1,1)
> Mean Model	: ARFIMA(1,0,0)
> Distribution	: sstd
>
> Optimal Parameters
> ------------------------------------
>          Estimate  Std. Error     t value Pr(>|t|)
> mu      0.000197    0.000007  2.7154e+01 0.000000
> ar1    -0.086149    0.000122 -7.0664e+02 0.000000
> omega   0.000618    0.000411  1.5062e+00 0.132023
> alpha1  0.090424    0.010405  8.6908e+00 0.000000
> beta1   0.916128    0.010687  8.5724e+01 0.000000
> gamma1  1.000000    0.000000  2.5738e+06 0.000000
> delta   0.844145    0.130924  6.4476e+00 0.000000
> skew    0.833679    0.028852  2.8895e+01 0.000000
> shape   7.325115    1.542399  4.7492e+00 0.000002
>
> Robust Standard Errors:
>          Estimate  Std. Error  t value Pr(>|t|)
> mu      0.000197         NaN      NaN      NaN
> ar1    -0.086149         NaN      NaN      NaN
> omega   0.000618         NaN      NaN      NaN
> alpha1  0.090424         NaN      NaN      NaN
> beta1   0.916128         NaN      NaN      NaN
> gamma1  1.000000         NaN      NaN      NaN
> delta   0.844145         NaN      NaN      NaN
> skew    0.833679         NaN      NaN      NaN
> shape   7.325115         NaN      NaN      NaN
>
> LogLikelihood : 4133.434
>
> Information Criteria
> ------------------------------------
>
> Akaike       -6.0167
> Bayes        -5.9824
> Shibata      -6.0168
> Hannan-Quinn -6.0038
>
> Q-Statistics on Standardized Residuals
> ------------------------------------
>        statistic p-value
> Lag10     11.45  0.2459
> Lag15     16.60  0.2780
> Lag20     18.74  0.4737
>
> H0 : No serial correlation
>
> Q-Statistics on Standardized Squared Residuals
> ------------------------------------
>        statistic   p-value
> Lag10     29.72 0.0004892
> Lag15     33.15 0.0027369
> Lag20     36.37 0.0094979
>
> ARCH LM Tests
> ------------------------------------
>               Statistic DoF   P-Value
> ARCH Lag[2]      15.81   2 0.0003695
> ARCH Lag[5]      16.98   5 0.0045286
> ARCH Lag[10]     30.99  10 0.0005890
>
> Nyblom stability test
> ------------------------------------
> Joint Statistic:  NA
> Individual Statistics:
> mu     0.2380
> ar1    0.2163
> omega  0.1923
> alpha1 0.1939
> beta1  0.2190
> gamma1     NA
> delta  0.2084
> skew   0.1054
> shape  0.2543
>
> Asymptotic Critical Values (10% 5% 1%)
> Joint Statistic:     	 2.1 2.32 2.82
> Individual Statistic:	 0.35 0.47 0.75
>
> Sign Bias Test
> ------------------------------------
>                     t-value     prob sig
> Sign Bias           0.3575 0.720737
> Negative Sign Bias  2.5732 0.010180  **
> Positive Sign Bias  2.7813 0.005489 ***
> Joint Effect       14.4861 0.002313 ***
>
>
> Adjusted Pearson Goodness-of-Fit Test:
> ------------------------------------
>    group statistic p-value(g-1)
> 1    20     30.47     0.046075
> 2    30     40.31     0.078949
> 3    40     54.67     0.049050
> 4    50     74.99     0.009861
>
>
> Elapsed time : 5.466
>
>> summary(GA3)
>
> Title:
>   GARCH Modelling
>
> Call:
>   garchFit(formula = ~arma(1, 0) + aparch(1, 1), data = last(SPY.log.ret,
>      1371), cond.dist = "sstd")
>
> Mean and Variance Equation:
>   data ~ arma(1, 0) + aparch(1, 1)
> <environment: 0x000000000e8e8e68>
>   [data = last(SPY.log.ret, 1371)]
>
> Conditional Distribution:
>   sstd
>
> Coefficient(s):
>           mu          ar1        omega       alpha1       gamma1        beta1
>   0.00022015  -0.08726888   0.00039220   0.09300673   0.99999999   0.90917036
>        delta         skew        shape
>   0.95108469   0.83598044   7.13436954
>
> Std. Errors:
>   based on Hessian
>
> Error Analysis:
>           Estimate  Std. Error  t value Pr(>|t|)
> mu      2.202e-04   2.702e-04    0.815 0.415301
> ar1    -8.727e-02   2.557e-02   -3.413 0.000643 ***
> omega   3.922e-04   9.879e-05    3.970 7.19e-05 ***
> alpha1  9.301e-02   1.157e-02    8.035 8.88e-16 ***
> gamma1  1.000e+00   1.085e-02   92.183  < 2e-16 ***
> beta1   9.092e-01   1.112e-02   81.759  < 2e-16 ***
> delta   9.511e-01   1.667e-01    5.705 1.16e-08 ***
> skew    8.360e-01   3.064e-02   27.284  < 2e-16 ***
> shape   7.134e+00   1.543e+00    4.625 3.75e-06 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Log Likelihood:
>   4131.182    normalized:  3.013262
>
> Description:
>   Wed Jun 13 14:57:49 2012 by user: cora
>
>
> Standardised Residuals Tests:
>                                  Statistic p-Value
>   Jarque-Bera Test   R    Chi^2  1584.761  0
>   Shapiro-Wilk Test  R    W      0.9597795 0
>   Ljung-Box Test     R    Q(10)  12.32339  0.2639963
>   Ljung-Box Test     R    Q(15)  16.8469   0.3280988
>   Ljung-Box Test     R    Q(20)  18.48151  0.5557211
>   Ljung-Box Test     R^2  Q(10)  9.478356  0.4873852
>   Ljung-Box Test     R^2  Q(15)  12.33782  0.6532996
>   Ljung-Box Test     R^2  Q(20)  13.34997  0.8618686
>   LM Arch Test       R    TR^2   29.52316  0.003292551
>
> Information Criterion Statistics:
>        AIC       BIC       SIC      HQIC
> -6.013395 -5.979106 -6.013480 -6.000563
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/rugarch-and-fGarch-tp4633077p4633253.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>



More information about the R-SIG-Finance mailing list