# Questions on fitted garch(1,1)

 Classic List Threaded
7 messages
Reply | Threaded
Open this post in threaded view
|

## Questions on fitted garch(1,1)

 Hi everyone, I'm trying to predict volatility using a garch(1,1) model and I'm running into some interesting issues I cannot find an answer for. Suppose I have the following code: library(quantmod) library(tseries) library(fGarch) # get some returns r = dailyReturn(Ad(getSymbols("SPY", from="2000-01-01", to="2010-11-04", auto.assign=F))) # fit models garch.fitted = garch(na.omit(r), order = c(1,1)) fgarch.fitted = fGarch::garchFit(~ garch(1,1), data = as.zoo(na.omit(r)), trace = FALSE) Now if I look at the values of the coefficients for both fitted models they are not the same: > coef(garch.fitted)           a0           a1           b1 1.339912e-06 8.165689e-02 9.101754e-01 > coef(fgarch.fitted)           mu        omega       alpha1        beta1 4.990616e-04 1.370880e-06 8.307080e-02 9.086447e-01 Q1) Why are they different? What do I have to change to make the coefficient values of fgarch.fitted the same as garch.fitted? If I try to predict the volatility with: predict(garch.fitted) I get the "conditional standard deviation predictions" (an interval) for every period return in r. Q2) Is this a 1 period prediction (i.e. the volatility prediction for the next day)? How do I get a prediction for let's say 2 periods in the future? If I use predict(fgarch.fitted) I get: > predict(fgarch.fitted)    meanForecast   meanError standardDeviation 1  0.0004990616 0.006677350       0.006677350 2  0.0004990616 0.006751925       0.006751925 3  0.0004990616 0.006825079       0.006825079 4  0.0004990616 0.006896859       0.006896859 5  0.0004990616 0.006967315       0.006967315 6  0.0004990616 0.007036491       0.007036491 7  0.0004990616 0.007104428       0.007104428 8  0.0004990616 0.007171167       0.007171167 9  0.0004990616 0.007236745       0.007236745 10 0.0004990616 0.007301198       0.007301198 Q3) Why is the meanForecast for all 10 future periods the same? Thanks, -Mark- predict(garch)         [[alternative HTML version deleted]] _______________________________________________ [hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

## Re: Questions on fitted garch(1,1)

 One possible case may be the different way of initializing the volatility estimates. You can look into the codes of 2 different packages on how they are estimating the volatility for the 1st day. You can also compare the estimated parameters which set is giving max value of the likelihood function, because may be they are using different optimizer? Thanks,
Reply | Threaded
Open this post in threaded view
|

