Click or drag to resize

ADFTest

AdfTest is a test for unit root in a time series sample. But, the rejection of the null hypothesis is often considered as an evidence of stationarity. The augmented Dickey–Fuller (ADF) statistic, used in the test, is a negative number. The more negative it is, the stronger the rejection of the hypothesis that there is a unit roots at some level of confidence. AdfTest indicator returns 4 values:

Calculation

The Dickey-Fuller model is

ADFTest 001

where L is the lag operator: ADFTest 002

ADFTest 003, so ADFTest 004

ADFTest 005 is the innovations process.

The null hypothesis restricts ADFTest 006.

The test assesses the null hypothesis under the model variant appropriate for series with different growth characteristics (ADFTest 007 or ADFTest 008). Lagged differences ADFTest 009 "augment" the test to account for serial correlations in the innovations process ADFTest 005.

Chart Example

ADFTest 010

Implementation and Usage

To initialize AdfTest indicator use one of the constructors provided:

AdfTest – this constructor sets default value 1 for update period, 20 for working period and ModelTypeAR for the type of time series model.

AdfTest(Int32, Int32, TimeSeriesModelType) – creates ADF Test indicator with expanding window and update scheduled by point period

AdfTest(TimeSpan, Int32, TimeSeriesModelType) – creates ADF Test indicator with expanding window and update scheduled by point period. updatePeriod parameter is of TimeSpan type.

To operate with sliding data sets, it is necessary to define the sliding window size value as a time period or a number of data points in the following constructors (note that updatePeriod can take either TimeSpan or int value):

AdfTest(Int32, Int32, Int32, TimeSeriesModelType) - initializes an instance of AdfTest class with sliding window and update sheduled by point period.

AdfTest(Int32, TimeSpan, Int32, TimeSeriesModelType) - initializes an instance of AdfTest class with sliding window and update sheduled by time period.

AdfTest(Int32, TimeSpan, Int32, TimeSeriesModelType) - initializes an instance of AdfTest class with sliding window and update sheduled by point period. workingPeriod is of TimeSpan type.

AdfTest(TimeSpan, TimeSpan, Int32, TimeSeriesModelType) - initializes an instance of AdfTest class with sliding window and update sheduled by time period. workingPeriod is of TimeSpan type.

Use

CValue

PValue

Decision

Statistic

properties to get current value.

Example
C#
 1// Create new instance
 2AdfTest adf = new AdfTest(5, 20, AdfTest.TimeSeriesModelType.ModelTypeAR);
 3
 4// Number of stored values
 5adf.HistoryCapacity = 2;
 6
 7// Add new data point
 8adf.Add(CurrentPrice, CurrentTime);
 9
10// Get indicator values
11double cValue = adf.CValue;
12double pValue = adf.PValue;
13double decision = adf.Decision;
14double statistic = adf.Statistic;
15// Get previous values
16if (adf.HistoryCount == 2)
17{
18    double PrevCValue = adf[1].CValue;
19    double PrevPValue = adf[1].PValue;
20    double PrevDecision = adf[1].Decision;
21    double PrevStatistic = adf[1].Statistic;
22}