# Structural Breaks in a Time Series Model

The Chow test is a test of whether the true coefficients in two linear regressions on different data sets are equal.

In econometrics, Chow test is most commonly used in time series analysis to test for the presence of a structural break.

## Data

Here is data taken from the explanation image of the referenced Wikipedia article for Chow test.

data = {{0.08, 0.34}, {0.16, 0.55}, {0.24, 0.54}, {0.32,
0.77}, {0.4, 0.77}, {0.48, 1.2}, {0.56, 0.57}, {0.64,
1.3}, {0.72, 1.}, {0.8, 1.3}, {0.88, 1.2}, {0.96,
0.88}, {1., 1.2}, {1.1, 1.3}, {1.2, 1.3}, {1.3,
1.4}, {1.4, 1.5}, {1.4, 1.5}, {1.5, 1.5}, {1.6,
1.6}, {1.7, 1.1}, {1.8, 0.98}, {1.8, 1.1}, {1.9,
1.4}, {2., 1.3}, {2.1, 1.5}, {2.2, 1.3}, {2.2,
1.3}, {2.3, 1.2}, {2.4, 1.1}, {2.5, 1.1}, {2.6,
1.2}, {2.6, 1.4}, {2.7, 1.3}, {2.8, 1.6}, {2.9,
1.5}, {3., 1.4}, {3., 1.8}, {3.1, 1.4}, {3.2,
1.4}, {3.3, 1.4}, {3.4, 2.}, {3.4, 2.}, {3.5,
1.5}, {3.6, 1.8}, {3.7, 2.1}, {3.8, 1.6}, {3.8,
1.8}, {3.9, 1.9}, {4., 2.1}};
ListPlot[data]


This code illustrates the presence of a structural break:

Show[
Map[
Function[{data},
ff = Fit[data, {1, x}, x];
Show[ListPlot[data],
ListLinePlot[{#, ff /. x -> #} & /@ data[[All, 1]]]]],
{Select[data, #[[1]] < 1.5 &], Select[data, #[[1]] >= 1.5 &]}],
PlotRange -> All]


How can we identify structural breaks in time series data using Mathematica?

# Original post

I am having troubles in performing structural break analysis on Mathematica. I have the following time series model for S&P500 starting January 1, 2015.

So I obtain the following AR model that describes the prices:

$$y_t = 0.996271y_{t-1} + u_t$$

From the above graph, it is obvious that there are structural breaks. Is there a way to perform a structural break test on Mathematica for unknown dates?

• It is not clear what are you asking. What table do you refer to? What are “structural breaks”? Commented Jun 12, 2019 at 12:49
• Apologies for not being clear. I meant graph. I want to perform a Chow test (F- test) to see if there is a statistically significant change in the model (hence 'structural break'). To my understanding, mathematica does not have a command for the test. So how can I perform the Chow test? @AntonAntonov
– user62722
Commented Jun 13, 2019 at 16:13
• Please complete or rewrite your question! (It is a potentially interesting one to answer...) Commented Jun 13, 2019 at 16:38
• I provided a new formulation of the question with references, data, and code that illustrates what a "structural break" is. Commented Jun 14, 2019 at 11:22
• @AntonAntonov in your investigations, are these related to “Statistical breakpoints”? OP may want to implement something similar to this: ncbi.nlm.nih.gov/m/pubmed/6496934 Commented Jun 14, 2019 at 11:26

## Update 2019-08-01

The Community blog post:

provides demonstrations and explanations for the code used to make the plot below.

(This is a preview / clarification for an answer I will post later today.)

@Waie Is the attached screenshot close to what you want or expect?

## Code

This function definition follows the formula given in Wikipedia's Chow test entry.

Clear[ChowTestStatistic]

ChowTestStatistic::empfuncs = "A non empty list of functions is expected.";
ChowTestStatistic::novar = "The specified variable is not a symbol.";
ChowTestStatistic::nofuncsvar = "The specified variable should be found in the functions list.";

ChowTestStatistic[data : {{_?NumberQ, _?NumberQ} ..}, splitPoint_?NumberQ, funcs_: {1, x}, var_: x] :=
Block[{S, S1, S2, k, data1, data2, fm, res},
If[Length[funcs] == 0, Message[ChowTestStatistic::empfuncs]; Return[$$Failed]]; If[! DeveloperSymbolQ[var], Message[ChowTestStatistic::novar]; Return[$$Failed]];
If[FreeQ[funcs, var], Message[ChowTestStatistic::nofuncsvar]; Return[\$Failed]];

k = Count[DeveloperSymbolQ /@ funcs, True];

data1 = Select[data, #[[1]] < splitPoint &];
data2 = Select[data, #[[1]] >= splitPoint &];

{S, S1, S2} =
Map[
Function[{d},
res = Fit[d, funcs, var, "FitResiduals"];
res.res
],
{data, data1, data2}];

((S - (S1 + S2))/k)/((S1 + S2)/(Length[data1] + Length[data2] - 2 k))
];


## Examples

Here is an example run of the Chow test statistic with the data data provided in the question.

res = {#, ChowTestStatistic[data, #, {1, x}, x]} & /@
Rest[Most[data[[All, 1]]]];
ListPlot[res, Filling -> Axis, PlotRange -> All]


Here is a plot of structural break splits (the point in blue is the best split):