The problem may lie in this line:
dcc.focast[[i]]=dccforecast(fit1, n.ahead = 1, n.roll = 0)
Here you supply fit1
which is a list to the dccforecast
function that requires supplying an object of class DCCfit
instead.
What you could do to remedy that is run a loop over i
where in each iteration you would execute the following
dcc.focast[[i]]=dccforecast(fit1[[i]], n.ahead = 1, n.roll = 0)
Alternatively you may consider using the dccroll
function which does the rolling for you.
Also note that if dcc.focast
is a list, you will not be able to execute the following:
covmat.focast= rcov(dcc.focast) ##-->Only one covariance matrix.
mean.focast = fitted(dcc.focast) ##Mean forecast matrix
You should do it element-by-element in a loop over i
:
covmat.focast[[i]]= rcov(dcc.focast[[i]])
mean.focast[[i]] = fitted(dcc.focast[[i]])
When modelling stock prices, it is quite common to transform the original prices $P_{t}$ to logarithmic returns $r_t:=\ln(P_{t})-\ln(P_{t-1})$ and then employ a GARCH model.
Logarithmic returns reflect price changes relative to price levels. If the price was fluctuating at around the same level, logarithmic returns would behave similarly to simple returns (just be scaled by roughly a constant); then not taking logarithms could be justified. But since the price is roughly a random walk, it does not stay around any fixed level for too long, and hence there is a difference between logarithmic and simple returns. Simple returns have an amplitude that changes with the price level, while logarithmic returns have a roughly constant amplitude. Therefore, modelling logarithmic returns is more convenient.
Given a GARCH model for (logarithmic) returns, you can predict the volatility iteratively:
$$
\begin{aligned}
\hat\sigma_{t+1}^2 &= \hat\omega + \hat\alpha r_{t}^2 + \hat\beta \sigma_{t}^2 \\
\hat r_{t+1}^2 &= \hat\sigma_{t+1}^2 \\
\hat\sigma_{t+2}^2 &= \hat\omega + \hat\alpha r_{t+1}^2 + \hat\beta \hat\sigma_{t+1}^2 \\
\hat r_{t+2}^2 &= \hat\sigma_{t+2}^2 \\
&\dotsc
\end{aligned}
$$
In R, use function predict
on a fitted object from garchFit
, in your case, garchA
; see p. 30-31 of the "fGarch" manual for details.
In the above I assumed you are not using an ARMA model for the conditional mean of returns. Predictability in the level of returns via ARMA would be a little naive to expect and would be a sign of market inefficiency. Without ARMA, the point forecast of $r_{t+h}=0$ for $h>0$.
However, if you decide to use ARMA, replace $r_t$ and $\hat r_t$ with $\hat\varepsilon_t$ in the GARCH formulas above, where $\hat\varepsilon_t$ is a residual from the ARMA model. Also, the point forecast is generally nonzero and is given by the ARMA model.
Also, if you use ARMA, estimate both ARMA and GARCH simultaneously (rather than first estimating ARMA and then fitting GARCH on its residuals). This will yield consistent and efficient parameter estimates. This can be done with the same garchFit
function as you are using now.
Best Answer
If you estimated a standard GARCH(s,r) model, the parameters were likely restricted to produce stationary conditional variance, which means it is mean reverting. This is what you see -- the variance gradually reverts towards its long-term mean.
An alternative GARCH-type of model that allows for non-mean-reverting volatility is integrated GARCH (IGARCH) that produces random-walk-type of volatility; or a GARCH model with exogenous variables (such as linear or nonlinear deterministic trend) in the conditional variance equation, which produces -- naturally -- a linear or nonlinear trend in volatility.