Notifications
Clear all
Topic starter 30/07/2024 4:51 pm
In below code I return the "pValue" in the "AugmentedDickeyFuller".
Now we can use different LagOrder parameters where it is important to choose the "best" possible lagOrder to return as accurate "pValue" as possible.
Normally a good way to determine what LagOrder value to choose is by calculate the
Akaike Information Criterion (AIC).
Where the lowest found AIC would be a good pValue to choose.
I am not sure how to calculate the AIC with the library in this context?
Below line is just pseudo code and that function do not exist but show the intent.
Thank you!
CalculateAIC(statistic, lagOrder)
TrendType P_1 = TrendType.CONSTANT; ADFDistribution dist = P_1.getDistribution(array_MSFT.Length); double minAIC = double.MaxValue; int bestLagOrder = 0; int maxLagOrder = 20; for (int lagOrder = 0; lagOrder <= maxLagOrder; lagOrder++) { AugmentedDickeyFuller ADFtest = new AugmentedDickeyFuller(array_MSFT, P_1, lagOrder, dist); double pValue = ADFtest.pValue(); double statistic = ADFtest.statistics(); //How to Implement AIC calculation? (Pseudo Code) double aic = CalculateAIC(statistic, lagOrder); if (aic < minAIC) { minAIC = aic; bestLagOrder = lagOrder; } }