How to use garch model?

garchmodel R

There are many ways to find volatility,GARCH model is being to  learn with R .

R code to use analyse AAPL stock price

> C(aapl.garch11.fit)

[1] 0.1889649
> uncmean(aapl.garch11.fit)
[1] 0.007145279
> ni.garch11 <- newsimpact(aapl.garch11.fit)
> plot(ni.garch11$zx, ni.garch11$zy, type="l", lwd=2, col="blue",main="GARCH(1,1)-News Impact", ylab=ni.garch11$yexpr, xlab=ni.garch11$xexpr)
> egarch11.spec = ugarchspec(variance.model = list(model="eGARCH",garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)))
>
> aapl.egarch11.fit = ugarchfit(spec=egarch11.spec, data=ret)
> coef(aapl.egarch11.fit)
         mu       omega      alpha1       beta1
 0.02163174 -1.14814240  0.07408394  0.31963281
     gamma1
 0.33290745
> ni.egarch11 <- newsimpact(aapl.egarch11.fit)
> plot(ni.egarch11$zx, ni.egarch11$zy, type="l", lwd=2, col="blue",
+      main="EGARCH(1,1) - News Impact",
+      ylab=ni.egarch11$yexpr, xlab=ni.egarch11$xexpr)
> tgarch11.spec = ugarchspec(variance.model = list(model="fGARCH",submodel="TGARCH", garchOrder=c(1,1)),
+  mean.model = list(armaOrder=c(0,0)))
> aapl.tgarch11.fit = ugarchfit(spec=tgarch11.spec, data=ret)
> coef(aapl.egarch11.fit)
         mu       omega      alpha1       beta1
 0.02163174 -1.14814240  0.07408394  0.31963281
     gamma1
 0.33290745
> ni.tgarch11 <- newsimpact(aapl.tgarch11.fit)
> plot(ni.tgarch11$zx, ni.tgarch11$zy, type="l", lwd=2, col="blue",
+      main="TGARCH(1,1) - News Impact",
+      ylab=ni.tgarch11$yexpr, xlab=ni.tgarch11$xexpr)
> garch11.spec = ugarchspec(variance.model = list(garchOrder=c(1,1)),mean.model = list(armaOrder=c(0,0)),fixed.pars=list(mu = 0, omega=0.1, alpha1=0.1,
+ beta1 = 0.7))
> garch11.sim = ugarchpath(garch11.spec, n.sim=1000)

Post a Comment

0 Comments