This code:
import numpy as np
from statsmodels.tsa.api import ExponentialSmoothing
time_series = np.array([1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4])
print(ExponentialSmoothing(time_series, seasonal_periods=4, trend=None, seasonal="add").fit().forecast(4)) # [1. 2. 3. 4.]
runs without warnings and correctly prints [1. 2. 3. 4.] on my computer (Anaconda Navigator 1.9.12 with Visual Studio Code 1.45.1, running python 3.7.6, numpy 1.18.1, statsmodels 0.11.0).
However on my colleague's computer (Visual Studio Code running Python 3.8, numpy 1.18.4, statsmodels 0.11.0) the same code triggers the following warnings before correctly printing [1. 2. 3. 4.]:
...\statsmodels\tsa\holtwinters.py:725: RuntimeWarning: invalid value encountered in less_equal loc = initial_p <= lb
...\statsmodels\tsa\holtwinters.py:731: RuntimeWarning: invalid value encountered in greater_equal loc = initial_p >= ub
...\statsmodels\tsa\holtwinters.py:956: RuntimeWarning: divide by zero encountered in log aic = self.nobs * np.log(sse / self.nobs) + k * 2
...\statsmodels\tsa\holtwinters.py:962: RuntimeWarning: divide by zero encountered in log bic = self.nobs * np.log(sse / self.nobs) + k * np.log(self.nobs)
How can we fix things so that my colleague doesn't get these RuntimeWarnings, please? Or should we not worry about them? Many thanks.
UPDATE: I think I have found the answer. My test data was too perfect and the warnings were caused by that. Introducing jitter into the data eliminates the warnings. Either way I think, on the basis of this, that we can ignore the warnings anyway:
import numpy as np
from statsmodels.tsa.api import ExponentialSmoothing
time_series = np.array([1.2, 1.8, 3.2, 3.8, 1, 2, 3, 4, 1.1, 1.9, 3.1, 3.9, 1, 2, 3, 4])
print(ExponentialSmoothing(time_series, seasonal_periods=4, trend=None, seasonal="add").fit().forecast(4))
# [1.07500096 1.92499933 3.07500112 3.92499949]
ANOTHER UPDATE: Nope, that wasn't it. On my computer I still get no warnings, but my colleague gets
...\statsmodels\tsa\holtwinters.py:725: RuntimeWarning: invalid value encountered in less_equal loc = initial_p <= lb
...\statsmodels\tsa\holtwinters.py:731: RuntimeWarning: invalid value encountered in greater_equal loc = initial_p >= ub