Stats TimeSeries dickeyfulleroptions - CyrilB1531/lodestar GitHub Wiki
Home βΊ Stats-TimeSeries βΊ Stationarity tests
DickeyFullerOptions
What an augmented Dickey-Fuller test may be told.
public sealed record DickeyFullerOptions
Properties β Regression is the regression's deterministic terms, a
TrendTerms; Constant by default. LagSelection is how the lag order is
chosen, a LagSelection; Akaike by default. MaxLag is the largest lag the
search considers, or the lag itself under LagSelection.Fixed; null by default, which takes
Schwert's ceil(12Β·(n/100)^ΒΌ) capped at n/2 β terms β 1.
Exceptions β ArgumentOutOfRangeException when MaxLag is negative, or Regression or
LagSelection is a value its enum does not declare, checked where the value is set.
Example β Schwarz's criterion picks the same lag as Akaike's on this series, and reports its own value.
using Lodestar.Stats.TimeSeries;
double[] walk = [0.0, 1.2, 0.7, 2.1, 3.0, 2.4, 3.9, 5.1, 4.6, 6.0, 7.3, 6.8,
8.2, 9.5, 9.1, 10.4, 11.8, 11.2, 12.7, 14.0, 13.5, 14.9, 16.2, 15.8];
DickeyFullerResult schwarz = Stationarity.AugmentedDickeyFuller(
walk, new DickeyFullerOptions { LagSelection = LagSelection.Schwarz });
int usedLag = schwarz.UsedLag; // => 3
double criterion = Math.Round(schwarz.InformationCriterion, 4); // => -34.6446
Remarks β without a constant the table changes too: TrendTerms.None reads MacKinnon's
no-constant surface, which has no upper cut-off, so a large positive statistic reads a p-value close
to 1 rather than exactly 1.
using Lodestar.Stats.TimeSeries;
double[] walk = [0.0, 1.2, 0.7, 2.1, 3.0, 2.4, 3.9, 5.1, 4.6, 6.0, 7.3, 6.8,
8.2, 9.5, 9.1, 10.4, 11.8, 11.2, 12.7, 14.0, 13.5, 14.9, 16.2, 15.8];
DickeyFullerResult bare = Stationarity.AugmentedDickeyFuller(
walk,
new DickeyFullerOptions { Regression = TrendTerms.None, LagSelection = LagSelection.Fixed, MaxLag = 2 });
double statistic = Math.Round(bare.Statistic, 4); // => 3.9128
double p = Math.Round(bare.PValue, 4); // => 1
double onePercent = Math.Round(bare.CriticalValues[0], 4); // => -2.6804
Being a record of value types, two option sets with the same three values are equal.
Applies to β net10.0, netstandard2.0.
See also β Stationarity.AugmentedDickeyFuller,
DickeyFullerResult, the Python equivalence table.