We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] `model_evaluation.evaluate` fails for `statsmodels` forecasters with exogenous features
**Describe the bug**

model_evaluation.evaluate creates X_test containing both train and test samples.  For statsmodels models with exogenous features X_test length must equal the forecast horizon and therefore this currently throws the error:

`ValueError: Provided exogenous values are not of the appropriate shape.`

This bug occurs for UnobservedComponents and SARIMAX.

The root cause of the bug is in the `_split` function:
https://github.com/sktime/sktime/blob/a5f824a5fff1c3fc1babd3f34b94c5055ec040b0/sktime/forecasting/model_evaluation/_functions.py#L60

This could be modified to 'X.iloc[test].sort_index()' for statsmodels models with exogenous features or alternatively by filtering X here:
https://github.com/sktime/sktime/blob/a5f824a5fff1c3fc1babd3f34b94c5055ec040b0/sktime/forecasting/base/adapters/_statsmodels.py#L104

**To Reproduce**

```python
from sktime.datasets import load_longley
from sktime.forecasting.structural import UnobservedComponents
from sktime.forecasting.model_evaluation import evaluate
from sktime.forecasting.model_selection import SlidingWindowSplitter

y, X = load_longley()

forecaster = UnobservedComponents(level='local linear trend')

cv = SlidingWindowSplitter(fh=[1,2,3],
                           window_length = 4,
                           step_length = 1)

results = evaluate(
        forecaster=forecaster, y=y, X = X,
        cv=cv, strategy='refit', return_data=True,
        error_score = 'raise'
        )
```

**Versions**

System:
python: 3.8.12 (default, Nov 20 2022, 10:50:06)  [Clang 14.0.0 (clang-1400.0.29.202)]
machine: macOS-13.0.1-arm64-arm-64bit

