# Volatility Clustering in a GARCHProcess

Generalized autoregressive conditionally heteroscedastic process GARCHProcess is used to describe time series that exhibit volatility clustering phenomenonlarge changes tend to be followed by large changes of either sign, and small changes tend to be followed by small changes.

Simulate a GARCHProcess.

 In:= Xgarch\[ScriptCapitalP] = GARCHProcess[.5, {.6}, {.3}]; BlockRandom[SeedRandom; data = RandomFunction[garch\[ScriptCapitalP], {0, 10^6}]];

Plot moving standard deviation with window of length 10.

 In:= Xvar = MovingMap[StandardDeviation, data, 10]; ListLinePlot[TimeSeriesResample[var, 100], PlotRange -> {0, 40}, Ticks -> {Table[{10^5 k, k}, {k, 10}], Automatic}, AxesLabel -> {"\[Times] 10^5", None}, ImageSize -> Medium]
 Out= Define a function to compute standard deviation, given that the previous time value of the process is close to a given number.

 In:= XcondVar[pd_, v_] := Module[{cd, n, var, p0, p1}, {p0, p1} = cfBinarySearch[pd[[All, 1]], v + Abs[v] {-0.1, 0.1}]; cd = Take[pd, {p0 - 1, p1}]; n = Length[cd]; If[n > 10, {Mean[cd[[All, 1]]], StandardDeviation[cd[[All, 2]]]}, {Indeterminate, Indeterminate}]]

Estimate conditional standard deviation as a function of the conditional value.

 In:= XQuantile[data, {0, 0.01, 0.05, 0.95, 0.99, 1}]
 Out= In:= Xvlist = Join[#, -#] &[{1, 2, 4, 6, 8, 10, 15, 20, 25, 30, 35, 40}]; Block[{pd = SortBy[Partition[data["Values"], 2, 1], First]}, sdEst = Table[condVar[pd, v], {v, Sort[vlist]}]];
 In:= XListLinePlot[SortBy[sdEst, First]]
 Out= Compare to the graph for a sample of an ARMA process, whose conditional standard deviation is constant.

 In:= Xarma\[ScriptCapitalP] = ARMAProcess[{.6, 0.1}, {.3}, 1]; BlockRandom[SeedRandom; data2 = RandomFunction[arma\[ScriptCapitalP], {10^6}]];
 In:= XQuantile[data2, {0, 0.01, 0.05, 0.25, 0.75, 0.95, 0.99, 1}]
 Out= In:= Xvlist = Join[#, -#] &[{0.5, 1, 2, 3, 4, 5}]; Block[{pd2 = SortBy[Partition[data2["Values"], 2, 1], First]}, sdEst2 = Table[condVar[pd2, v], {v, Sort[vlist]}]];
 In:= XListLinePlot[SortBy[sdEst2, First], PlotRange -> {0, 2}]
 Out= ## Mathematica

Questions? Comments? Contact a Wolfram expert »