## Re: Questions on fitted garch(1,1)

 In reply to this post by Mark Breman-3 The default for fGarch::garchFit is to estimate the mean, assuming a non-zero mean dataset is passed, as can be seen from the returned "mu" parameter ( a call to 'args(garchFit)' should highlight the 'include.mean' argument ). The default for tseries garch is to assume zero mean data. Demean the data before passing to tseries garch by the estimated 'mu' value from 'fgarch.fitted' and you should obtain closer results. -Alexios On 11/4/2010 8:44 PM, Mark Breman wrote: > Hi everyone, > > I'm trying to predict volatility using a garch(1,1) model and I'm running > into some interesting issues I cannot find an answer for. > > Suppose I have the following code: > > library(quantmod) > library(tseries) > library(fGarch) > > # get some returns > r = dailyReturn(Ad(getSymbols("SPY", from="2000-01-01", to="2010-11-04", > auto.assign=F))) > > # fit models > garch.fitted = garch(na.omit(r), order = c(1,1)) > fgarch.fitted = fGarch::garchFit(~ garch(1,1), data = as.zoo(na.omit(r)), > trace = FALSE) > > Now if I look at the values of the coefficients for both fitted models they > are not the same: > >> coef(garch.fitted) >           a0           a1           b1 > 1.339912e-06 8.165689e-02 9.101754e-01 >> coef(fgarch.fitted) >           mu        omega       alpha1        beta1 > 4.990616e-04 1.370880e-06 8.307080e-02 9.086447e-01 > > Q1) Why are they different? What do I have to change to make the coefficient > values of fgarch.fitted the same as garch.fitted? > > If I try to predict the volatility with: predict(garch.fitted) I get the > "conditional standard deviation predictions" (an interval) for every period > return in r. > > Q2) Is this a 1 period prediction (i.e. the volatility prediction for the > next day)? How do I get a prediction for let's say 2 periods in the future? > > > If I use predict(fgarch.fitted) I get: > >> predict(fgarch.fitted) >    meanForecast   meanError standardDeviation > 1  0.0004990616 0.006677350       0.006677350 > 2  0.0004990616 0.006751925       0.006751925 > 3  0.0004990616 0.006825079       0.006825079 > 4  0.0004990616 0.006896859       0.006896859 > 5  0.0004990616 0.006967315       0.006967315 > 6  0.0004990616 0.007036491       0.007036491 > 7  0.0004990616 0.007104428       0.007104428 > 8  0.0004990616 0.007171167       0.007171167 > 9  0.0004990616 0.007236745       0.007236745 > 10 0.0004990616 0.007301198       0.007301198 > > Q3) Why is the meanForecast for all 10 future periods the same? > > Thanks, > > -Mark- > > > > predict(garch) > > [[alternative HTML version deleted]] > > _______________________________________________ > [hidden email] 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. > > _______________________________________________ [hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

## Re: Questions on fitted garch(1,1)

 Taking Alexios' advice will probably help, but I wouldn't be surprised if they are still not the same.  The garch likelihood is extremely tricky to optimize -- specialized optimizers would be the ideal. Assuming you can give starting values to the optimizer in both cases, you can give the other's answer to each and see what happens. On 04/11/2010 21:02, alexios wrote: > The default for fGarch::garchFit is to estimate the mean, assuming a > non-zero mean dataset is passed, as can be seen from the returned "mu" > parameter ( a call to 'args(garchFit)' should highlight the > 'include.mean' argument ). The default for tseries garch is to assume > zero mean data. > > Demean the data before passing to tseries garch by the estimated 'mu' > value from 'fgarch.fitted' and you should obtain closer results. > > -Alexios > > > > On 11/4/2010 8:44 PM, Mark Breman wrote: >> Hi everyone, >> >> I'm trying to predict volatility using a garch(1,1) model and I'm running >> into some interesting issues I cannot find an answer for. >> >> Suppose I have the following code: >> >> library(quantmod) >> library(tseries) >> library(fGarch) >> >> # get some returns >> r = dailyReturn(Ad(getSymbols("SPY", from="2000-01-01", to="2010-11-04", >> auto.assign=F))) >> >> # fit models >> garch.fitted = garch(na.omit(r), order = c(1,1)) >> fgarch.fitted = fGarch::garchFit(~ garch(1,1), data = as.zoo(na.omit(r)), >> trace = FALSE) >> >> Now if I look at the values of the coefficients for both fitted models they >> are not the same: >> >>> coef(garch.fitted) >>            a0           a1           b1 >> 1.339912e-06 8.165689e-02 9.101754e-01 >>> coef(fgarch.fitted) >>            mu        omega       alpha1        beta1 >> 4.990616e-04 1.370880e-06 8.307080e-02 9.086447e-01 >> >> Q1) Why are they different? What do I have to change to make the coefficient >> values of fgarch.fitted the same as garch.fitted? >> >> If I try to predict the volatility with: predict(garch.fitted) I get the >> "conditional standard deviation predictions" (an interval) for every period >> return in r. >> >> Q2) Is this a 1 period prediction (i.e. the volatility prediction for the >> next day)? How do I get a prediction for let's say 2 periods in the future? >> >> >> If I use predict(fgarch.fitted) I get: >> >>> predict(fgarch.fitted) >>     meanForecast   meanError standardDeviation >> 1  0.0004990616 0.006677350       0.006677350 >> 2  0.0004990616 0.006751925       0.006751925 >> 3  0.0004990616 0.006825079       0.006825079 >> 4  0.0004990616 0.006896859       0.006896859 >> 5  0.0004990616 0.006967315       0.006967315 >> 6  0.0004990616 0.007036491       0.007036491 >> 7  0.0004990616 0.007104428       0.007104428 >> 8  0.0004990616 0.007171167       0.007171167 >> 9  0.0004990616 0.007236745       0.007236745 >> 10 0.0004990616 0.007301198       0.007301198 >> >> Q3) Why is the meanForecast for all 10 future periods the same? >> >> Thanks, >> >> -Mark- >> >> >> >> predict(garch) >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> [hidden email] 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. >> >> > > _______________________________________________ > [hidden email] 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. > -- Patrick Burns [hidden email] http://www.burns-stat.comhttp://www.portfolioprobe.com/blog_______________________________________________ [hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