Python dependencies:
          pip: 21.2
   setuptools: 63.1.0
      sklearn: 1.1.3
       sktime: 0.14.0
  statsmodels: 0.13.5
        numpy: 1.22.0
        scipy: 1.9.3
       pandas: 1.4.1
   matplotlib: 3.6.2
       joblib: 1.2.0
        numba: 0.56.4
     pmdarima: None
      tsfresh: None

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sktime/forecasting/base/adapters/_statsmodels.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # !/usr/bin/env python3 -u
3 # copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
4 """Implements adapter for statsmodels forecasters to be used in sktime framework."""
5 
6 __author__ = ["mloning"]
7 __all__ = ["_StatsModelsAdapter"]
8 
9 import inspect
10 from warnings import warn
11 
12 import numpy as np
13 import pandas as pd
14 
15 from sktime.forecasting.base import BaseForecaster
16 
17 
18 class _StatsModelsAdapter(BaseForecaster):
19     """Base class for interfacing statsmodels forecasting algorithms."""
20 
21     _fitted_param_names = ()
22     _tags = {
23         "ignores-exogeneous-X": True,
24         "requires-fh-in-fit": False,
25         "handles-missing-data": False,
26         "python_dependencies": "statsmodels",
27     }
28 
29     def __init__(self, random_state=None):
30         self._forecaster = None
31         self.random_state = random_state
32         self._fitted_forecaster = None
33         super(_StatsModelsAdapter, self).__init__()
34 
35     def _fit(self, y, X=None, fh=None):
36         """Fit to training data.
37 
38         Parameters
39         ----------
40         y : pd.Series
41             Target time series to which to fit the forecaster.
42         fh : int, list or np.array, optional (default=None)
43             The forecasters horizon with the steps ahead to to predict.
44         X : pd.DataFrame, optional (default=None)
45             Exogenous variables are ignored
46 
47         Returns
48         -------
49         self : returns an instance of self.
50         """
51         # statsmodels does not support the pd.Int64Index as required,
52         # so we coerce them here to pd.RangeIndex
53         if isinstance(y, pd.Series) and y.index.is_integer():
54             y, X = _coerce_int_to_range_index(y, X)
55         self._fit_forecaster(y, X)
56         return self
57 
58     def _fit_forecaster(self, y_train, X_train=None):
59         """Log used internally in fit."""
60         raise NotImplementedError("abstract method")
61 
62     def _update(self, y, X=None, update_params=True):
63         """Update used internally in update."""
64         if update_params or self.is_composite():
65             super()._update(y, X, update_params=update_params)
66         else:
67             if not hasattr(self._fitted_forecaster, "append"):
68                 warn(
69                     f"NotImplementedWarning: {self.__class__.__name__} "
70                     f"can not accept new data when update_params=False. "
71                     f"Call with update_params=True to refit with new data."
72                 )
73             else:
74                 # only append unseen data to fitted forecaster
75                 index_diff = y.index.difference(
76                     self._fitted_forecaster.fittedvalues.index
77                 )
78                 if index_diff.isin(y.index).all():
79                     y = y.loc[index_diff]
80                 self._fitted_forecaster = self._fitted_forecaster.append(y)
81 
82     def _predict(self, fh, X=None):
83         """Make forecasts.
84 
85         Parameters
86         ----------
87         fh : ForecastingHorizon
88             The forecasters horizon with the steps ahead to to predict.
89             Default is one-step ahead forecast,
90             i.e. np.array([1])
91         X : pd.DataFrame, optional (default=None)
92             Exogenous variables are ignored.
93 
94         Returns
95         -------
96         y_pred : pd.Series
97             Returns series of predicted values.
98         """
99         # statsmodels requires zero-based indexing starting at the
100         # beginning of the training series when passing integers
101         start, end = fh.to_absolute_int(self._y.index[0], self.cutoff)[[0, -1]]
102 
103         if "exog" in inspect.signature(self._forecaster.__init__).parameters.keys():
104             y_pred = self._fitted_forecaster.predict(start=start, end=end, exog=X)
105         else:
106             y_pred = self._fitted_forecaster.predict(start=start, end=end)
107 
108         # statsmodels forecasts all periods from start to end of forecasting
109         # horizon, but only return given time points in forecasting horizon
110         y_pred = y_pred.loc[fh.to_absolute(self.cutoff).to_pandas()]
111         # ensure that name is not added nor removed
112         # otherwise this may upset conversion to pd.DataFrame
113         y_pred.name = self._y.name
114         return y_pred
115 
116     def _get_fitted_params(self):
117         """Get fitted parameters.
118 
119         Returns
120         -------
121         fitted_params : dict
122         """
123         fitted_params = {}
124         for name in self._get_fitted_param_names():
125             if name in ["aic", "aicc", "bic", "hqic"]:
126                 fitted_params[name] = getattr(self._fitted_forecaster, name, None)
127             else:
128                 fitted_params[name] = self._fitted_forecaster.params.get(name)
129         return fitted_params
130 
131     def _get_fitted_param_names(self):
132         """Get names of fitted parameters."""
133         return self._fitted_param_names
134 
135 
136 def _coerce_int_to_range_index(y, X=None):
137     new_index = pd.RangeIndex(y.index[0], y.index[-1] + 1)
138     try:
139         np.testing.assert_array_equal(y.index, new_index)
140     except AssertionError:
141         raise ValueError(
142             "Coercion of integer pd.Index to pd.RangeIndex "
143             "failed. Please provide `y_train` with a "
144             "pd.RangeIndex."
145         )
146     y.index = new_index
147     if X is not None:
148         X.index = new_index
149     return y, X
150
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sktime/forecasting/base/adapters/_statsmodels.py b/sktime/forecasting/base/adapters/_statsmodels.py
--- a/sktime/forecasting/base/adapters/_statsmodels.py
+++ b/sktime/forecasting/base/adapters/_statsmodels.py
@@ -99,6 +99,16 @@
         # statsmodels requires zero-based indexing starting at the
         # beginning of the training series when passing integers
         start, end = fh.to_absolute_int(self._y.index[0], self.cutoff)[[0, -1]]
+        fh_abs = fh.to_absolute(self.cutoff).to_pandas()
+
+        # bug fix for evaluate function as test_plus_train indices are passed
+        # statsmodels exog must contain test indices only.
+        # For discussion see https://github.com/sktime/sktime/issues/3830
+        if X is not None:
+            ind_drop = self._X.index
+            X = X.loc[~X.index.isin(ind_drop)]
+            # Entire range of the forecast horizon is required
+            X = X[: fh_abs[-1]]
 
         if "exog" in inspect.signature(self._forecaster.__init__).parameters.keys():
             y_pred = self._fitted_forecaster.predict(start=start, end=end, exog=X)
