[R-SIG-Finance] Just finished Kris Boudt's course, running into errors from non-convergence in rugarch
Ilya Kipnis
ily@@kipni@ @ending from gm@il@com
Thu Nov 29 05:11:32 CET 2018
The variance.targeting does work, but it does impose an assumption on the
nature of the variance of the S&P 500 returns, that the variance is
naturally mean-reverting, and I'm not sure that's the case. While the VIX
certainly does tend to mean-revert more often than not, the times it
*doesn't* are the times that all of the volatility mean-reverting guys just
get absolutely blown up, whether it's 2008, when vol went up and up, or Feb
4-Feb 5 of 2018, when anyone that thought Feb 5 was a nice time to revert
the Feb 4 spike got blown up in 20 minutes after hours.
Will go with this solution for now in terms of trying to see if there's a
new VIX trading strategy, but I'm hoping I can relax the assumption in the
near future.
Thanks again.
On Wed, Nov 28, 2018 at 10:57 PM alexios galanos <alexios using 4dscape.com>
wrote:
> That's piqued my interest...here is my suggestion (which I have
> successfully tested) for a quick solution:
>
> 1. Use variance targeting:
>
> gjrSpec <- ugarchspec(mean.model = list(armaOrder =
> c(1,0)),variance.model = list(model = "gjrGARCH",
> variance.targeting=TRUE),distribution.model = "sstd")
>
> 2. remove the NA leftover from the return calculation:
> na.omit(spyRets)
>
>
> Alexios
>
>
> On 11/28/18 7:39 PM, Ilya Kipnis wrote:
> > image.png
> >
> > Unfortunately, the gosolnp method does not work.
> >
> > Tried implementing fit.control as best I understood it.
> >
> > image.png
> >
> > Also does not work.
> >
> > On Wed, Nov 28, 2018 at 10:33 PM alexios galanos <alexios using 4dscape.com
> > <mailto:alexios using 4dscape.com>> wrote:
> >
> > Try setting the solver in the resume command to "gosolnp".
> > It may also have helped to set fit.control(scale=1) in the
> ugarchroll,
> > but you can set this in resume as well.
> >
> > Alexios
> >
> > On 11/28/18 7:22 PM, Ilya Kipnis wrote:
> > > I just completed Kris Boudt's datacamp course on GARCH models, and
> > > thought I'd give it a spin in a more reasonable setting. I've run
> > into
> > > an error that the course didn't cover. I'm using a rolling window
> > of 504
> > > trading days to try to fit a GJR-GARCH with AR1 return
> > innovations and a
> > > skewed student t distribution and refitting the model every 22
> > days (so,
> > > basically every month) on SPY returns.
> > >
> > > In the course, it was possible to convert this output into a data
> > frame,
> > > with an as.data.frame command.
> > >
> > > Unfortunately, the course didn't cover what happened when over the
> > > course of ~300 model fits, there would be the occasional failure
> to
> > > converge, which throws the following error:
> > >
> > > image.png
> > >
> > > Here's my MRE:
> > >
> > > require(rugarch)
> > > require(quantmod)
> > >
> > > # get SPY data from Yahoo (also tried with Quandl, data isn't the
> > issue)
> > > getSymbols("SPY", from = '1990-01-01')
> > >
> > > spyRets <- Return.calculate(Ad(SPY))
> > >
> > > # GJR garch with AR1 innovations under a skewed student T
> > distribution
> > > for returns
> > > gjrSpec <- ugarchspec(mean.model = list(armaOrder = c(1,0)),
> > > variance.model = list(model = "gjrGARCH"),
> > > distribution.model = "sstd")
> > >
> > > # Use rolling window of 504 days, refitting the model every 22
> > trading days
> > > t1 <- Sys.time()
> > > garchroll <- ugarchroll(gjrSpec, data = spyRets,
> > > n.start = 504, refit.window = "moving",
> > > refit.every = 22)
> > > t2 <- Sys.time()
> > > print(t2-t1)
> > >
> > > # try to convert predictions to data frame, as in course -- error
> > thrown
> > > regarding non-converged estimation windows
> > > garchroll <- as.data.frame(garchroll)
> > >
> > > With a screenshot for better readability:
> > >
> > > image.png
> > > I also tried the resume command from the following post
> > > https://stat.ethz.ch/pipermail/r-sig-finance/2013q2/011720.html,
> > which
> > > did not solve my problem.
> > >
> > > I feel that this is a pretty straightforward application of the
> > rugarch
> > > package, and that there is most likely a solution that simply
> wasn't
> > > covered in the course. I'd be greatly appreciative if someone
> > could help
> > > me over this hill (albeit at the risk of revealing that I'm not
> > exactly
> > > an expert on GARCH models).
> > >
> > > Thank you so much.
> > >
> > > Sincerely,
> > >
> > > Ilya Kipnis (author of Quantstrat TradeR)
> > >
> > > _______________________________________________
> > > R-SIG-Finance using r-project.org <mailto:R-SIG-Finance using 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.
> > >
> >
> > _______________________________________________
> > R-SIG-Finance using r-project.org <mailto:R-SIG-Finance using 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.
> >
>
[[alternative HTML version deleted]]
More information about the R-SIG-Finance
mailing list