class_docstr: Results from applying the Kalman smoother and/or filter to a state space
  model.
  
  Parameters
  ----------
  model : Representation
      A Statespace representation
  
  Attributes
  ----------
  nobs : int
      Number of observations.
  k_endog : int
      The dimension of the observation series.
  k_states : int
      The dimension of the unobserved state process.
  k_posdef : int
      The dimension of a guaranteed positive definite covariance matrix
      describing the shocks in the measurement equation.
  dtype : dtype
      Datatype of representation matrices
  prefix : str
      BLAS prefix of representation matrices
  shapes : dictionary of name:tuple
      A dictionary recording the shapes of each of the representation
      matrices as tuples.
  endog : ndarray
      The observation vector.
  design : ndarray
      The design matrix, :math:`Z`.
  obs_intercept : ndarray
      The intercept for the observation equation, :math:`d`.
  obs_cov : ndarray
      The covariance matrix for the observation equation :math:`H`.
  transition : ndarray
      The transition matrix, :math:`T`.
  state_intercept : ndarray
      The intercept for the transition equation, :math:`c`.
  selection : ndarray
      The selection matrix, :math:`R`.
  state_cov : ndarray
      The covariance matrix for the state equation :math:`Q`.
  missing : array of bool
      An array of the same size as `endog`, filled with boolean values that
      are True if the corresponding entry in `endog` is NaN and False
      otherwise.
  nmissing : array of int
      An array of size `nobs`, where the ith entry is the number (between 0
      and k_endog) of NaNs in the ith row of the `endog` array.
  time_invariant : bool
      Whether or not the representation matrices are time-invariant
  initialization : str
      Kalman filter initialization method.
  initial_state : array_like
      The state vector used to initialize the Kalamn filter.
  initial_state_cov : array_like
      The state covariance matrix used to initialize the Kalamn filter.
  filter_method : int
      Bitmask representing the Kalman filtering method
  inversion_method : int
      Bitmask representing the method used to invert the forecast error
      covariance matrix.
  stability_method : int
      Bitmask representing the methods used to promote numerical stability in
      the Kalman filter recursions.
  conserve_memory : int
      Bitmask representing the selected memory conservation method.
  tolerance : float
      The tolerance at which the Kalman filter determines convergence to
      steady-state.
  loglikelihood_burn : int
      The number of initial periods during which the loglikelihood is not
      recorded.
  converged : bool
      Whether or not the Kalman filter converged.
  period_converged : int
      The time period in which the Kalman filter converged.
  filtered_state : ndarray
      The filtered state vector at each time period.
  filtered_state_cov : ndarray
      The filtered state covariance matrix at each time period.
  predicted_state : ndarray
      The predicted state vector at each time period.
  predicted_state_cov : ndarray
      The predicted state covariance matrix at each time period.
  kalman_gain : ndarray
      The Kalman gain at each time period.
  forecasts : ndarray
      The one-step-ahead forecasts of observations at each time period.
  forecasts_error : ndarray
      The forecast errors at each time period.
  forecasts_error_cov : ndarray
      The forecast error covariance matrices at each time period.
  loglikelihood : ndarray
      The loglikelihood values at each time period.
  collapsed_forecasts : ndarray
      If filtering using collapsed observations, stores the one-step-ahead
      forecasts of collapsed observations at each time period.
  collapsed_forecasts_error : ndarray
      If filtering using collapsed observations, stores the one-step-ahead
      forecast errors of collapsed observations at each time period.
  collapsed_forecasts_error_cov : ndarray
      If filtering using collapsed observations, stores the one-step-ahead
      forecast error covariance matrices of collapsed observations at each
      time period.
  standardized_forecast_error : ndarray
      The standardized forecast errors
  smoother_output : int
      Bitmask representing the generated Kalman smoothing output
  scaled_smoothed_estimator : ndarray
      The scaled smoothed estimator at each time period.
  scaled_smoothed_estimator_cov : ndarray
      The scaled smoothed estimator covariance matrices at each time period.
  smoothing_error : ndarray
      The smoothing error covariance matrices at each time period.
  smoothed_state : ndarray
      The smoothed state at each time period.
  smoothed_state_cov : ndarray
      The smoothed state covariance matrices at each time period.
  smoothed_state_autocov : ndarray
      The smoothed state lago-one autocovariance matrices at each time
      period: :math:`Cov(\alpha_{t+1}, \alpha_t)`.
  smoothed_measurement_disturbance : ndarray
      The smoothed measurement at each time period.
  smoothed_state_disturbance : ndarray
      The smoothed state at each time period.
  smoothed_measurement_disturbance_cov : ndarray
      The smoothed measurement disturbance covariance matrices at each time
      period.
  smoothed_state_disturbance_cov : ndarray
      The smoothed state disturbance covariance matrices at each time period.
docstr: Compute "forward" autocovariances, Cov(t, t+j)
  
  Parameters
  ----------
  shift : int
      The number of period to shift forwards when computing the
      autocovariance. This has the opposite sign as `lag` from the
      `smoothed_state_autocovariance` method.
  start : int, optional
      The start of the interval (inclusive) of autocovariances to compute
      and return.
  end : int, optional
      The end of the interval (exclusive) autocovariances to compute and
      return. Note that since it is an exclusive endpoint, the returned
      autocovariances do not include the value at this index.
  extend_kwargs : dict, optional
      Keyword arguments containing updated state space system matrices
      for handling out-of-sample autocovariance computations in
      time-varying state space models.
