# How to analyze the volatility with GARCH?

How could I use GARCH model to detect if the volatility is constant during all the series(time series)?

I can't do a visual check, I need to detect if the volatility is constant using R and GARCH function of tseries package

-

You can use the classic Engle test for ARCH effects. The test is implemented as follows (copy from Ch. Brooks, "Introductory Econometrics for Finance").

1. Estimate the model

$$y_t=\beta_0+x_{1t}\beta_1+...+x_{kt}\beta_k + u_t, \quad t=1,...,T$$ using OLS and save the residuals $\hat{u}_i$. (If you do not have any explanatory variables, simply demean $y$.)

2. Square the residuals and estimate the following regression:

$$\hat{u_t}^2=\gamma_0+\hat{u}_{t-1}^2\gamma_1+\hat{u}_{t-2}^2\gamma_2+...+\hat{u}_{t-q}^2\gamma_q+v_t,$$

Obtain $R^2$ from this regression.

3. The test statistic, which is defined as $T\cdot R^2$, is distributed as $\chi^2(q)$.

4. The null hypothesis is $\gamma_i=0$, $i=1,\ldots,q,$ against the alternative $\exists j: \gamma_j\neq 0$.

This can be implemented in R as follows. Supposing we have $\hat{u}$, the p-value for the hypothesis is

> set.seed(13)
> u<-rnorm(100)
> 1-pchisq(summary(lm(X1~.,data=data.frame(embed(u^2,5))))$r.squared*100,4) [1] 0.6867667  Naturally you will need to decide how many lags to include. Since usually GARCH models use small numbers of lags, some predefined number may entirely appropriate. I would do some MC simulations to determine which works best. - Amazing! thank you for your answer! one question...can I do it with garch() function or do I have to do it manually as you wrote? so IF the pvalue is ABOVE 0.05 it should means that the volatility is constant? How could I change the number of lags inside the code you wrote? – Dail Nov 14 '11 at 12:57 Probably you cannot do that with garch. The answer to the second question is yes, with the usual caveats of interpreting p-values. The number of lags here is 4. So if your number of lags is$p$, change 4 to$p$and 5 to$p+1\$. –  mpiktas Nov 14 '11 at 13:46
do you mean that I have to modify (100-4) in (100-p) and (u^2,5) in (u^2,p+1) ? let me know, where p is the number of lags I use. Thank you really much –  Dail Nov 14 '11 at 14:00
Yes, also do not forget to change the last 4 to p. This is an argument to pchisq, which is the number of degrees of freedom of chi square distribution. –  mpiktas Nov 14 '11 at 14:13
Why the numbers of lags must to be equals to the degrees of freedom? –  Dail Nov 14 '11 at 14:28