In: Computer Science
How to fit an example of non-stationary data into GARCH model in R programming.
Answer) Dear student , we are taking example of Time Series
Analysis( non-stationary) with GARCH model in R
Programming
Differencing: In order to convert non-stationary
series to stationary, differencing method can be used in which the
series is lagged 1 step and subtracted from original series:
For example: Yt = Yt-1 +et
et = Yt –
Yt-1
In financial time series, it is often that the series is transformed by logging and then the differencing is performed. This is because financial time series is usually exposed to exponential growth, and thus log transformation can smooth out (linearize) the series and differencing will help stabilize the variance of the time series.
Following is an example of Apple stock price:
• The upper left graph is the original time series of Apple stock price from 01/01/2007 to 07/24/2012, showing exponential growth
• The lower left graph shows the differences of apple stock prices. It can be seen that the series is price-dependent; in other words, the variance of the series increases as the level of original series increases, and therefore, is not stationary
• The upper right corner show the graph of log price of Apple. The series is more linear compared to the original one.
• The lower right graphs the differences of log price of Apple.
The series seems more meanreverting, and variance is constant and
does not significantly change as level of original series
changes
To perform the differencing in R, follow these steps:
• Read the data file in R and store it in a variable
appl=read.csv('Apple.csv')
appl.close=appl$Adjclose #read and store adj close price in original file
• Plot original stock price
plot(appl.close,type='l',main='Apple Stock Price')
• Differencing the original series
diff.appl=diff(appl.close)
• Plot differences of original series
plot(diff.appl,type='l',main='Difference Apple')
• Take log of original series and plot the log price
log.appl=log(appl.close)
plot(log.appl,type='l',main='Log Apple')
• Differencing log price and plot
difflog.appl=diff(log.appl) plot(difflog.appl,type='l',main='Difference Log Apple')
Another point that makes the differences of time series is more of interest than price series is that people often look at the returns of the stock rather than the its prices. Differences of log prices represent the returns and are similar to percentage changes of stock prices.