[R-SIG-Finance] help needed for rugarch forecast function
alexios
alexios at 4dscape.com
Thu Oct 27 20:59:04 CEST 2011
Dear John,
The reason possibly no one, including the developer, have not replied is
that you provide a very large example, in a specialized package, for
which is it not possible to reproduce without the data, but is also not
consistent in places:
1. "m.pred<- ugarchforecast(cl_ar4.fit, data = yCL05, external.forecasts
= list(mregfor = ext), n.ahead = 1, n.roll = 322)"
You did not tell us what cl_ar4.fit is (since you are using the data
option, it should be of class uGARCHspec).
2. In the next example you set "fixed.pars = list(ar33 = 0,omega = 0)"
for an arma(4,0) model. Did you mean "ar3=0".
As the developer, I would be happy to look into this, but you should
please take the time to create fully reproducible example and sent me an
email off list with the dataset so that I might try to see whether it is
a bug in the handling of this or some wrong use of the functions.
Regards,
Alexios
On 27/10/2011 19:29, johnzli at comcast.net wrote:
> Dear all:
>
> I posted this question before, and did not receive feedback. If I posted in the wrong mailing list, I apologize here in advance, and will post it to the right place next time.
>
> I am building a model for forecasting using rugarch package (version 1.0-5, R version 2.13.2). To verify the behavior of rugarch model, I also performed the same exercise using simple linear regression lm. All the data here is return times 100, so 0.5 represents 0.5%. If we look at the regression coefficients obtained from rugarch and lm, they are fairly close. So for practical purpose, I would argue that the DAC number given by DACTest from rugarch package should be very close to each other, and they are widely different.
>
> I suspect that when you perform regression in rugarch armaOrder = c(0, 0), and define regressors by using external.regressors, somehow the forecast function ugarchforecast will give results that are different from prediction given by predict.lm function.
>
> Can anyone kindly provide your feedback?
>
> Thank you very much.
>
>
>
> The code and selected output looks like this:
>
>
>> min.model<- lm(yCL05 ~ -1, data = data.frame(yCL05, xCL05))
>> fwd.model<- step(min.model, direction = "forward", scope = (~CL05_1 + CL05_2 + CL05_3 + CL05_4), trace = 0)
>> summary(fwd.model)
>>
>> summary(fwd.model)
>
> Call:
> lm(formula = yCL05 ~ CL05_1 + CL05_4 + CL05_2 - 1, data = data.frame(yCL05,
> xCL05))
>
> Residuals:
> Min 1Q Median 3Q Max
> -0.48690 -0.07605 0.00166 0.07853 0.64095
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> CL05_1 0.98036 0.01746 56.16< 2e-16 ***
> CL05_4 -0.14149 0.01228 -11.53< 2e-16 ***
> CL05_2 -0.11615 0.02038 -5.70 1.31e-08 ***
> ---
> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 0.1312 on 3217 degrees of freedom
> Multiple R-squared: 0.7201, Adjusted R-squared: 0.7199
> F-statistic: 2759 on 3 and 3217 DF, p-value:< 2.2e-16
>
>> pred<- predict(fwd.model, newdata = tail(xCL05, (dailyDataPoint + 1)))
>> obsx<- tail(yCL05, dailyDataPoint + 1)
>> print(DACTest(as.matrix(pred), as.matrix(obsx), test = "PT", conf.level = 0.95))
> $Test
> [1] "Pesaran and Timmermann"
>
> $Stat
> [1] 12.43268
>
> $p.value
> [1] 0
>
> $H0
> [1] "Independently Distributed"
>
> $Decision
> [1] "Reject H0"
>
> $DirAcc
> [1] 0.8452012
>> print(DACTest(as.matrix(pred), as.matrix(obsx), test = "AG", conf.level = 0.95))
> $Test
> [1] "Anatolyev and Gerko"
>
> $Stat
> [1] 12.59703
>
> $p.value
> [1] 0
>
> $H0
> [1] "No Predictability"
>
> $Decision
> [1] "Reject H0"
>
> $DirAcc
> [1] 0.8452012
>
> # Now results from rugarch using sGARCH(1, 1) + ARMA(0, 0) + XREG(M)
>> ext<- data.matrix(xCL05)
>> startPar = as.list(coef(m.fit))
>> m.spec<- ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(0, 0), include.mean = FALSE, external.regressors = ext), distribution.model = "std", start.pars = startPar, fixed.pars = list(mxreg3 = 0,omega = 0))
> m.fit<- ugarchfit(data = yCL05, spec = m.spec, out.sample = 322, solver = "solnp", fit.control = list(scale = 1))
>> m.fit
> *---------------------------------*
> * GARCH Model Fit *
> *---------------------------------*
>
> Conditional Variance Dynamics
> -----------------------------------
> GARCH Model : sGARCH(1,1)
> Mean Model : ARFIMA(0,0,0)
> Distribution : std
>
> Optimal Parameters
> ------------------------------------
> Estimate Std. Error t value Pr(>|t|)
> mxreg1 0.975195 0.013854 70.3926 0
> mxreg2 -0.119729 0.015947 -7.5080 0
> mxreg3 0.000000 NA NA NA
> mxreg4 -0.132482 0.009730 -13.6159 0
> omega 0.000000 NA NA NA
> alpha1 0.035356 0.004597 7.6919 0
> beta1 0.963644 0.004773 201.9094 0
> shape 10.396033 1.192115 8.7207 0
>
> Robust Standard Errors:
> Estimate Std. Error t value Pr(>|t|)
> mxreg1 0.975195 0.014851 65.6665 0
> mxreg2 -0.119729 0.016830 -7.1139 0
> mxreg3 0.000000 NA NA NA
> mxreg4 -0.132482 0.010469 -12.6544 0
> omega 0.000000 NA NA NA
> alpha1 0.035356 0.006289 5.6217 0
> beta1 0.963644 0.006833 141.0259 0
> shape 10.396033 1.182089 8.7946 0
>
> LogLikelihood : 3895.616
>
> Information Criteria
> ------------------------------------
>
> Akaike -1.5092
> Bayes -1.4990
> Shibata -1.5092
> Hannan-Quinn -1.5056
> ...
>> m.pred<- ugarchforecast(cl_ar4.fit, data = yCL05, external.forecasts = list(mregfor = ext), n.ahead = 1, n.roll = 322)
>> fpm(m.pred, summary = TRUE)
> MSE MAE DAC
> 1 0.09805421 0.2428945 0.5434783
>
> The problem arises when you compare DAC given by rugarch package and the one given by DACTest from rugarch package for lm regression. In another test (the results are not listed here), I ran AR(4) model in rugarch with ugarchspec like:
>> m.spec<- ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1)), mean.model = list(armaOrder = c(4, 0), include.mean = FALSE), distribution.model = "std", start.pars = startPar, fixed.pars = list(ar33 = 0,omega = 0))
> and then ran
>> fpm(m.pred, summary = TRUE)
>
> then it will give a results similar to DAC from the one obtained from lm package.
>
> It seems the problem arises when you try to perform regression with external regressors with armaOrder = c(0, 0) ...
>
> Any help will be greatly appreciated..
>
>
> Thank you.
>
> John Li
>
> [[alternative HTML version deleted]]
>
>
>
>
> _______________________________________________
> 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