## Re: Questions on fitted garch(1,1)

 Hi everyone, As a followup on my three fitted garch questions; Yes indeed, if I give the estimated coefficients of fgarch.fitted as initial values to garch() the results are much more inline with each other: > coef(garch(na.omit(r), order = c(1,1), control=garch.control(start=c(1.3705e-06,8.1789e-02,9.0995e-01))))  ***** ESTIMATION WITH ANALYTICAL GRADIENT *****      I     INITIAL X(I)        D(I)      1     1.370500e-06     1.000e+00      2     8.178900e-02     1.000e+00      3     9.099500e-01     1.000e+00     IT   NF      F         RELDF    PRELDF    RELDX   STPPAR   D*STEP NPRELDF      0    1 -1.093e+04      1   13 -1.093e+04  4.54e-09  1.67e-08  1.1e-09  4.3e+13  2.1e-09  3.63e+05      2   24 -1.093e+04 -1.30e-14  2.64e-14  8.1e-15  1.6e+00  1.5e-14 -1.22e-03  ***** FALSE CONVERGENCE *****  FUNCTION    -1.093479e+04   RELDX        8.076e-15  FUNC. EVALS      24         GRAD. EVALS       2  PRELDF       2.641e-14      NPRELDF     -1.222e-03      I      FINAL X(I)        D(I)          G(I)      1    1.372553e-06     1.000e+00    -1.965e+04      2    8.178900e-02     1.000e+00     2.046e+00      3    9.099500e-01     1.000e+00    -1.478e+01           a0           a1           b1 1.372553e-06 8.178900e-02 9.099500e-01 Very nice, thank you! Now only question 2 and 3 remain a mystery to me. Kind regards, -Mark- 2010/11/4 Patrick Burns <[hidden email]> > Taking Alexios' advice will probably > help, but I wouldn't be surprised if > they are still not the same.  The > garch likelihood is extremely tricky > to optimize -- specialized optimizers > would be the ideal. > > Assuming you can give starting values > to the optimizer in both cases, you can > give the other's answer to each and see > what happens. > > > On 04/11/2010 21:02, alexios wrote: > >> The default for fGarch::garchFit is to estimate the mean, assuming a >> non-zero mean dataset is passed, as can be seen from the returned "mu" >> parameter ( a call to 'args(garchFit)' should highlight the >> 'include.mean' argument ). The default for tseries garch is to assume >> zero mean data. >> >> Demean the data before passing to tseries garch by the estimated 'mu' >> value from 'fgarch.fitted' and you should obtain closer results. >> >> -Alexios >> >> >> >> On 11/4/2010 8:44 PM, Mark Breman wrote: >> >>> Hi everyone, >>> >>> I'm trying to predict volatility using a garch(1,1) model and I'm running >>> into some interesting issues I cannot find an answer for. >>> >>> Suppose I have the following code: >>> >>> library(quantmod) >>> library(tseries) >>> library(fGarch) >>> >>> # get some returns >>> r = dailyReturn(Ad(getSymbols("SPY", from="2000-01-01", to="2010-11-04", >>> auto.assign=F))) >>> >>> # fit models >>> garch.fitted = garch(na.omit(r), order = c(1,1)) >>> fgarch.fitted = fGarch::garchFit(~ garch(1,1), data = as.zoo(na.omit(r)), >>> trace = FALSE) >>> >>> Now if I look at the values of the coefficients for both fitted models >>> they >>> are not the same: >>> >>>  coef(garch.fitted) >>>> >>>           a0           a1           b1 >>> 1.339912e-06 8.165689e-02 9.101754e-01 >>> >>>> coef(fgarch.fitted) >>>> >>>           mu        omega       alpha1        beta1 >>> 4.990616e-04 1.370880e-06 8.307080e-02 9.086447e-01 >>> >>> Q1) Why are they different? What do I have to change to make the >>> coefficient >>> values of fgarch.fitted the same as garch.fitted? >>> >>> If I try to predict the volatility with: predict(garch.fitted) I get the >>> "conditional standard deviation predictions" (an interval) for every >>> period >>> return in r. >>> >>> Q2) Is this a 1 period prediction (i.e. the volatility prediction for the >>> next day)? How do I get a prediction for let's say 2 periods in the >>> future? >>> >>> >>> If I use predict(fgarch.fitted) I get: >>> >>>  predict(fgarch.fitted) >>>> >>>    meanForecast   meanError standardDeviation >>> 1  0.0004990616 0.006677350       0.006677350 >>> 2  0.0004990616 0.006751925       0.006751925 >>> 3  0.0004990616 0.006825079       0.006825079 >>> 4  0.0004990616 0.006896859       0.006896859 >>> 5  0.0004990616 0.006967315       0.006967315 >>> 6  0.0004990616 0.007036491       0.007036491 >>> 7  0.0004990616 0.007104428       0.007104428 >>> 8  0.0004990616 0.007171167       0.007171167 >>> 9  0.0004990616 0.007236745       0.007236745 >>> 10 0.0004990616 0.007301198       0.007301198 >>> >>> Q3) Why is the meanForecast for all 10 future periods the same? >>> >>> Thanks, >>> >>> -Mark- >>> >>> >>> >>> predict(garch) >>> >>>        [[alternative HTML version deleted]] >>> >>> _______________________________________________ >>> [hidden email] 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. >>> >>> >>> >> _______________________________________________ >> [hidden email] 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. >> >> > -- > Patrick Burns > [hidden email] > http://www.burns-stat.com> http://www.portfolioprobe.com/blog> > > _______________________________________________ > [hidden email] 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]] _______________________________________________ [hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

