# How to reconstruct a stock price from ARMA/GARCH fit

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.

• 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. – Richard Hardy Nov 6 '15 at 19:05
• 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? – Ihab Nov 10 '15 at 9:34
• 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. – Richard Hardy Nov 10 '15 at 9:51
• Sure @RichardHardy. Done. Let me know if I omitted any other important information. Thanks again – Ihab Nov 10 '15 at 10:17
• 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. – Richard Hardy Nov 10 '15 at 19:50