2
$\begingroup$

In this GIST, you will find simple R code that calculates Microsoft's daily stock price based on an ARMA(1,1) + GARCH(2,2) using "rugarch" library and the data from 2008 to 2015. It compares the result to the real daily stock price. The idea is to see how good ARMA + GARCH is as a model to represent an equity price.

The code is simple:

  • Fit ARMA(1,1) + GARCH(2,2) to the data
  • Calculate the volatility (using GARCH)
  • Calculate the return from the volatility (using ARMA)
  • Calculate the stock price from the return (based on the real stock price on day 1)

Here are the ARMA(1,1) + GARCH(2,2) estimation results.

As you can see in the image here, the difference between the ARMA/GARCH simulated stock price (black) and the real one (red) is significant, knowing that I used all the data to fit the model. I can understand that the model would not fit perfectly, but to be so far off is a surprise to me.

I would appreciate it if somebody could look through the R code and help me spot any misunderstandings or errors.

$\endgroup$
  • 2
    $\begingroup$ You seem to be generating random shocks and feeding them into an estimated ARMA-GARCH model to produce an outcome series. If you used estimated shocks from the model, you should get a pretty good fit. But now you use random shocks, and this way you may get way off. You can extract fitted values from an object of uGARCHfit class using function fitted and compare that to the actual series. Also, I don't think you can fit the data (which is fixed) to a model; but you can do the opposite, i.e. fit the model (which is flexible due to the coefficients to be estimated) to the data. $\endgroup$ – Richard Hardy Nov 6 '15 at 19:05
  • $\begingroup$ Thanks a ton @RichardHardy (Sorry for the late reply, the website team just gave me back control over this post) I have updated my gist based on your answer to plot: 1. The real stock price 2. The prices fitted by the ARMA/GARCH 3. The prices calculated based on an ARMA/GARCH model using the parameters calculated by ugarch but using a random shock Here is the result link The fitted plot is much better but still far off. Is that normal in your opinion? $\endgroup$ – Ihab Nov 10 '15 at 9:34
  • $\begingroup$ Still doesn't look good... What is the conditional mean part of your model, could you include it in your original post by editing it? I mean include the estimated model output. $\endgroup$ – Richard Hardy Nov 10 '15 at 9:51
  • $\begingroup$ Sure @RichardHardy. Done. Let me know if I omitted any other important information. Thanks again $\endgroup$ – Ihab Nov 10 '15 at 10:17
  • $\begingroup$ On a second thought, if the red line is obtained by supplying the estimated shocks to the fitted ARMA-GARCH model (and starting from the same origin as the blue), then it might be correct. The discrepancy between the blue and the red is because the red are forecasts of points that are increasingly further from the forecast origin, and you cannot expect high precision there. The red at least shares the overall slope with the blue, and that is as expected because the red is generated by a model that was estimated on the full sample. So perhaps it's alright after all. $\endgroup$ – Richard Hardy Nov 10 '15 at 19:50
3
$\begingroup$

(Following a discussion in the comments and some changes to the code used in the original post.)

If the red line is obtained by supplying the estimated shocks to the fitted ARMA-GARCH model (and starting from the same origin as the blue), then it might be correct. The discrepancy between the blue and the red is because the red are forecasts of points that are increasingly further away from the forecast origin, and you cannot expect high precision there. The red at least shares the overall slope with the blue, and that is as expected because the red is generated by a model that was estimated on the full sample. So perhaps it's alright after all.

$\endgroup$
  • $\begingroup$ Hello Richard, thanks for your comment and sorry for the delay...I was actually busy trying to figure out the answer. Actually even the returns fitted vs real plot is far from being close. I tried another example with FOREX and it went much better, I guess this specific dataset is not appropriate for GARCH. It would be definitely interesting to try to understand why that is the case. Thanks a ton for your help and answer $\endgroup$ – Ihab Nov 24 '15 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.