# Buggy code
def summary(self, alpha=0.05, start=None):
    # Create the model name

    # See if we have an ARIMA component
    order = ""
    if self.model.k_ar + self.model.k_diff + self.model.k_ma > 0:
        if self.model.k_ar == self.model.k_ar_params:
            order_ar = self.model.k_ar
        else:
            order_ar = tuple(self.polynomial_ar.nonzero()[0][1:])
        if self.model.k_ma == self.model.k_ma_params:
            order_ma = self.model.k_ma
        else:
            order_ma = tuple(self.polynomial_ma.nonzero()[0][1:])
        # If there is simple differencing, then that is reflected in the
        # dependent variable name
        k_diff = 0 if self.model.simple_differencing else self.model.k_diff
        order = "(%s, %d, %s)" % (order_ar, k_diff, order_ma)
    # See if we have an SARIMA component
    seasonal_order = ""
    has_seasonal = (
        self.model.k_seasonal_ar + self.model.k_seasonal_diff + self.model.k_seasonal_ma
    ) > 0
    if has_seasonal:
        if self.model.k_ar == self.model.k_ar_params:
            order_seasonal_ar = int(
                self.model.k_seasonal_ar / self.model.seasonal_periods
            )
        else:
            order_seasonal_ar = tuple(self.polynomial_seasonal_ar.nonzero()[0][1:])
        if self.model.k_ma == self.model.k_ma_params:
            order_seasonal_ma = int(
                self.model.k_seasonal_ma / self.model.seasonal_periods
            )
        else:
            order_seasonal_ma = tuple(self.polynomial_seasonal_ma.nonzero()[0][1:])
        # If there is simple differencing, then that is reflected in the
        # dependent variable name
        k_seasonal_diff = self.model.k_seasonal_diff
        if self.model.simple_differencing:
            k_seasonal_diff = 0
        seasonal_order = "(%s, %d, %s, %d)" % (
            str(order_seasonal_ar),
            k_seasonal_diff,
            str(order_seasonal_ma),
            self.model.seasonal_periods,
        )
        if not order == "":
            order += "x"
    model_name = "%s%s%s" % (self.model.__class__.__name__, order, seasonal_order)
    return super(SARIMAXResults, self).summary(
        alpha=alpha, start=start, model_name=model_name
    )


# Traceback (IndexError)
c:\git\statsmodels\statsmodels\tsa\statespace\sarimax.py:914: RuntimeWarning: overflow encountered in square
params_variance = (residuals[k_params_ma:]**2).mean()
c:\git\statsmodels\statsmodels\tsa\statespace\sarimax.py:976: UserWarning: Non-stationary starting autoregressive parameters found. Using zeros as starting parameters.
warn('Non-stationary starting autoregressive parameters'
c:\git\statsmodels\statsmodels\tsa\statespace\tools.py:487: RuntimeWarning: invalid value encountered in double_scalars
y[k-1, i] = (y[k, i] - y[k, k]*y[k, k-i-1]) / (1 - y[k, k]**2)
c:\git\statsmodels\statsmodels\tsa\statespace\tools.py:489: RuntimeWarning: invalid value encountered in sqrt
x = r / ((1 - r**2)**0.5)
Traceback (most recent call last):
File "C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-8-a7c5e4baeb4f>", line 10, in <module>
res = mod.fit()
File "c:\git\statsmodels\statsmodels\tsa\statespace\mlemodel.py", line 605, in fit
start_params = self.untransform_params(start_params)
File "c:\git\statsmodels\statsmodels\tsa\statespace\sarimax.py", line 1495, in untransform_params
unconstrained[start] = constrained[start]**0.5
IndexError: index 6 is out of bounds for axis 0 with size 4

# Fixed code
def summary(self, alpha=0.05, start=None):
    # Create the model name

    # See if we have an ARIMA component
    order = ""
    if self.model.k_ar + self.model.k_diff + self.model.k_ma > 0:
        if self.model.k_ar == self.model.k_ar_params:
            order_ar = self.model.k_ar
        else:
            order_ar = list(self.model._spec.ar_lags)
        if self.model.k_ma == self.model.k_ma_params:
            order_ma = self.model.k_ma
        else:
            order_ma = list(self.model._spec.ma_lags)
        # If there is simple differencing, then that is reflected in the
        # dependent variable name
        k_diff = 0 if self.model.simple_differencing else self.model.k_diff
        order = "(%s, %d, %s)" % (order_ar, k_diff, order_ma)
    # See if we have an SARIMA component
    seasonal_order = ""
    has_seasonal = (
        self.model.k_seasonal_ar + self.model.k_seasonal_diff + self.model.k_seasonal_ma
    ) > 0
    if has_seasonal:
        tmp = int(self.model.k_seasonal_ar / self.model.seasonal_periods)
        if tmp == self.model.k_seasonal_ar_params:
            order_seasonal_ar = int(
                self.model.k_seasonal_ar / self.model.seasonal_periods
            )
        else:
            order_seasonal_ar = list(self.model._spec.seasonal_ar_lags)
        tmp = int(self.model.k_seasonal_ma / self.model.seasonal_periods)
        if tmp == self.model.k_ma_params:
            order_seasonal_ma = tmp
        else:
            order_seasonal_ma = list(self.model._spec.seasonal_ma_lags)
        # If there is simple differencing, then that is reflected in the
        # dependent variable name
        k_seasonal_diff = self.model.k_seasonal_diff
        if self.model.simple_differencing:
            k_seasonal_diff = 0
        seasonal_order = "(%s, %d, %s, %d)" % (
            str(order_seasonal_ar),
            k_seasonal_diff,
            str(order_seasonal_ma),
            self.model.seasonal_periods,
        )
        if not order == "":
            order += "x"
    model_name = "%s%s%s" % (self.model.__class__.__name__, order, seasonal_order)
    return super(SARIMAXResults, self).summary(
        alpha=alpha, start=start, title="SARIMAX Results", model_name=model_name
    )