docstr_tok: ["Compute","``","forward","''","autocovariances",",","Cov","(","t",",","t+j",")","Parameters","--","--","--","--","--","shift",":","int","The","number","of","period","to","shift","forwards","when","computing","the","autocovariance",".","This","has","the","opposite","sign","as","`","lag","`","from","the","`","smoothed_state_autocovariance","`","method",".","start",":","int",",","optional","The","start","of","the","interval","(","inclusive",")","of","autocovariances","to","compute","and","return",".","end",":","int",",","optional","The","end","of","the","interval","(","exclusive",")","autocovariances","to","compute","and","return",".","Note","that","since","it","is","an","exclusive","endpoint",",","the","returned","autocovariances","do","not","include","the","value","at","this","index",".","extend_kwargs",":","dict",",","optional","Keyword","arguments","containing","updated","state","space","system","matrices","for","handling","out-of-sample","autocovariance","computations","in","time-varying","state","space","models","."]
code: def _smoothed_state_autocovariance(
      self, shift, start, end, extend_kwargs=None
  ):
      """
      Compute "forward" autocovariances, Cov(t, t+j)
  
      Parameters
      ----------
      shift : int
          The number of period to shift forwards when computing the
          autocovariance. This has the opposite sign as `lag` from the
          `smoothed_state_autocovariance` method.
      start : int, optional
          The start of the interval (inclusive) of autocovariances to compute
          and return.
      end : int, optional
          The end of the interval (exclusive) autocovariances to compute and
          return. Note that since it is an exclusive endpoint, the returned
          autocovariances do not include the value at this index.
      extend_kwargs : dict, optional
          Keyword arguments containing updated state space system matrices
          for handling out-of-sample autocovariance computations in
          time-varying state space models.
  
      """
      if extend_kwargs is None:
          extend_kwargs = {}
  
      # Size of returned array in the time dimension
      n = end - start
  
      # Get number of post-sample periods we need to create an extended
      # model to compute
      if shift == 0:
          max_insample = self.nobs - shift
      else:
          max_insample = self.nobs - shift + 1
      n_postsample = max(0, end - max_insample)
  
      # Get full in-sample arrays
      if shift != 0:
          L = self.innovations_transition
          P = self.predicted_state_cov
          N = self.scaled_smoothed_estimator_cov
      else:
          acov = self.smoothed_state_cov
  
      # If applicable, append out-of-sample arrays
      if n_postsample > 0:
          # Note: we need 1 less than the number of post
          endog = np.zeros((n_postsample, self.k_endog)) * np.nan
          mod = self.model.extend(
              endog, start=self.nobs, **extend_kwargs
          )
          mod.initialize_known(
              self.predicted_state[..., self.nobs],
              self.predicted_state_cov[..., self.nobs],
          )
          res = mod.smooth()
  
          if shift != 0:
              start_insample = max(0, start)
              L = np.concatenate(
                  (L[..., start_insample:], res.innovations_transition),
                  axis=2,
              )
              P = np.concatenate(
                  (
                      P[..., start_insample:],
                      res.predicted_state_cov[..., 1:],
                  ),
                  axis=2,
              )
              N = np.concatenate(
                  (
                      N[..., start_insample:],
                      res.scaled_smoothed_estimator_cov,
                  ),
                  axis=2,
              )
              end -= start_insample
              start -= start_insample
          else:
              acov = np.concatenate(
                  (acov, res.predicted_state_cov), axis=2
              )
  
      if shift != 0:
          # Subset to appropriate start, end
          start_insample = max(0, start)
          LT = L[..., start_insample : end + shift - 1].T
          P = P[..., start_insample : end + shift].T
          N = N[..., start_insample : end + shift - 1].T
  
          # Intermediate computations
          tmpLT = np.eye(self.k_states)[None, :, :]
          length = (
              P.shape[0] - shift
          )  # this is the required length of LT
          for i in range(1, shift + 1):
              tmpLT = LT[shift - i : length + shift - i] @ tmpLT
          eye = np.eye(self.k_states)[None, ...]
  
          # Compute the autocovariance
          acov = np.zeros((n, self.k_states, self.k_states))
          acov[: start_insample - start] = np.nan
          acov[start_insample - start :] = (
              P[:-shift] @ tmpLT @ (eye - N[shift - 1 :] @ P[shift:])
          )
      else:
          acov = acov.T[start:end]
  
      return acov
  
imports: import numpy
  from types import SimpleNamespace
  from statsmodels.tsa.statespace.representation import OptionWrapper
  from statsmodels.tsa.statespace.kalman_filter import KalmanFilter, FilterResults
  from statsmodels.tsa.statespace.tools import reorder_missing_matrix, reorder_missing_vector, copy_index_matrix
  from statsmodels.tsa.statespace import tools, initialization
label_desc: Use image node_id 3 for calling the SmootherResults obj's underlying member method code with example usage: obj._smoothed_state_autocovariance(shift, start, end, extend_kwargs) and returns: acov