Repository: statsmodels/statsmodels

Issue:
Series of same data: Divide by Zero encountered in true_divide
#### Describe the bug

Hello,
I am predicting a series of exact same data (Series min == max == 51653410816.0) values.
The series I am using is fixed to have a 7d frequency set and is over ~2 years.

Before, I was already able to get a constant prediction with the forecast being the same values.
I am using the fit and forecast method, while not giving any parameters to the fit method.
```python

ets_fit: ETSResults = ETSModel(
            data_series,
            error="mul",
            trend="mul",
            initialization_method="estimated", # no real documentation here
            missing="skip" # drop missing values, like nan -> doesnt work due to freq not being detected even if set
            ).fit(disp=False) # type: ignore
        prediction: Series = ets_fit.forecast(120)
```

I am unsure what changed, but now I get following error:

```
Python310\lib\site-packages\statsmodels\tsa\exponential_smoothing\ets.py:1228: RuntimeWarning: divide by zero encountered in true_divide
  return (data - yhat) / yhat

Exception: <class 'ValueError'>
Exception Message: NumPy boolean array indexing assignment cannot assign 0 input values to the 1 output values where the mask is true
``` 

#### Code Sample, a copy-pastable example if possible


```python

predict_data = {1591228800: 51653410816.0, 1591833600: 51653410816.0, 1592438400: 51653410816.0, 1593043200: 51653410816.0, 1593648000: 51653410816.0, 1594252800: 51653410816.0, 1594857600: 51653410816.0, 1595462400: 51653410816.0, 1596067200: 51653410816.0, 1596672000: 51653410816.0, 1597276800: 51653410816.0, 1597881600: 51653410816.0, 1598486400: 51653410816.0, 1599091200: 51653410816.0, 1657756800: 51653410816.0}
# this contains way more timestamps, but I added the 

positive_data = {datetime.utcfromtimestamp(k): v for k, v in predict_data.items() if v is not None and v > 0}
data_series: Series = Series(positive_data,
            ).resample(f"{dp_freq_hour}H"    # make sure the frequency is correct
            ).mean() 

data_series = data_series.interpolate()

ets_fit: ETSResults = ETSModel(
    data_series,
    error="mul",
    trend="mul",
    initialization_method="estimated", # no real documentation here
    missing="skip" # drop missing values, like nan -> doesnt work due to freq not being detected even if set
    ).fit(disp=False) # type: ignore
prediction: Series = ets_fit.forecast(forecast_dp_count)

```

I did not found a similar issue in the tracker

<details>

**Note**: As you can see, there are many issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates.

**Note**: Please be sure you are using the latest released version of `statsmodels`, or a recent build of `main`. If your problem has been fixed in an unreleased version, you might be able to use `main` until a new release occurs. 

**Note**: If you are using a released version, have you verified that the bug exists in the main branch of this repository? It helps the limited resources if we know problems exist in the current main branch so that they do not need to check whether the code sample produces a bug in the next release.

</details>


If the issue has not been resolved, please file it in the issue tracker.

#### Expected Output

A prediction with each value being  51653410816

#### Output of ``import statsmodels.api as sm; sm.show_versions()``

<details>

INSTALLED VERSIONS
------------------
Python: 3.10.2.final.0

statsmodels
===========

Installed: 0.13.2 (C:\Users\XX\AppData\Local\Programs\Python\Python310\lib\site-packages\statsmodels)

Required Dependencies
=====================

cython: 0.29.28 (C:\Users\XX\AppData\Local\Programs\Python\Python310\lib\site-packages\Cython)
numpy: 1.22.3 (C:\Users\XX\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy)
scipy: 1.8.0 (C:\Users\XX\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy)
pandas: 1.4.1 (C:\Users\XX\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas)
    dateutil: 2.8.2 (C:\Users\XX\AppData\Local\Programs\Python\Python310\lib\site-packages\dateutil)
patsy: 0.5.2 (C:\Users\XX\AppData\Local\Programs\Python\Python310\lib\site-packages\patsy)

Optional Dependencies
=====================

matplotlib: 3.5.1 (C:\Users\XX\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib)
    backend: TkAgg 
cvxopt: Not installed
joblib: Not installed

Developer Tools
================

IPython: Not installed
    jinja2: Not installed
sphinx: Not installed
    pygments: Not installed
pytest: Not installed
virtualenv: Not installed


</details>



Discussion:
Thanks, this is a pretty straightforward indexing bug introduced in https://github.com/statsmodels/statsmodels/commit/d13b2894d6a5a22f561a167a8857fc5c85fcd7de.

Resolving patch:
diff --git a/statsmodels/tsa/exponential_smoothing/ets.py b/statsmodels/tsa/exponential_smoothing/ets.py
--- a/statsmodels/tsa/exponential_smoothing/ets.py
+++ b/statsmodels/tsa/exponential_smoothing/ets.py
@@ -1165,7 +1165,7 @@ def _loglike_internal(
             # parameterizations, we clip negative values to very small positive
             # values so that the log-transformation yields very large negative
             # values.
-            yhat[yhat <= 0] = 1 / (1e-8 * (1 + np.abs(yhat[yhat < 0])))
+            yhat[yhat <= 0] = 1 / (1e-8 * (1 + np.abs(yhat[yhat <= 0])))
             logL -= np.sum(np.log(yhat))
         return logL
 


Test patch: