1

Freaky convergence results and svd errors with statsmodels.tsa.arima_model

Below is code that does not consistently run successfully or fail for different settings of Transform Parameters ("transparams") and for different precision levels.

If you look at the warnings and errors, in no consistent fashion that is immediately apparent to me we get...

sometimes there are "ConvergenceWarning: Maximum Likelihood ..."

and sometimes there are:

raise LinAlgError("SVD did not converge") numpy.linalg.linalg.LinAlgError: SVD did not converge

Any help is appreciated!

# "Freaky" results with statsmodels.tsa.arima_model
#
# Below is code that does not consistently run successfully or fail
# for different settings of Transform Parameters ("transparams") and
# for different precision levels.
#
# If you look at the warnings and errors, in no consistent fashion that
# is immediately apparent to me we get...
#
# sometimes there are
#         "ConvergenceWarning: Maximum Likelihood ..."
#
# and sometimes there are:
#
#         raise LinAlgError("SVD did not converge")
#         numpy.linalg.linalg.LinAlgError: SVD did not converge
#

from statsmodels.tsa.arima_model import ARIMA

# raw data is from a printout -- lower in code precision is set with rounding

# this is length 37 -- it was printed out from a dataframe that was in some other code
y_raw = [0.019269999999999999, 0.03916, 0.02274, -0.048919999999999998,
         0.0066800000000000002,
         0.019910000000000001, -0.015610000000000001, 0.0039699999999999996,
         0.0059199999999999999, 0.021600000000000001, -0.0025600000000000002,
         -0.018630000000000001, -0.0144, -0.0053099999999999996,
         0.00134, 0.01, 0.019140000000000001, 0.013599999999999999,
         -0.023640000000000001, 0.0019599999999999999,
         -0.02155, 0.0060099999999999997, 0.01393, 0.0071999999999999998,
         -0.0045500000000000002, -0.0019599999999999999, 0.0039199999999999999,
         -0.0052100000000000002, 0.0039300000000000003, 0.0032599999999999999,
         0.0064999999999999997, 0.00711, 0.0032100000000000002,
         -0.011509999999999999, 0.0058199999999999997, 0.00579, 0.01023]

# this is length 37 -- it was printed out from a dataframe that was in some other code
x_raw = [4.9103500000000002, 4.1414200000000001, 3.1673200000000001,
         0.67383000000000004, 0.41469, -1.47105, -5.0846299999999998,
         -6.5102099999999998, -4.7134400000000003, -2.9291100000000001,
         -2.2156699999999998, 0.023, -0.40053, 1.9970699999999999,
         5.2835000000000001, 6.5333899999999998, 4.0112399999999999,
         0.45212999999999998, 0.54645999999999995, 1.4251400000000001,
         2.1529699999999998, 1.5075799999999999, 1.3955200000000001,
         2.2717000000000001, 2.4378099999999998, 4.9119999999999999,
         5.1389199999999997, 3.8104399999999998, 4.6619700000000002,
         4.3374199999999998, 4.4402799999999996, 4.1830299999999996,
         4.1744700000000003, 2.27535, 2.2844899999999999, 1.7574700000000001,
         1.3590599999999999]


for rval in range(1, 9):

  for tflag in [True, False]:

    y = [round(z,rval) for z in y_raw]
    x = [round(z,rval) for z in x_raw]

    try:
        reg = ARIMA(endog=y, exog=x, order=(3, 0, 0)).fit(transparams=tflag, trend='nc', disp=False, tol=1e-20)
        #print(reg.summary())
        print('Transform Flag: {}   Precision: {} - Success'.format(tflag, rval))
    except:
        print('Transform Flag: {}   Precision: {} - Fail'.format(tflag, rval))


#
# Following is the results of the code block above
#
# Transform Flag: True   Precision: 1 - Fail
# Transform Flag: False   Precision: 1 - Fail
# Transform Flag: True   Precision: 2 - Success
# C:\Python\Anaconda3-4.4.0-64BIT\lib\site-packages\statsmodels\base\model.py:496: ConvergenceWarning: Maximum Likelihood optimization failed to converge. Check mle_retvals
#   "Check mle_retvals", ConvergenceWarning)
# Transform Flag: False   Precision: 2 - Success
# Transform Flag: True   Precision: 3 - Success
# Transform Flag: False   Precision: 3 - Success
# Transform Flag: True   Precision: 4 - Success
# C:\Python\Anaconda3-4.4.0-64BIT\lib\site-packages\statsmodels\base\model.py:496: ConvergenceWarning: Maximum Likelihood optimization failed to converge. Check mle_retvals
#   "Check mle_retvals", ConvergenceWarning)
# Transform Flag: False   Precision: 4 - Success
# Transform Flag: True   Precision: 5 - Fail
# C:\Python\Anaconda3-4.4.0-64BIT\lib\site-packages\statsmodels\tsa\tsatools.py:584: RuntimeWarning: overflow encountered in exp
#   newparams = ((1-np.exp(-params))/
# C:\Python\Anaconda3-4.4.0-64BIT\lib\site-packages\statsmodels\tsa\tsatools.py:585: RuntimeWarning: overflow encountered in exp
#   (1+np.exp(-params))).copy()
# C:\Python\Anaconda3-4.4.0-64BIT\lib\site-packages\statsmodels\tsa\tsatools.py:585: RuntimeWarning: invalid value encountered in true_divide
#   (1+np.exp(-params))).copy()
# C:\Python\Anaconda3-4.4.0-64BIT\lib\site-packages\statsmodels\tsa\tsatools.py:586: RuntimeWarning: overflow encountered in exp
#   tmp = ((1-np.exp(-params))/
# C:\Python\Anaconda3-4.4.0-64BIT\lib\site-packages\statsmodels\tsa\tsatools.py:587: RuntimeWarning: overflow encountered in exp
#   (1+np.exp(-params))).copy()
# C:\Python\Anaconda3-4.4.0-64BIT\lib\site-packages\statsmodels\tsa\tsatools.py:587: RuntimeWarning: invalid value encountered in true_divide
#   (1+np.exp(-params))).copy()
# Transform Flag: False   Precision: 5 - Success
# Transform Flag: True   Precision: 6 - Fail
# Transform Flag: False   Precision: 6 - Success
# Transform Flag: True   Precision: 7 - Fail
# Transform Flag: False   Precision: 7 - Success
# Transform Flag: True   Precision: 8 - Fail
# Transform Flag: False   Precision: 8 - Success
Odil
  • 25
  • 5

0 Answers0