## Re: Questions on fitted garch(1,1)

 Mark, >>> If I try to predict the volatility with: predict(garch.fitted) I get the >>> "conditional standard deviation predictions" (an interval) for every >>> period >>> return in r. >>> >>> Q2) Is this a 1 period prediction (i.e. the volatility prediction for the >>> next day)? How do I get a prediction for let's say 2 periods in the >>> future? No these are not predictions for the next day. The term "predict" is maybe somewhat misleading. "Fitted Values" is more appropriate, and in fact both functions give the same results, e.g. all.equal(predict(garch.fitted)[,1],fitted.values(garch.fitted)[,1]) [1] TRUE For a two-step-ahead forecast I would use the predict function on the fGARCH Object and would set the n.ahead argument to 2: predict(fgarch.fitted, n.ahead = 2)   meanForecast   meanError standardDeviation 1 0.0005044188 0.008436248       0.008436248 2 0.0005044188 0.008482511       0.008482511 >>> Q3) Why is the meanForecast for all 10 future periods the same? Because you have just modeled the variance equation and the mean equation has only a constant. Garch will help you forecasting the variance of the returns but not the returns themselves. If you want return forecasts you should model the mean equation, e.g. fgarch.fitted <- fGarch::garchFit(~ arma(2,1)+garch(1,1), data = as.zoo(na.omit(r)), trace =  FALSE) > predict(fgarch.fitted, n.ahead = 5)    meanForecast   meanError standardDeviation 1 -0.0009371963 0.008495794       0.008495794 2 -0.0003940789 0.008556624       0.008539586 3  0.0004374707 0.008608828       0.008582793 4  0.0005284133 0.008651758       0.008625429 5  0.0005093462 0.008693970       0.008667503 Hope this helps Zeno -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Mark Breman Sent: Dienstag, 9. November 2010 12:51 To: Patrick Burns Cc: [hidden email] Subject: Re: [R-SIG-Finance] Questions on fitted garch(1,1) Hi everyone, As a followup on my three fitted garch questions; Yes indeed, if I give the estimated coefficients of fgarch.fitted as initial values to garch() the results are much more inline with each other: > coef(garch(na.omit(r), order = c(1,1), control=garch.control(start=c(1.3705e-06,8.1789e-02,9.0995e-01))))  ***** ESTIMATION WITH ANALYTICAL GRADIENT *****      I     INITIAL X(I)        D(I)      1     1.370500e-06     1.000e+00      2     8.178900e-02     1.000e+00      3     9.099500e-01     1.000e+00     IT   NF      F         RELDF    PRELDF    RELDX   STPPAR   D*STEP NPRELDF      0    1 -1.093e+04      1   13 -1.093e+04  4.54e-09  1.67e-08  1.1e-09  4.3e+13  2.1e-09  3.63e+05      2   24 -1.093e+04 -1.30e-14  2.64e-14  8.1e-15  1.6e+00  1.5e-14 -1.22e-03  ***** FALSE CONVERGENCE *****  FUNCTION    -1.093479e+04   RELDX        8.076e-15  FUNC. EVALS      24         GRAD. EVALS       2  PRELDF       2.641e-14      NPRELDF     -1.222e-03      I      FINAL X(I)        D(I)          G(I)      1    1.372553e-06     1.000e+00    -1.965e+04      2    8.178900e-02     1.000e+00     2.046e+00      3    9.099500e-01     1.000e+00    -1.478e+01           a0           a1           b1 1.372553e-06 8.178900e-02 9.099500e-01 Very nice, thank you! Now only question 2 and 3 remain a mystery to me. Kind regards, -Mark- 2010/11/4 Patrick Burns <[hidden email]> > Taking Alexios' advice will probably > help, but I wouldn't be surprised if > they are still not the same.  The > garch likelihood is extremely tricky > to optimize -- specialized optimizers > would be the ideal. > > Assuming you can give starting values > to the optimizer in both cases, you can > give the other's answer to each and see > what happens. > > > On 04/11/2010 21:02, alexios wrote: > >> The default for fGarch::garchFit is to estimate the mean, assuming a >> non-zero mean dataset is passed, as can be seen from the returned "mu" >> parameter ( a call to 'args(garchFit)' should highlight the >> 'include.mean' argument ). The default for tseries garch is to assume >> zero mean data. >> >> Demean the data before passing to tseries garch by the estimated 'mu' >> value from 'fgarch.fitted' and you should obtain closer results. >> >> -Alexios >> >> >> >> On 11/4/2010 8:44 PM, Mark Breman wrote: >> >>> Hi everyone, >>> >>> I'm trying to predict volatility using a garch(1,1) model and I'm running >>> into some interesting issues I cannot find an answer for. >>> >>> Suppose I have the following code: >>> >>> library(quantmod) >>> library(tseries) >>> library(fGarch) >>> >>> # get some returns >>> r = dailyReturn(Ad(getSymbols("SPY", from="2000-01-01", to="2010-11-04", >>> auto.assign=F))) >>> >>> # fit models >>> garch.fitted = garch(na.omit(r), order = c(1,1)) >>> fgarch.fitted = fGarch::garchFit(~ garch(1,1), data = as.zoo(na.omit(r)), >>> trace = FALSE) >>> >>> Now if I look at the values of the coefficients for both fitted models >>> they >>> are not the same: >>> >>>  coef(garch.fitted) >>>> >>>           a0           a1           b1 >>> 1.339912e-06 8.165689e-02 9.101754e-01 >>> >>>> coef(fgarch.fitted) >>>> >>>           mu        omega       alpha1        beta1 >>> 4.990616e-04 1.370880e-06 8.307080e-02 9.086447e-01 >>> >>> Q1) Why are they different? What do I have to change to make the >>> coefficient >>> values of fgarch.fitted the same as garch.fitted? >>> >>> If I try to predict the volatility with: predict(garch.fitted) I get the >>> "conditional standard deviation predictions" (an interval) for every >>> period >>> return in r. >>> >>> Q2) Is this a 1 period prediction (i.e. the volatility prediction for the >>> next day)? How do I get a prediction for let's say 2 periods in the >>> future? >>> >>> >>> If I use predict(fgarch.fitted) I get: >>> >>>  predict(fgarch.fitted) >>>> >>>    meanForecast   meanError standardDeviation >>> 1  0.0004990616 0.006677350       0.006677350 >>> 2  0.0004990616 0.006751925       0.006751925 >>> 3  0.0004990616 0.006825079       0.006825079 >>> 4  0.0004990616 0.006896859       0.006896859 >>> 5  0.0004990616 0.006967315       0.006967315 >>> 6  0.0004990616 0.007036491       0.007036491 >>> 7  0.0004990616 0.007104428       0.007104428 >>> 8  0.0004990616 0.007171167       0.007171167 >>> 9  0.0004990616 0.007236745       0.007236745 >>> 10 0.0004990616 0.007301198       0.007301198 >>> >>> Q3) Why is the meanForecast for all 10 future periods the same? >>> >>> Thanks, >>> >>> -Mark- >>> >>> >>> >>> predict(garch) >>> >>>        [[alternative HTML version deleted]] >>> >>> _______________________________________________ >>> [hidden email] 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. >>> >>> >>> >> _______________________________________________ >> [hidden email] 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. >> >> > -- > Patrick Burns > [hidden email] > http://www.burns-stat.com> http://www.portfolioprobe.com/blog> > > _______________________________________________ > [hidden email] 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]] _______________________________________________ [hidden email] 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. EBS European Business School gemeinnuetzige GmbH, Universitaet fuer Wirtschaft und Recht i.Gr. - Amtsgericht Wiesbaden HRB 19951 - Umsatzsteuer-ID DE 113891213 Geschaeftsfuehrung: Prof. Dr. Christopher Jahns,  President; Prof. Dr. Rolf Tilmes, Dean Business School; Sabine Fuchs, CMO; Prof. Dr. Dr. Gerrick Frhr. v. Hoyningen-Huene, Dean Law School; Verwaltungsrat: Dr. Hellmut K. Albrecht, Vorsitzender _______________________________________________ [hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

