[R-SIG-Finance] Forecast of ARMA-GARCH model in R
Tom Huppertz
huppertz.tom at gmail.com
Mon Jul 20 10:44:05 CEST 2015
I managed to forecast a GARCH model yesterday and run a Monte Carlo
simulation on R. Nevertheless, I can't do the same with an ARMA-GARCH. I
tested 4 different method but without achieving an ARMA-GARCH simulation
with my data.
Thanks in advance !
Tom Huppertz
The packages and the data I used:
|library(quantmod)
library(tseries)
library(TSA)
library(betategarch)
library(mcsm)
library(PerformanceAnalytics)
library(forecast)
library(fGarch)
library(GEVStableGarch)
getSymbols("DEXB.BR",from="2005-07-01", to="2015-07-01")
STOCK = DEXB.BR
STOCK.rtn=diff(STOCK[,6] )
STOCK.diff = STOCK.rtn[2:length(STOCK.rtn)]
ARI_2_1=arima(STOCK[,6],order=c(2,1,1))
GA_1_1=garch(ARI_2_1$residuals, order = c(1,1))
|
First tested method
|specifi = garchSpec(model = list(ar = c(0.49840, -0.0628), ma =c(-0.4551), omega = 8.393e-08, alpha = 1.356e-01, beta = 8.844e-01))
garchSim(spec = specifi, n = 500, n.start = 200, extended = FALSE)
|
This lead to a "NaN" forecast.
|garchSim(spec = specifi, n = 500)
n=1000
armagarch.sim_1 = rep(0,n)
armagarch.sim_50 = rep(0,n)
armagarch.sim_100 = rep(0,n)
for(i in 1:n)
{
armagarch.sim=garchSim(spec = specifi, n = 500, n.start = 200, extended = FALSE)
armagarch.sim_1[i] = armagarch.sim[1]
armagarch.sim_50[i] = armagarch.sim[50]
armagarch.sim_100[i] = armagarch.sim[100]
}
|
Second tested method
|GSgarch.Sim(N = 500, mu = 0, a = c(0.49840, -0.0628), b = c(-0.4551),
omega = 8.393e-08, alpha = c(1.356e-01), gm = c(0), beta = c(8.844e-01),
cond.dist = "norm")
|
This part works.
|n=10000
Garmagarch.sim_1 = rep(0,n)
Garmagarch.sim_50 = rep(0,n)
Garmagarch.sim_100 = rep(0,n)
for(i in 1:n)
{
Garmagarch.sim= GSgarch.Sim(N = 500, mu = 0, a = c(0.49840, -0.0628), b = c(-0.4551),omega = 8.393e-08, alpha = c(1.356e-01), gm = c(0), beta c(8.844e-01), cond.dist = "norm")
Garmagarch.sim_1[i] = Garmagarch.sim[1]
Garmagarch.sim_50[i] = Garmagarch.sim[50]
Garmagarch.sim_100[i] = Garmagarch.sim[100]
}
|
The simulation runs but
|> Garmagarch.sim[1]
$model
[1] "arma(2,1)-aparch(1,1) ## Intercept:FALSE"
|
and
|> Garmagarch.sim[50]
$<NA>
NULL
|
Third tested method
|ga_arma = garch.sim(alpha=c(8.393e-08,1.356e-01),beta =8.844e-01 ,n=500, ntrans=200)
|
This lead to
|Error in garch.sim(alpha = c(8.393e-08, 0.1356), beta = 0.8844, n = 500, :
Check model: it does not have finite variance
arima.sim(ARI_2_1, 500, innov = ga_arma ,n.start = 200)
|
And this to
|Error in arima.sim(ARI_2_1, 500, innov = ga_arma, n.start = 200) :
la partie 'ar' du mopdèle n'est pas stationaire
|
which mean that the 'ar' part of the model isn't stationnary.
Fourth tested method
|forecast(ARI_2_1, h = 500, bootstrap = TRUE, npaths=200)
|
This one actually works but I don't know how to add the GARCH component.
|forecast(specifi, h = 500, bootstrap = TRUE, npaths=200)
|
[[alternative HTML version deleted]]
More information about the R-SIG-Finance
mailing list