@@ -107,7 +117,7 @@
 
         # statsmodels forecasts all periods from start to end of forecasting
         # horizon, but only return given time points in forecasting horizon
-        y_pred = y_pred.loc[fh.to_absolute(self.cutoff).to_pandas()]
+        y_pred = y_pred.loc[fh_abs]
         # ensure that name is not added nor removed
         # otherwise this may upset conversion to pd.DataFrame
         y_pred.name = self._y.name

{"golden_diff": "diff --git a/sktime/forecasting/base/adapters/_statsmodels.py b/sktime/forecasting/base/adapters/_statsmodels.py\n--- a/sktime/forecasting/base/adapters/_statsmodels.py\n+++ b/sktime/forecasting/base/adapters/_statsmodels.py\n@@ -99,6 +99,16 @@\n         # statsmodels requires zero-based indexing starting at the\n         # beginning of the training series when passing integers\n         start, end = fh.to_absolute_int(self._y.index[0], self.cutoff)[[0, -1]]\n+        fh_abs = fh.to_absolute(self.cutoff).to_pandas()\n+\n+        # bug fix for evaluate function as test_plus_train indices are passed\n+        # statsmodels exog must contain test indices only.\n+        # For discussion see https://github.com/sktime/sktime/issues/3830\n+        if X is not None:\n+            ind_drop = self._X.index\n+            X = X.loc[~X.index.isin(ind_drop)]\n+            # Entire range of the forecast horizon is required\n+            X = X[: fh_abs[-1]]\n \n         if \"exog\" in inspect.signature(self._forecaster.__init__).parameters.keys():\n             y_pred = self._fitted_forecaster.predict(start=start, end=end, exog=X)\n@@ -107,7 +117,7 @@\n \n         # statsmodels forecasts all periods from start to end of forecasting\n         # horizon, but only return given time points in forecasting horizon\n-        y_pred = y_pred.loc[fh.to_absolute(self.cutoff).to_pandas()]\n+        y_pred = y_pred.loc[fh_abs]\n         # ensure that name is not added nor removed\n         # otherwise this may upset conversion to pd.DataFrame\n         y_pred.name = self._y.name\n", "issue": "[BUG] `model_evaluation.evaluate` fails for `statsmodels` forecasters with exogenous features\n**Describe the bug**\r\n\r\nmodel_evaluation.evaluate creates X_test containing both train and test samples.  For statsmodels models with exogenous features X_test length must equal the forecast horizon and therefore this currently throws the error:\r\n\r\n`ValueError: Provided exogenous values are not of the appropriate shape.`\r\n\r\nThis bug occurs for UnobservedComponents and SARIMAX.\r\n\r\nThe root cause of the bug is in the `_split` function:\r\nhttps://github.com/sktime/sktime/blob/a5f824a5fff1c3fc1babd3f34b94c5055ec040b0/sktime/forecasting/model_evaluation/_functions.py#L60\r\n\r\nThis could be modified to 'X.iloc[test].sort_index()' for statsmodels models with exogenous features or alternatively by filtering X here:\r\nhttps://github.com/sktime/sktime/blob/a5f824a5fff1c3fc1babd3f34b94c5055ec040b0/sktime/forecasting/base/adapters/_statsmodels.py#L104\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom sktime.datasets import load_longley\r\nfrom sktime.forecasting.structural import UnobservedComponents\r\nfrom sktime.forecasting.model_evaluation import evaluate\r\nfrom sktime.forecasting.model_selection import SlidingWindowSplitter\r\n\r\ny, X = load_longley()\r\n\r\nforecaster = UnobservedComponents(level='local linear trend')\r\n\r\ncv = SlidingWindowSplitter(fh=[1,2,3],\r\n                           window_length = 4,\r\n                           step_length = 1)\r\n\r\nresults = evaluate(\r\n        forecaster=forecaster, y=y, X = X,\r\n        cv=cv, strategy='refit', return_data=True,\r\n        error_score = 'raise'\r\n        )\r\n```\r\n\r\n**Versions**\r\n\r\nSystem:\r\npython: 3.8.12 (default, Nov 20 2022, 10:50:06)  [Clang 14.0.0 (clang-1400.0.29.202)]\r\nmachine: macOS-13.0.1-arm64-arm-64bit\r\n\r\nPython dependencies:\r\n          pip: 21.2\r\n   setuptools: 63.1.0\r\n      sklearn: 1.1.3\r\n       sktime: 0.14.0\r\n  statsmodels: 0.13.5\r\n        numpy: 1.22.0\r\n        scipy: 1.9.3\r\n       pandas: 1.4.1\r\n   matplotlib: 3.6.2\r\n       joblib: 1.2.0\r\n        numba: 0.56.4\r\n     pmdarima: None\r\n      tsfresh: None\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# !/usr/bin/env python3 -u\n# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)\n\"\"\"Implements adapter for statsmodels forecasters to be used in sktime framework.\"\"\"\n\n__author__ = [\"mloning\"]\n__all__ = [\"_StatsModelsAdapter\"]\n\nimport inspect\nfrom warnings import warn\n\nimport numpy as np\nimport pandas as pd\n\nfrom sktime.forecasting.base import BaseForecaster\n\n\nclass _StatsModelsAdapter(BaseForecaster):\n    \"\"\"Base class for interfacing statsmodels forecasting algorithms.\"\"\"\n\n    _fitted_param_names = ()\n    _tags = {\n        \"ignores-exogeneous-X\": True,\n        \"requires-fh-in-fit\": False,\n        \"handles-missing-data\": False,\n        \"python_dependencies\": \"statsmodels\",\n    }\n\n    def __init__(self, random_state=None):\n        self._forecaster = None\n        self.random_state = random_state\n        self._fitted_forecaster = None\n        super(_StatsModelsAdapter, self).__init__()\n\n    def _fit(self, y, X=None, fh=None):\n        \"\"\"Fit to training data.\n\n        Parameters\n        ----------\n        y : pd.Series\n            Target time series to which to fit the forecaster.\n        fh : int, list or np.array, optional (default=None)\n            The forecasters horizon with the steps ahead to to predict.\n        X : pd.DataFrame, optional (default=None)\n            Exogenous variables are ignored\n\n        Returns\n        -------\n        self : returns an instance of self.\n        \"\"\"\n        # statsmodels does not support the pd.Int64Index as required,\n        # so we coerce them here to pd.RangeIndex\n        if isinstance(y, pd.Series) and y.index.is_integer():\n            y, X = _coerce_int_to_range_index(y, X)\n        self._fit_forecaster(y, X)\n        return self\n\n    def _fit_forecaster(self, y_train, X_train=None):\n        \"\"\"Log used internally in fit.\"\"\"\n        raise NotImplementedError(\"abstract method\")\n\n    def _update(self, y, X=None, update_params=True):\n        \"\"\"Update used internally in update.\"\"\"\n        if update_params or self.is_composite():\n            super()._update(y, X, update_params=update_params)\n        else:\n            if not hasattr(self._fitted_forecaster, \"append\"):\n                warn(\n                    f\"NotImplementedWarning: {self.__class__.__name__} \"\n                    f\"can not accept new data when update_params=False. \"\n                    f\"Call with update_params=True to refit with new data.\"\n                )\n            else:\n                # only append unseen data to fitted forecaster\n                index_diff = y.index.difference(\n                    self._fitted_forecaster.fittedvalues.index\n                )\n                if index_diff.isin(y.index).all():\n                    y = y.loc[index_diff]\n                self._fitted_forecaster = self._fitted_forecaster.append(y)\n\n    def _predict(self, fh, X=None):\n        \"\"\"Make forecasts.\n\n        Parameters\n        ----------\n        fh : ForecastingHorizon\n            The forecasters horizon with the steps ahead to to predict.\n            Default is one-step ahead forecast,\n            i.e. np.array([1])\n        X : pd.DataFrame, optional (default=None)\n            Exogenous variables are ignored.\n\n        Returns\n        -------\n        y_pred : pd.Series\n            Returns series of predicted values.\n        \"\"\"\n        # statsmodels requires zero-based indexing starting at the\n        # beginning of the training series when passing integers\n        start, end = fh.to_absolute_int(self._y.index[0], self.cutoff)[[0, -1]]\n\n        if \"exog\" in inspect.signature(self._forecaster.__init__).parameters.keys():\n            y_pred = self._fitted_forecaster.predict(start=start, end=end, exog=X)\n        else:\n            y_pred = self._fitted_forecaster.predict(start=start, end=end)\n\n        # statsmodels forecasts all periods from start to end of forecasting\n        # horizon, but only return given time points in forecasting horizon\n        y_pred = y_pred.loc[fh.to_absolute(self.cutoff).to_pandas()]\n        # ensure that name is not added nor removed\n        # otherwise this may upset conversion to pd.DataFrame\n        y_pred.name = self._y.name\n        return y_pred\n\n    def _get_fitted_params(self):\n        \"\"\"Get fitted parameters.\n\n        Returns\n        -------\n        fitted_params : dict\n        \"\"\"\n        fitted_params = {}\n        for name in self._get_fitted_param_names():\n            if name in [\"aic\", \"aicc\", \"bic\", \"hqic\"]:\n                fitted_params[name] = getattr(self._fitted_forecaster, name, None)\n            else:\n                fitted_params[name] = self._fitted_forecaster.params.get(name)\n        return fitted_params\n\n    def _get_fitted_param_names(self):\n        \"\"\"Get names of fitted parameters.\"\"\"\n        return self._fitted_param_names\n\n\ndef _coerce_int_to_range_index(y, X=None):\n    new_index = pd.RangeIndex(y.index[0], y.index[-1] + 1)\n    try:\n        np.testing.assert_array_equal(y.index, new_index)\n    except AssertionError:\n        raise ValueError(\n            \"Coercion of integer pd.Index to pd.RangeIndex \"\n            \"failed. Please provide `y_train` with a \"\n            \"pd.RangeIndex.\"\n        )\n    y.index = new_index\n    if X is not None:\n        X.index = new_index\n    return y, X\n", "path": "sktime/forecasting/base/adapters/_statsmodels.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# !/usr/bin/env python3 -u\n# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)\n\"\"\"Implements adapter for statsmodels forecasters to be used in sktime framework.\"\"\"\n\n__author__ = [\"mloning\"]\n__all__ = [\"_StatsModelsAdapter\"]\n\nimport inspect\nfrom warnings import warn\n\nimport numpy as np\nimport pandas as pd\n\nfrom sktime.forecasting.base import BaseForecaster\n\n\nclass _StatsModelsAdapter(BaseForecaster):\n    \"\"\"Base class for interfacing statsmodels forecasting algorithms.\"\"\"\n\n    _fitted_param_names = ()\n    _tags = {\n        \"ignores-exogeneous-X\": True,\n        \"requires-fh-in-fit\": False,\n        \"handles-missing-data\": False,\n        \"python_dependencies\": \"statsmodels\",\n    }\n\n    def __init__(self, random_state=None):\n        self._forecaster = None\n        self.random_state = random_state\n        self._fitted_forecaster = None\n        super(_StatsModelsAdapter, self).__init__()\n\n    def _fit(self, y, X=None, fh=None):\n        \"\"\"Fit to training data.\n\n        Parameters\n        ----------\n        y : pd.Series\n            Target time series to which to fit the forecaster.\n        fh : int, list or np.array, optional (default=None)\n            The forecasters horizon with the steps ahead to to predict.\n        X : pd.DataFrame, optional (default=None)\n            Exogenous variables are ignored\n\n        Returns\n        -------\n        self : returns an instance of self.\n        \"\"\"\n        # statsmodels does not support the pd.Int64Index as required,\n        # so we coerce them here to pd.RangeIndex\n        if isinstance(y, pd.Series) and y.index.is_integer():\n            y, X = _coerce_int_to_range_index(y, X)\n        self._fit_forecaster(y, X)\n        return self\n\n    def _fit_forecaster(self, y_train, X_train=None):\n        \"\"\"Log used internally in fit.\"\"\"\n        raise NotImplementedError(\"abstract method\")\n\n    def _update(self, y, X=None, update_params=True):\n        \"\"\"Update used internally in update.\"\"\"\n        if update_params or self.is_composite():\n            super()._update(y, X, update_params=update_params)\n        else:\n            if not hasattr(self._fitted_forecaster, \"append\"):\n                warn(\n                    f\"NotImplementedWarning: {self.__class__.__name__} \"\n                    f\"can not accept new data when update_params=False. \"\n                    f\"Call with update_params=True to refit with new data.\"\n                )\n            else:\n                # only append unseen data to fitted forecaster\n                index_diff = y.index.difference(\n                    self._fitted_forecaster.fittedvalues.index\n                )\n                if index_diff.isin(y.index).all():\n                    y = y.loc[index_diff]\n                self._fitted_forecaster = self._fitted_forecaster.append(y)\n\n    def _predict(self, fh, X=None):\n        \"\"\"Make forecasts.\n\n        Parameters\n        ----------\n        fh : ForecastingHorizon\n            The forecasters horizon with the steps ahead to to predict.\n            Default is one-step ahead forecast,\n            i.e. np.array([1])\n        X : pd.DataFrame, optional (default=None)\n            Exogenous variables are ignored.\n\n        Returns\n        -------\n        y_pred : pd.Series\n            Returns series of predicted values.\n        \"\"\"\n        # statsmodels requires zero-based indexing starting at the\n        # beginning of the training series when passing integers\n        start, end = fh.to_absolute_int(self._y.index[0], self.cutoff)[[0, -1]]\n        fh_abs = fh.to_absolute(self.cutoff).to_pandas()\n\n        # bug fix for evaluate function as test_plus_train indices are passed\n        # statsmodels exog must contain test indices only.\n        # For discussion see https://github.com/sktime/sktime/issues/3830\n        if X is not None:\n            ind_drop = self._X.index\n            X = X.loc[~X.index.isin(ind_drop)]\n            # Entire range of the forecast horizon is required\n            X = X[: fh_abs[-1]]\n\n        if \"exog\" in inspect.signature(self._forecaster.__init__).parameters.keys():\n            y_pred = self._fitted_forecaster.predict(start=start, end=end, exog=X)\n        else:\n            y_pred = self._fitted_forecaster.predict(start=start, end=end)\n\n        # statsmodels forecasts all periods from start to end of forecasting\n        # horizon, but only return given time points in forecasting horizon\n        y_pred = y_pred.loc[fh_abs]\n        # ensure that name is not added nor removed\n        # otherwise this may upset conversion to pd.DataFrame\n        y_pred.name = self._y.name\n        return y_pred\n\n    def _get_fitted_params(self):\n        \"\"\"Get fitted parameters.\n\n        Returns\n        -------\n        fitted_params : dict\n        \"\"\"\n        fitted_params = {}\n        for name in self._get_fitted_param_names():\n            if name in [\"aic\", \"aicc\", \"bic\", \"hqic\"]:\n                fitted_params[name] = getattr(self._fitted_forecaster, name, None)\n            else:\n                fitted_params[name] = self._fitted_forecaster.params.get(name)\n        return fitted_params\n\n    def _get_fitted_param_names(self):\n        \"\"\"Get names of fitted parameters.\"\"\"\n        return self._fitted_param_names\n\n\ndef _coerce_int_to_range_index(y, X=None):\n    new_index = pd.RangeIndex(y.index[0], y.index[-1] + 1)\n    try:\n        np.testing.assert_array_equal(y.index, new_index)\n    except AssertionError:\n        raise ValueError(\n            \"Coercion of integer pd.Index to pd.RangeIndex \"\n            \"failed. Please provide `y_train` with a \"\n            \"pd.RangeIndex.\"\n        )\n    y.index = new_index\n    if X is not None:\n        X.index = new_index\n    return y, X\n", "path": "sktime/forecasting/base/adapters/_statsmodels.py"}]}