## Re: Questions on fitted garch(1,1)

 Thanks Zeno, this fully answers the remaining questions. I will read-up on arma... Also thanks to everyone else contributing to the thread! -Mark- 2010/11/9 Adams, Zeno <[hidden email]> > Mark, > > >>> If I try to predict the volatility with: predict(garch.fitted) I get > the > >>> "conditional standard deviation predictions" (an interval) for every > >>> period > >>> return in r. > >>> > >>> Q2) Is this a 1 period prediction (i.e. the volatility prediction > for the > >>> next day)? How do I get a prediction for let's say 2 periods in the > >>> future? > > No these are not predictions for the next day. The term "predict" is > maybe somewhat misleading. "Fitted Values" is more appropriate, and in > fact both functions give the same results, e.g. > > all.equal(predict(garch.fitted)[,1],fitted.values(garch.fitted)[,1]) > [1] TRUE > > For a two-step-ahead forecast I would use the predict function on the > fGARCH Object and would set the n.ahead argument to 2: > > predict(fgarch.fitted, n.ahead = 2) >  meanForecast   meanError standardDeviation > 1 0.0005044188 0.008436248       0.008436248 > 2 0.0005044188 0.008482511       0.008482511 > > > >>> Q3) Why is the meanForecast for all 10 future periods the same? > > Because you have just modeled the variance equation and the mean > equation has only a constant. Garch will help you forecasting the > variance of the returns but not the returns themselves. If you want > return forecasts you should model the mean equation, e.g. > > fgarch.fitted <- fGarch::garchFit(~ arma(2,1)+garch(1,1), data = > as.zoo(na.omit(r)), trace =  FALSE) > > > predict(fgarch.fitted, n.ahead = 5) >   meanForecast   meanError standardDeviation > 1 -0.0009371963 0.008495794       0.008495794 > 2 -0.0003940789 0.008556624       0.008539586 > 3  0.0004374707 0.008608828       0.008582793 > 4  0.0005284133 0.008651758       0.008625429 > 5  0.0005093462 0.008693970       0.008667503 > > Hope this helps > > Zeno > > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of Mark > Breman > Sent: Dienstag, 9. November 2010 12:51 > To: Patrick Burns > Cc: [hidden email] > Subject: Re: [R-SIG-Finance] Questions on fitted garch(1,1) > > Hi everyone, > > As a followup on my three fitted garch questions; > > Yes indeed, if I give the estimated coefficients of fgarch.fitted as > initial > values to garch() the results are much more inline with each other: > > > coef(garch(na.omit(r), order = c(1,1), > control=garch.control(start=c(1.3705e-06,8.1789e-02,9.0995e-01)))) > >  ***** ESTIMATION WITH ANALYTICAL GRADIENT ***** > > >     I     INITIAL X(I)        D(I) > >     1     1.370500e-06     1.000e+00 >     2     8.178900e-02     1.000e+00 >     3     9.099500e-01     1.000e+00 > >    IT   NF      F         RELDF    PRELDF    RELDX   STPPAR   D*STEP > NPRELDF >     0    1 -1.093e+04 >     1   13 -1.093e+04  4.54e-09  1.67e-08  1.1e-09  4.3e+13  2.1e-09 >  3.63e+05 >     2   24 -1.093e+04 -1.30e-14  2.64e-14  8.1e-15  1.6e+00  1.5e-14 > -1.22e-03 > >  ***** FALSE CONVERGENCE ***** > >  FUNCTION    -1.093479e+04   RELDX        8.076e-15 >  FUNC. EVALS      24         GRAD. EVALS       2 >  PRELDF       2.641e-14      NPRELDF     -1.222e-03 > >     I      FINAL X(I)        D(I)          G(I) > >     1    1.372553e-06     1.000e+00    -1.965e+04 >     2    8.178900e-02     1.000e+00     2.046e+00 >     3    9.099500e-01     1.000e+00    -1.478e+01 > >          a0           a1           b1 > 1.372553e-06 8.178900e-02 9.099500e-01 > > Very nice, thank you! > > Now only question 2 and 3 remain a mystery to me. > > Kind regards, > > -Mark- > > 2010/11/4 Patrick Burns <[hidden email]> > > > Taking Alexios' advice will probably > > help, but I wouldn't be surprised if > > they are still not the same.  The > > garch likelihood is extremely tricky > > to optimize -- specialized optimizers > > would be the ideal. > > > > Assuming you can give starting values > > to the optimizer in both cases, you can > > give the other's answer to each and see > > what happens. > > > > > > On 04/11/2010 21:02, alexios wrote: > > > >> The default for fGarch::garchFit is to estimate the mean, assuming a > >> non-zero mean dataset is passed, as can be seen from the returned > "mu" > >> parameter ( a call to 'args(garchFit)' should highlight the > >> 'include.mean' argument ). The default for tseries garch is to assume > >> zero mean data. > >> > >> Demean the data before passing to tseries garch by the estimated 'mu' > >> value from 'fgarch.fitted' and you should obtain closer results. > >> > >> -Alexios > >> > >> > >> > >> On 11/4/2010 8:44 PM, Mark Breman wrote: > >> > >>> Hi everyone, > >>> > >>> I'm trying to predict volatility using a garch(1,1) model and I'm > running > >>> into some interesting issues I cannot find an answer for. > >>> > >>> Suppose I have the following code: > >>> > >>> library(quantmod) > >>> library(tseries) > >>> library(fGarch) > >>> > >>> # get some returns > >>> r = dailyReturn(Ad(getSymbols("SPY", from="2000-01-01", > to="2010-11-04", > >>> auto.assign=F))) > >>> > >>> # fit models > >>> garch.fitted = garch(na.omit(r), order = c(1,1)) > >>> fgarch.fitted = fGarch::garchFit(~ garch(1,1), data = > as.zoo(na.omit(r)), > >>> trace = FALSE) > >>> > >>> Now if I look at the values of the coefficients for both fitted > models > >>> they > >>> are not the same: > >>> > >>>  coef(garch.fitted) > >>>> > >>>           a0           a1           b1 > >>> 1.339912e-06 8.165689e-02 9.101754e-01 > >>> > >>>> coef(fgarch.fitted) > >>>> > >>>           mu        omega       alpha1        beta1 > >>> 4.990616e-04 1.370880e-06 8.307080e-02 9.086447e-01 > >>> > >>> Q1) Why are they different? What do I have to change to make the > >>> coefficient > >>> values of fgarch.fitted the same as garch.fitted? > >>> > >>> If I try to predict the volatility with: predict(garch.fitted) I get > the > >>> "conditional standard deviation predictions" (an interval) for every > >>> period > >>> return in r. > >>> > >>> Q2) Is this a 1 period prediction (i.e. the volatility prediction > for the > >>> next day)? How do I get a prediction for let's say 2 periods in the > >>> future? > >>> > >>> > >>> If I use predict(fgarch.fitted) I get: > >>> > >>>  predict(fgarch.fitted) > >>>> > >>>    meanForecast   meanError standardDeviation > >>> 1  0.0004990616 0.006677350       0.006677350 > >>> 2  0.0004990616 0.006751925       0.006751925 > >>> 3  0.0004990616 0.006825079       0.006825079 > >>> 4  0.0004990616 0.006896859       0.006896859 > >>> 5  0.0004990616 0.006967315       0.006967315 > >>> 6  0.0004990616 0.007036491       0.007036491 > >>> 7  0.0004990616 0.007104428       0.007104428 > >>> 8  0.0004990616 0.007171167       0.007171167 > >>> 9  0.0004990616 0.007236745       0.007236745 > >>> 10 0.0004990616 0.007301198       0.007301198 > >>> > >>> Q3) Why is the meanForecast for all 10 future periods the same? > >>> > >>> Thanks, > >>> > >>> -Mark- > >>> > >>> > >>> > >>> predict(garch) > >>> > >>>        [[alternative HTML version deleted]] > >>> > >>> _______________________________________________ > >>> [hidden email] 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. > >>> > >>> > >>> > >> _______________________________________________ > >> [hidden email] 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. > >> > >> > > -- > > Patrick Burns > > [hidden email] > > http://www.burns-stat.com> > http://www.portfolioprobe.com/blog> > > > > > _______________________________________________ > > [hidden email] 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]] > > _______________________________________________ > [hidden email] 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. > > EBS European Business School gemeinnuetzige GmbH, Universitaet fuer > Wirtschaft und Recht i.Gr. - Amtsgericht Wiesbaden HRB 19951 - > Umsatzsteuer-ID DE 113891213 Geschaeftsfuehrung: Prof. Dr. Christopher > Jahns,  President; Prof. Dr. Rolf Tilmes, Dean Business School; Sabine > Fuchs, CMO; Prof. Dr. Dr. Gerrick Frhr. v. Hoyningen-Huene, Dean Law School; > Verwaltungsrat: Dr. Hellmut K. Albrecht, Vorsitzender >         [[alternative HTML version deleted]] _______________________________________________ [hidden email] 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.