Align the AR and MA rows in AutoRegressiveIntegratedMovingAverage - #9714
Align the AR and MA rows in AutoRegressiveIntegratedMovingAverage#9714mkzung wants to merge 1 commit into
Conversation
|
One thing I should have put in the description: whether the new pairing fits a model, or only stops throwing. Generated 400 points from The first row is the diagonal this change does not touch. The second only runs with it, and recovers the same coefficients to two figures with the same residual error, so the rows are being paired in time rather than merely paired. The third is an over-specified AR(3) on AR(2) data, where the extra coefficient absorbs the difference. Worth saying that this took two attempts. The first put the process on top of a level of 100 with no intercept, and every configuration returned coefficients summing to 1.0001: the fit was reproducing the level and the truth was invisible behind it. |
Description
MovingAverageStepwalked the lagged errors and indexed the AR lags with the same counter,which runs off the end of
lagswheneverarOrder > maOrder. It now walks time and indexeseach array by its own offset.
Related Issue
Closes #9712
Motivation and Context
ARIMA(2, 0, 1)throws at any period. At period 50, 24 of the 80 order sets the constructoraccepts throw.
lags[i]is the row for timei + _arOrderandlaggedErrors[j]the row forj + _maOrder,so the counters agree only when the orders do.
The other direction does not throw, and that is the part worth looking hardest at. It pairs
an AR row from one bar with error terms from another, so the model gets fitted on rows that
never coexisted, and the fitted values move once they line up:
ARIMA(1, 0, 2, 50)over adeterministic series ends at 100.103983 before this change and 101.581063 after.
Two
catchblocks added for #8039 also read their row width off row zero, so a fit thatfailed for having no rows threw out of the handler meant to absorb it. Both widths follow
from the orders.
177 of 456 accepted order sets still throw at periods of 8 or less, so the issue is not fully
closed.
period < Math.Max(arOrder, maOrder)is weaker than what the fit needs, by up to sixbars in the range I measured, and tightening it is a separate call.
Requires Documentation Change
No.
How Has This Been Tested?
AcceptsAnAutoRegressiveOrderAboveTheMovingAverageOrdercovers(2, 0, 1),(3, 1, 1)and(4, 0, 2). All three throw on master. A fourth case withmaOrder > arOrdercame out of thedraft because it passes there, so it would have been a test that never fails.
Every test in the file uses
ARIMA(1, 0, 1, 50), the diagonal where the orders match and theold bound is accidentally right, so the change is a no-op there. That configuration sums to
7090.1814358551 over 120 points of a deterministic series and ends at 103.9912907073, both
before and after.
My local NUnit host crashes in a Python.NET finalizer before any test runs, because
QuantConnect.pythonnet2.0.65 wants Python 3.11 and this machine has 3.10, the samelimitation I noted on #9694. The figures above come from a console program linked against
QuantConnect.Indicators, which dumps the outcome of all 640 order-set and periodcombinations on master and on this branch and diffs them: 116 newly work, 0 newly throw.
Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>