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.
uGARCHfit
class using functionfitted
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