Background: I'm developing a program using statsmodels that fits 27 arima models (p,d,q=0,1,2) to over 100 variables and chooses the model with the lowest aic and statistically significant t-statistics for the AR/MA coefficients and statistically significant p-values for the dickey fuller test...
For one particular variable and one particular set of parameters, I get
LinAlgError: SVD did not converge
for replication, the variable and the code that fails are below
rollrate =[0.3469842191781748,
0.9550689157572028,
0.48170862494888256,
0.15277985674197356,
0.46102487817508747,
0.32777706854320243,
0.5163787896482797,
0.01707716528127215,
0.015036662424309755,
0.2299825242910243,
0.03719773802216722,
0.24392098372995807,
0.1783587055969874,
0.6759904243574179,
0.1197617555878022,
0.04274682226635633,
0.27369984820298465,
0.18999355015483932,
0.2985208240580264,
0.2872064881442138,
1.0522764728046277,
0.3694114556631419,
0.09613536093441034,
0.6648215681632191,
0.3223120091564835,
0.9274048223872483,
0.2763221143255601,
0.4501460109958479,
0.2220472247972312,
0.3644512582291407,
0.7790042237519584,
0.3749145302678043,
1.2771681290160286,
0.6760112486224217,
0.5214358465170098,
0.84041997296269,
0.12054593136059581,
0.18900376737686622,
0.042561102427304424,
0.17189805124670604,
0.11383752243305952,
0.2687780002387387,
0.717538770963329,
0.26636160206108384,
0.04221743047344771,
0.3259506533106764,
0.20146525340606328,
0.4059344185647537,
0.07503287726465639,
0.3011594076817088,
0.1433563136989911,
0.14803562944375281,
0.23096999679467808,
0.31133672787599703,
0.2313639154827471,
0.30343086620083537,
0.4608439884577555,
0.19149827372467804,
0.2506814947310181,
1.008458195025946,
0.3776434264127751,
0.344728062930179,
0.2110402015365776,
0.26582041849423843,
1.1019000121595244,
0.0,
0.023068095385979804,
0.014256779894199491,
0.3209225608633755,
0.00294468492742426,
0.0,
0.3346732726544143,
0.38256681208088283,
0.4916019617068597,
0.06922156984602362,
0.34458053250016984,
0.0,
0.09615667784109984,
1.8271531669931351,
0,
0,
0.0,
0,
0.0,
0.03205594450156685,
0.0,
0.0,
0.0,
0,
0.0,
0,
0.0,
0,
0,
1.0,
0]
p=2
q=2
d=0
fit = statsmodels.api.tsa.ARIMA(rollRate, (p,d,q)).fit(transparams=False)
I understand that the particular parameters p=2,d=2,q=0 may be a terrible ARIMA model for this particular variable and that the variable itself may not be a suitable candidate for an ARIMA model due to the many zeroes or unstationary qualities, but I need a way to possibly bypass this error or fix the issue in order to keep the program iterating through parameters. Thanks
try-except
block? This way you accept that for some parameter combinations your selected model cannot be fitted. – Chambermaidtry: fit = statsmodels.api.tsa.ARIMA(rollRate, (p,d,q)).fit(transparams=False) except (ValueError, LinAlgError): pass
but i get aNameError: name 'LinAlgError' is not defined
– HutchingsLinAlgError
to your namespace:from numpy.linalg import LinAlgError
– Chambermaid_safe_arma_fit
. It also handles the cases of non-convergence due to bad starting parameters. All pretty naive though. github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/… – Celindaceline_safe_arma_fit
work ? – Taegu