This topic contains the following sections.
ADF Test Specification
Given an observed time series Dickey and Fuller consider three differentialform autoregressive equations to detect the presence of a unit root:
t is the time index,
α is an intercept constant called a drift,
β is the coefficient on a time trend,
γ is the coefficient presenting process root, i.e. the focus of testing,
p is the lag order of the firstdifferences autoregressive process,
e_{t} is an independent identically distributes residual term.
The focus of testing is whether the coefficient γ equals to zero, what means that the original process has a unit root; hence, the null hypothesis of γ = 0 (random walk process) is tested against the alternative hypothesis γ < 0 of stationarity. More detailed, the null and alternative hypotheses corresponding to the models above are:
The ADF test ensures that the null hypothesis is accepted unless there is strong evidence against it to reject in favor of the alternate stationarity hypothesis.
ADF testing technique involves Ordinary Least Squares (OLS) method to find the coefficients of the model chosen. To estimate the significance of the coefficients in focus, the modified T (Student)statistic (known as DickeyFuller statistic) is computed and compared with the relevant critical value: if the test statistic is less than the critical value then the null hypothesis is rejected. Each version of the test has its own critical value which depends on the size of the sample.
Restrictions and Recommendations
There are some drawbacks of the ADF test that require additional efforts to get reliable results.
The ADF Test has low statistical power in distinguishing between true unit root processes (γ = 0) and near unit root processes (γ is close to zero). Also, several authors have shown that the ADF test tends to reject the nonstationarity hypothesis far too often, when the series have large (longrun) moving average processes. If there is evidence or doubt about such cases then it is recommended to additionally apply other stationarity tests (for instance, the KPSS Test) to ensure the results.
Uncertainty about lags order, p, which has to be determined when applying the test. As it is shown by Perron (1989), including extra regressors of lagged firstdifferences does not affect the size of the test (probability of Type I Error) but decreases test power. On the contrary, too few lags may affect the size of the test. Perron suggested a procedure to define the adequate lag order. An alternative approach is to examine information criteria (such as the Bayesian, HannanQuinn, etc.) computed for different lags.
Uncertainty about what test version to use, i.e. about including the intercept and time trend terms. Inappropriate exclusion or inclusion of these terms substantially affects test reliability. Using of prior knowledge (for instance, as result of visual inspection of a given time series) about whether the intercept and time trend should be included is the mostly recommended (but not always possible) informal way to overcome the difficulty mentioned. The more formal (algorithmic) approach is known as testing strategy and requires several additional experiments (series of ordered tests) to decide what model is adequate for a given observed process. There are several testing strategies developed, the most known of them are those suggested by Dolado et al. (1990), by Elder and Kennedy (2001) and by Enders (2004).
ADF Test Implementation and Usage
The ADFTest class implements ADF Test procedure according to the specification above. This class inherits from the OneSampleTest class.
The following constructor creates an instance of the ADFTest class.
Constructor 
Description 
Performance 

set significanceLevel, numberOfLags, and model type 
Initializes an instance of ADFTest class for the input parameters specified: series contains time series observations (sample) to be tested for the presence of a unit root, the last element must correspond to the most recent observation, significanceLevel is the desired significance level of the test in the range 0.001 – 0.999, numberOfLags is the nonnegative integer indicating the number of lagged changes of series to include in the model, modelType specifies test version (model type), one of the members listed in the ADFTest..::..TimeSeriesModelType enumeration. ModelTypeAR defines 'pure' autoregresression corresponding to the equation (1) in the specification, ModelTypeARD defines using of the model with a drift according to the equation (2) of the specification, ModelTypeTS defines using of the model which includes a drift and a time trend according to the equation (3). 
The following public properties provide the details about the model and decision made:
Property 
Description 
Performance 

decision 
The result of testing: takes true if the random walk null hypothesis is accepted while the false value means rejecting of the null hypothesis in favor of the alternative hypothesis of stationarity. 

statistic 
Shows the value of ADF statistic. 

pvalue 
The probability of obtaining a test statistic at least as extreme as the one that was actually observed, assuming that the null hypothesis is true. 

cvalue 
Shows the critical value of the ADF statistic at the input significance level. 

sse 
The sum of squared errors. 

alpha 
The intercept constant or drift. 

beta 
The coefficient β on a time trend. 

gamma 
The coefficient presenting the process' root, i.e. the focus of testing (the γ in the specification). 

delta 
The vector of coefficients of lagged derivatives ( δ_{j} , j = 1 ... p in the specification). 

region of acceptance 
We fail to reject null hypothesis if test statistics is between left and right borders of region of acceptance. Region of acceptance left border: Region of acceptance right border: 
Note  

There is also the indicatorstyle implementation of the ADF Test available in the Financial Analysis library and referred to as

Code Sample
The example of ADFTest class usage:
C#  Copy 

1using System; 2using FinMath.LinearAlgebra; 3using FinMath.Statistics.HypothesisTesting; 4 5namespace FinMath.Samples 6{ 7 class ADFTestSample 8 { 9 static void Main() 10 { 11 // Generate random series. 12 Vector series = Vector.Random(100); 13 14 // Create an instance of ADFTest. 15 ADFTest test = new ADFTest(0.05, 2, ADFTest.TimeSeriesModelType.ModelTypeTS); 16 test.Update(series); 17 18 Console.WriteLine("Test Result:"); 19 // Test's decision. 20 Console.WriteLine(" Stationary? = {0}", !test.Decision); 21 // The statistic of ADF test. 22 Console.WriteLine(" Statistics = {0:0.000}", test.Statistic); 23 // The cvalue of the test statistic. 24 Console.WriteLine(" CValue = {0:0.000}", test.CValue); 25 // The pvalue of the test statistic. 26 Console.WriteLine(" PValue = {0:0.000}", test.PValue); 27 28 Console.WriteLine("Model Details:"); 29 // The intercept constant or drift. 30 Console.WriteLine(" Alpha = {0:0.000}", test.Alpha); 31 // The coefficient on a time trend. 32 Console.WriteLine(" Beta = {0:0.000}", test.Beta); 33 // The coefficient presenting the process' root, i.e. the focus of testing. 34 Console.WriteLine(" Gamma = {0:0.000}", test.Gamma); 35 // The vector of coefficients of lagged derivatives. 36 Console.WriteLine(" Delta = ({0:0.000})", test.Delta); 37 38 Console.WriteLine("Extra Information:"); 39 // The sum of squared errors. 40 Console.WriteLine(" SSE = {0:000}", test.SSE); 41 } 42 } 43} 