{"action":"closed","issue":{"url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4878","repository_url":"https://api.github.com/repos/statsmodels/statsmodels","labels_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4878/labels{/name}","comments_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4878/comments","events_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4878/events","html_url":"https://github.com/statsmodels/statsmodels/issues/4878","id":349737898,"node_id":"MDU6SXNzdWUzNDk3Mzc4OTg=","number":4878,"title":"ZeroDivisionError given by endog length in statsmodels.tsa.holtwinters.ExponentialSmoothing.fit()","user":{"login":"g8a9","id":19472113,"node_id":"MDQ6VXNlcjE5NDcyMTEz","avatar_url":"https://avatars1.githubusercontent.com/u/19472113?v=4","gravatar_id":"","url":"https://api.github.com/users/g8a9","html_url":"https://github.com/g8a9","followers_url":"https://api.github.com/users/g8a9/followers","following_url":"https://api.github.com/users/g8a9/following{/other_user}","gists_url":"https://api.github.com/users/g8a9/gists{/gist_id}","starred_url":"https://api.github.com/users/g8a9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g8a9/subscriptions","organizations_url":"https://api.github.com/users/g8a9/orgs","repos_url":"https://api.github.com/users/g8a9/repos","events_url":"https://api.github.com/users/g8a9/events{/privacy}","received_events_url":"https://api.github.com/users/g8a9/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-11T14:27:06Z","updated_at":"2018-08-13T09:08:04Z","closed_at":"2018-08-13T09:08:04Z","author_association":"NONE","body":"Hi,\r\nI was using the ExponentialSmoothing class, fitting an **endog array of length 5**. The method raises a **ZeroDivisionError**, here it is the relevant part of the stack:\r\n```python\r\nFile \"/Users/giuseppe/development/time_series_forecasting/exp_smoothing.py\", line 125, in forecast_sliding_window\r\n    model_fit = ExponentialSmoothing(window, trend=None, seasonal=None).fit(smoothing_level=0.8)\r\n  File \"/Users/giuseppe/development/time_series_forecasting/venv/lib/python3.6/site-packages/statsmodels/tsa/holtwinters.py\", line 594, in fit\r\n    use_boxcox=use_boxcox, lamda=lamda, remove_bias=remove_bias)\r\n  File \"/Users/giuseppe/development/time_series_forecasting/venv/lib/python3.6/site-packages/statsmodels/tsa/holtwinters.py\", line 735, in _predict\r\n    aicc = aic + (2 * (k + 2) * (k + 3)) / (self.nobs - k - 3)\r\nZeroDivisionError: division by zero\r\n```\r\nAs far as I can understand, the problem is created by these lines in **holtwinters.py**:\r\n```python\r\n...\r\n733 k = m * seasoning + 2 * trending + 2 + 1 * damped\r\n734 aic = self.nobs * np.log(sse / self.nobs) + (k) * 2\r\n735 aicc = aic + (2 * (k + 2) * (k + 3)) / (self.nobs - k - 3)\r\n...\r\n```\r\n\r\n- *self.nobs* is equivalent to the length of input endog array: 5. \r\n- *k*, in my case of Simple Exponential Smoothing (*seasoning, trending and damped* are 0) is 2. \r\n\r\nAlso, what happens if the divider is negative (e.g. trying to fit an endog array of 3 values)? Does it invalidate results given by the model? "}}
{"actor":{"display_login":"g8a9"}}