# Test for Serial Correlation

Generate random sample of an ARProcess.

 In:= XarData = RandomFunction[ARProcess[{.3, .5, -.2}, 1], {1000}];

The estimated correlation function slowly decreases as a function of lag.

 In:= XListPlot[CorrelationFunction[arData, {20}], Filling -> Axis, PlotRange -> All]
 Out= Test for serial correlation up to lag 10.

 In:= XAutocorrelationTest[arData, 10, {"TestDataTable", All}]
 Out= The tests confirm that data is serially correlated.

 In:= XAutocorrelationTest[arData, 10, {"TestConclusion", All}]
 Out= Now generate a random sample from a GARCHProcess.

 In:= Xgarch = GARCHProcess[.4, {.3, .4}, {.2}]; BlockRandom[SeedRandom["Mathematica 10"]; garchData = RandomFunction[garch, {10^2}, 10^5];]

The values of the estimated correlation function at nonzero lags are very small.

 In:= XListPlot[CorrelationFunction[garchData, {10}], Filling -> Axis, PlotRange -> All, PlotStyle -> PointSize[Medium]]
 Out= Check the first path with the AutocorrelationTest.

 In:= XAutocorrelationTest[garchData["Path", 1], 10, {"TestDataTable", All}]
 Out= In:= XAutocorrelationTest[garchData["Path", 1], 10, {"TestConclusion", All}]
 Out= There is no serial correlation, but the slices are not independent.

 In:= Xgarch0 = garchData["SliceData", 0];
 In:= Xslices = Table[garchData["SliceData", k], {k, 1, 4}];

Check the independence between the slice at time zero and the four following slices using Hoeffding's independence test.

 In:= XDistributeDefinitions[garch0]; LaunchKernels[]; tests = ParallelMap[ IndependenceTest[ garch0, #, {"ShortTestConclusion", "HoeffdingD"}] &, slices];

Show scattered plots of slice values at time zero and at other times and the conclusions of the test.

 Out= ## Mathematica

Questions? Comments? Contact a Wolfram expert »