def initialize_state(self, variance=None, complex_step=False):
        """
        Initialize state and state covariance arrays in preparation for the
        Kalman filter.

        Parameters
        ----------
        variance : float, optional
            The variance for approximating diffuse initial conditions. Default
            can be found in the Representation class documentation.

        Notes
        -----
        Initializes the ARMA component of the state space to the typical
        stationary values and the other components as approximate diffuse.

        Can be overridden be calling one of the other initialization methods
        before fitting the model.
        """
        # Check if a manual initialization has already been specified
        if self._manual_initialization:
            return

        # If we're not enforcing stationarity, then we can't initialize a
        # stationary component
        if not self.enforce_stationarity:
            self.initialize_approximate_diffuse(variance)
            return

        # Otherwise, create the initial state and state covariance matrix
        # as from a combination of diffuse and stationary components

        # Create initialized non-stationary components
        if variance is None:
            variance = self.ssm.initial_variance

        dtype = self.ssm.transition.dtype
        initial_state = np.zeros(self.k_states, dtype=dtype)
        initial_state_cov = np.eye(self.k_states, dtype=dtype) * variance

        # Get the offsets (from the bottom or bottom right of the vector /
        # matrix) for the stationary component.
        if self.state_regression:
            start = -(self.k_exog + self._k_order)
            end = -self.k_exog if self.k_exog > 0 else None
        else:
            start = -self._k_order
            end = None

        # Add in the initialized stationary components
        if self._k_order > 0:
            selection_stationary = self.ssm.selection[start:end, :, 0]
            selected_state_cov_stationary = np.dot(
                np.dot(selection_stationary, self.ssm.state_cov[:, :, 0]),
                selection_stationary.T
            )
            initial_state_cov_stationary = solve_discrete_lyapunov(
                self.ssm.transition[start:end, start:end, 0],
                selected_state_cov_stationary,
                complex_step=complex_step
            )

            initial_state_cov[start:end, start:end] = (
                initial_state_cov_stationary
            )

        self.ssm.initialize_known(initial_state, initial_state_cov)
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/tsa/statespace/sarimax.py/SARIMAX.initialize_state/original