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 the news and impacts associated with a data release
  
  Parameters
  ----------
  previous : SmootherResults
      Prior results object relative to which to compute the news. This
      results object must have identical state space representation for
      the prior sample period so that the only difference is that this
      results object has updates to the observed data.
  t : int, optional
      A specific period for which to compute the news. Cannot be used in
      combination with `start` or `end`.
  start : int, optional
      The start of the interval (inclusive) of news to compute. Cannot be
      used in combination with the `t` argument. Default is the last
      period of the sample (`nobs - 1`).
  end : int, optional
      The end of the interval (exclusive) of news to compute. Note that
      since it is an exclusive endpoint, the returned news do not include
      the value at this index. Cannot be used in combination with the `t`
      argument.
  revisions_details_start : bool or int, optional
      The period at which to beging computing the detailed impacts of
      data revisions. Any revisions prior to this period will have their
      impacts grouped together. If a negative integer, interpreted as
      an offset from the end of the dataset. If set to True, detailed
      impacts are computed for all revisions, while if set to False, all
      revisions are grouped together. Default is False. Note that for
      large models, setting this to be near the beginning of the sample
      can cause this function to be slow.
  design : array, optional
      Design matrix for the period `t` in time-varying models. If this
      model has a time-varying design matrix, and the argument `t` is out
      of this model's sample, then a new design matrix for period `t`
      must be provided. Unused otherwise.
  state_index : array_like, optional
      An optional index specifying a subset of states to use when
      constructing the impacts of revisions and news. For example, if
      `state_index=[0, 1]` is passed, then only the impacts to the
      observed variables arising from the impacts to the first two
      states will be returned.
  
  Returns
  -------
  news_results : SimpleNamespace
      News and impacts associated with a data release. Includes the
      following attributes:
  
      - `update_impacts`: update to forecasts of impacted variables from
        the news. It is equivalent to E[y^i | post] - E[y^i | revision],
        where y^i are the variables of interest. In [1]_, this is
        described as "revision" in equation (17).
      - `revision_detailed_impacts`: update to forecasts of variables
        impacted variables from data revisions. It is
        E[y^i | revision] - E[y^i | previous], and does not have a
        specific notation in [1]_, since there for simplicity they assume
        that there are no revisions.
      - `news`: the unexpected component of the updated data. Denoted
        I = y^u - E[y^u | previous], where y^u are the data points that
        were newly incorporated in a data release (but not including
        revisions to data points that already existed in the previous
        release). In [1]_, this is described as "news" in equation (17).
      - `revisions`: y^r(updated) - y^r(previous) for periods in
        which detailed impacts were computed
      - `revisions_all` : y^r(updated) - y^r(previous) for all revisions
      - `gain`: the gain matrix associated with the "Kalman-like" update
        from the news, E[y I'] E[I I']^{-1}. In [1]_, this can be found
        in the equation For E[y_{k,t_k} \mid I_{v+1}] in the middle of
        page 17.
      - `revision_weights` weights on observations for the smoothed
        signal
      - `update_forecasts`: forecasts of the updated periods used to
        construct the news, E[y^u | previous].
      - `update_realized`: realizations of the updated periods used to
        construct the news, y^u.
      - `revised`: revised observations of the periods that were revised
        and for which detailed impacts were computed
      - `revised`: revised observations of the periods that were revised
      - `revised_prev`: previous observations of the periods that were
        revised and for which detailed impacts were computed
      - `revised_prev_all`: previous observations of the periods that
        were revised and for which detailed impacts were computed
      - `prev_impacted_forecasts`: previous forecast of the periods of
        interest, E[y^i | previous].
      - `post_impacted_forecasts`: forecast of the periods of interest
        after taking into account both revisions and updates,
        E[y^i | post].
      - `revision_results`: results object that updates the `previous`
        results to take into account data revisions.
      - `revision_results`: results object associated with the revisions
      - `revision_impacts`: total impacts from all revisions (both
        grouped and detailed)
      - `revisions_ix`: list of `(t, i)` positions of revisions in endog
      - `revisions_details`: list of `(t, i)` positions of revisions to
        endog for which details of impacts were computed
      - `revisions_grouped`: list of `(t, i)` positions of revisions to
        endog for which impacts were grouped
      - `revisions_details_start`: period in which revision details start
        to be computed
      - `updates_ix`: list of `(t, i)` positions of updates to endog
      - `state_index`: index of state variables used to compute impacts
  
  Notes
  -----
  This method computes the effect of new data (e.g. from a new data
  release) on smoothed forecasts produced by a state space model, as
  described in [1]_. It also computes the effect of revised data on
  smoothed forecasts.
  
  References
  ----------
  .. [1] Bańbura, Marta and Modugno, Michele. 2010.
         "Maximum likelihood estimation of factor models on data sets
         with arbitrary pattern of missing data."
         No 1189, Working Paper Series, European Central Bank.
         https://EconPapers.repec.org/RePEc:ecb:ecbwps:20101189.
  .. [2] Bańbura, Marta, and Michele Modugno.
         "Maximum likelihood estimation of factor models on datasets with
         arbitrary pattern of missing data."
         Journal of Applied Econometrics 29, no. 1 (2014): 133-160.
docstr_tok: ["Compute","the","news","and","impacts","associated","with","a","data","release","Parameters","--","--","--","--","--","previous",":","SmootherResults","Prior","results","object","relative","to","which","to","compute","the","news",".","This","results","object","must","have","identical","state","space","representation","for","the","prior","sample","period","so","that","the","only","difference","is","that","this","results","object","has","updates","to","the","observed","data",".","t",":","int",",","optional","A","specific","period","for","which","to","compute","the","news",".","Can","not","be","used","in","combination","with","`","start","`","or","`","end","`",".","start",":","int",",","optional","The","start","of","the","interval","(","inclusive",")","of","news","to","compute",".","Can","not","be","used","in","combination","with","the","`","t","`","argument",".","Default","is","the","last","period","of","the","sample","(","`","nobs","-","1","`",")",".","end",":","int",",","optional","The","end","of","the","interval","(","exclusive",")","of","news","to","compute",".","Note","that","since","it","is","an","exclusive","endpoint",",","the","returned","news","do","not","include","the","value","at","this","index",".","Can","not","be","used","in","combination","with","the","`","t","`","argument",".","revisions_details_start",":","bool","or","int",",","optional","The","period","at","which","to","beging","computing","the","detailed","impacts","of","data","revisions",".","Any","revisions","prior","to","this","period","will","have","their","impacts","grouped","together",".","If","a","negative","integer",",","interpreted","as","an","offset","from","the","end","of","the","dataset",".","If","set","to","True",",","detailed","impacts","are","computed","for","all","revisions",",","while","if","set","to","False",",","all","revisions","are","grouped","together",".","Default","is","False",".","Note","that","for","large","models",",","setting","this","to","be","near","the","beginning","of","the","sample","can","cause","this","function","to","be","slow",".","design",":","array",",","optional","Design","matrix","for","the","period","`","t","`","in","time-varying","models",".","If","this","model","has","a","time-varying","design","matrix",",","and","the","argument","`","t","`","is","out","of","this","model","'s","sample",",","then","a","new","design","matrix","for","period","`","t","`","must","be","provided",".","Unused","otherwise",".","state_index",":","array_like",",","optional","An","optional","index","specifying","a","subset","of","states","to","use","when","constructing","the","impacts","of","revisions","and","news",".","For","example",",","if","`","state_index=","[","0",",","1","]","`","is","passed",",","then","only","the","impacts","to","the","observed","variables","arising","from","the","impacts","to","the","first","two","states","will","be","returned",".","Returns","--","--","--","-","news_results",":","SimpleNamespace","News","and","impacts","associated","with","a","data","release",".","Includes","the","following","attributes",":","-","`","update_impacts","`",":","update","to","forecasts","of","impacted","variables","from","the","news",".","It","is","equivalent","to","E","[","y^i","|","post","]","-","E","[","y^i","|","revision","]",",","where","y^i","are","the","variables","of","interest",".","In","[","1","]","_",",","this","is","described","as","``","revision","''","in","equation","(","17",")",".","-","`","revision_detailed_impacts","`",":","update","to","forecasts","of","variables","impacted","variables","from","data","revisions",".","It","is","E","[","y^i","|","revision","]","-","E","[","y^i","|","previous","]",",","and","does","not","have","a","specific","notation","in","[","1","]","_",",","since","there","for","simplicity","they","assume","that","there","are","no","revisions",".","-","`","news","`",":","the","unexpected","component","of","the","updated","data",".","Denoted","I","=","y^u","-","E","[","y^u","|","previous","]",",","where","y^u","are","the","data","points","that","were","newly","incorporated","in","a","data","release","(","but","not","including","revisions","to","data","points","that","already","existed","in","the","previous","release",")",".","In","[","1","]","_",",","this","is","described","as","``","news","''","in","equation","(","17",")",".","-","`","revisions","`",":","y^r","(","updated",")","-","y^r","(","previous",")","for","periods","in","which","detailed","impacts","were","computed","-","`","revisions_all","`",":","y^r","(","updated",")","-","y^r","(","previous",")","for","all","revisions","-","`","gain","`",":","the","gain","matrix","associated","with","the","``","Kalman-like","''","update","from","the","news",",","E","[","y","I","'","]","E","[","I","I","'","]","^","{","-1","}",".","In","[","1","]","_",",","this","can","be","found","in","the","equation","For","E","[","y_","{","k",",","t_k","}","\\mid","I_","{","v+1","}","]","in","the","middle","of","page","17",".","-","`","revision_weights","`","weights","on","observations","for","the","smoothed","signal","-","`","update_forecasts","`",":","forecasts","of","the","updated","periods","used","to","construct","the","news",",","E","[","y^u","|","previous","]",".","-","`","update_realized","`",":","realizations","of","the","updated","periods","used","to","construct","the","news",",","y^u",".","-","`","revised","`",":","revised","observations","of","the","periods","that","were","revised","and","for","which","detailed","impacts","were","computed","-","`","revised","`",":","revised","observations","of","the","periods","that","were","revised","-","`","revised_prev","`",":","previous","observations","of","the","periods","that","were","revised","and","for","which","detailed","impacts","were","computed","-","`","revised_prev_all","`",":","previous","observations","of","the","periods","that","were","revised","and","for","which","detailed","impacts","were","computed","-","`","prev_impacted_forecasts","`",":","previous","forecast","of","the","periods","of","interest",",","E","[","y^i","|","previous","]",".","-","`","post_impacted_forecasts","`",":","forecast","of","the","periods","of","interest","after","taking","into","account","both","revisions","and","updates",",","E","[","y^i","|","post","]",".","-","`","revision_results","`",":","results","object","that","updates","the","`","previous","`","results","to","take","into","account","data","revisions",".","-","`","revision_results","`",":","results","object","associated","with","the","revisions","-","`","revision_impacts","`",":","total","impacts","from","all","revisions","(","both","grouped","and","detailed",")","-","`","revisions_ix","`",":","list","of","`","(","t",",","i",")","`","positions","of","revisions","in","endog","-","`","revisions_details","`",":","list","of","`","(","t",",","i",")","`","positions","of","revisions","to","endog","for","which","details","of","impacts","were","computed","-","`","revisions_grouped","`",":","list","of","`","(","t",",","i",")","`","positions","of","revisions","to","endog","for","which","impacts","were","grouped","-","`","revisions_details_start","`",":","period","in","which","revision","details","start","to","be","computed","-","`","updates_ix","`",":","list","of","`","(","t",",","i",")","`","positions","of","updates","to","endog","-","`","state_index","`",":","index","of","state","variables","used","to","compute","impacts","Notes","--","--","-","This","method","computes","the","effect","of","new","data","(","e.g",".","from","a","new","data","release",")","on","smoothed","forecasts","produced","by","a","state","space","model",",","as","described","in","[","1","]","_",".","It","also","computes","the","effect","of","revised","data","on","smoothed","forecasts",".","References","--","--","--","--","--","..","[","1","]","Ba\u0144bura",",","Marta","and","Modugno",",","Michele",".","2010",".","``","Maximum","likelihood","estimation","of","factor","models","on","data","sets","with","arbitrary","pattern","of","missing","data",".","''","No","1189",",","Working","Paper","Series",",","European","Central","Bank",".","https",":","\/\/EconPapers.repec.org\/RePEc",":","ecb",":","ecbwps:20101189",".","..","[","2","]","Ba\u0144bura",",","Marta",",","and","Michele","Modugno",".","``","Maximum","likelihood","estimation","of","factor","models","on","datasets","with","arbitrary","pattern","of","missing","data",".","''","Journal","of","Applied","Econometrics","29",",","no",".","1","(","2014",")",":","133-160","."]
code: def news(
      self,
      previous,
      t=None,
      start=None,
      end=None,
      revisions_details_start=True,
      design=None,
      state_index=None,
  ):
      r"""
      Compute the news and impacts associated with a data release
  
      Parameters
      ----------
      previous : SmootherResults
          Prior results object relative to which to compute the news. This
          results object must have identical state space representation for
          the prior sample period so that the only difference is that this
          results object has updates to the observed data.
      t : int, optional
          A specific period for which to compute the news. Cannot be used in
          combination with `start` or `end`.
      start : int, optional
          The start of the interval (inclusive) of news to compute. Cannot be
          used in combination with the `t` argument. Default is the last
          period of the sample (`nobs - 1`).
      end : int, optional
          The end of the interval (exclusive) of news to compute. Note that
          since it is an exclusive endpoint, the returned news do not include
          the value at this index. Cannot be used in combination with the `t`
          argument.
      revisions_details_start : bool or int, optional
          The period at which to beging computing the detailed impacts of
          data revisions. Any revisions prior to this period will have their
          impacts grouped together. If a negative integer, interpreted as
          an offset from the end of the dataset. If set to True, detailed
          impacts are computed for all revisions, while if set to False, all
          revisions are grouped together. Default is False. Note that for
          large models, setting this to be near the beginning of the sample
          can cause this function to be slow.
      design : array, optional
          Design matrix for the period `t` in time-varying models. If this
          model has a time-varying design matrix, and the argument `t` is out
          of this model's sample, then a new design matrix for period `t`
          must be provided. Unused otherwise.
      state_index : array_like, optional
          An optional index specifying a subset of states to use when
          constructing the impacts of revisions and news. For example, if
          `state_index=[0, 1]` is passed, then only the impacts to the
          observed variables arising from the impacts to the first two
          states will be returned.
  
      Returns
      -------
      news_results : SimpleNamespace
          News and impacts associated with a data release. Includes the
          following attributes:
  
          - `update_impacts`: update to forecasts of impacted variables from
            the news. It is equivalent to E[y^i | post] - E[y^i | revision],
            where y^i are the variables of interest. In [1]_, this is
            described as "revision" in equation (17).
          - `revision_detailed_impacts`: update to forecasts of variables
            impacted variables from data revisions. It is
            E[y^i | revision] - E[y^i | previous], and does not have a
            specific notation in [1]_, since there for simplicity they assume
            that there are no revisions.
          - `news`: the unexpected component of the updated data. Denoted
            I = y^u - E[y^u | previous], where y^u are the data points that
            were newly incorporated in a data release (but not including
            revisions to data points that already existed in the previous
            release). In [1]_, this is described as "news" in equation (17).
          - `revisions`: y^r(updated) - y^r(previous) for periods in
            which detailed impacts were computed
          - `revisions_all` : y^r(updated) - y^r(previous) for all revisions
          - `gain`: the gain matrix associated with the "Kalman-like" update
            from the news, E[y I'] E[I I']^{-1}. In [1]_, this can be found
            in the equation For E[y_{k,t_k} \mid I_{v+1}] in the middle of
            page 17.
          - `revision_weights` weights on observations for the smoothed
            signal
          - `update_forecasts`: forecasts of the updated periods used to
            construct the news, E[y^u | previous].
          - `update_realized`: realizations of the updated periods used to
            construct the news, y^u.
          - `revised`: revised observations of the periods that were revised
            and for which detailed impacts were computed
          - `revised`: revised observations of the periods that were revised
          - `revised_prev`: previous observations of the periods that were
            revised and for which detailed impacts were computed
          - `revised_prev_all`: previous observations of the periods that
            were revised and for which detailed impacts were computed
          - `prev_impacted_forecasts`: previous forecast of the periods of
            interest, E[y^i | previous].
          - `post_impacted_forecasts`: forecast of the periods of interest
            after taking into account both revisions and updates,
            E[y^i | post].
          - `revision_results`: results object that updates the `previous`
            results to take into account data revisions.
          - `revision_results`: results object associated with the revisions
          - `revision_impacts`: total impacts from all revisions (both
            grouped and detailed)
          - `revisions_ix`: list of `(t, i)` positions of revisions in endog
          - `revisions_details`: list of `(t, i)` positions of revisions to
            endog for which details of impacts were computed
          - `revisions_grouped`: list of `(t, i)` positions of revisions to
            endog for which impacts were grouped
          - `revisions_details_start`: period in which revision details start
            to be computed
          - `updates_ix`: list of `(t, i)` positions of updates to endog
          - `state_index`: index of state variables used to compute impacts
  
      Notes
      -----
      This method computes the effect of new data (e.g. from a new data
      release) on smoothed forecasts produced by a state space model, as
      described in [1]_. It also computes the effect of revised data on
      smoothed forecasts.
  
      References
      ----------
      .. [1] Bańbura, Marta and Modugno, Michele. 2010.
             "Maximum likelihood estimation of factor models on data sets
             with arbitrary pattern of missing data."
             No 1189, Working Paper Series, European Central Bank.
             https://EconPapers.repec.org/RePEc:ecb:ecbwps:20101189.
      .. [2] Bańbura, Marta, and Michele Modugno.
             "Maximum likelihood estimation of factor models on datasets with
             arbitrary pattern of missing data."
             Journal of Applied Econometrics 29, no. 1 (2014): 133-160.
  
      """
      # Handle `t`
      if t is not None and (start is not None or end is not None):
          raise ValueError(
              "Cannot specify both `t` and `start` or `end`."
          )
      if t is not None:
          start = t
          end = t + 1
  
      # Defaults
      if start is None:
          start = self.nobs - 1
      if end is None:
          end = self.nobs
  
      # Sanity checks
      if start < 0 or end < 0:
          raise ValueError(
              "Negative `t`, `start`, or `end` is not allowed."
          )
      if end <= start:
          raise ValueError("`end` must be after `start`")
  
      if self.smoothed_state_cov is None:
          raise ValueError(
              "Cannot compute news without having applied the"
              " Kalman smoother first."
          )
  
      error_ss = (
          "This results object has %s and so it does not appear to"
          " by an extension of `previous`. Can only compute the"
          " news by comparing this results set to previous results"
          " objects."
      )
      if self.nobs < previous.nobs:
          raise ValueError(
              error_ss % "fewer observations than" " `previous`"
          )
  
      if not (
          self.k_endog == previous.k_endog
          and self.k_states == previous.k_states
          and self.k_posdef == previous.k_posdef
      ):
          raise ValueError(
              error_ss % "different state space dimensions than"
              " `previous`"
          )
  
      for key in self.model.shapes.keys():
          if key == "obs":
              continue
          tv = getattr(self, key).shape[-1] > 1
          tv_prev = getattr(previous, key).shape[-1] > 1
          if tv and not tv_prev:
              raise ValueError(
                  error_ss % f"time-varying {key} while"
                  " `previous` does not"
              )
          if not tv and tv_prev:
              raise ValueError(
                  error_ss % f"time-invariant {key} while"
                  " `previous` does not"
              )
  
      # Standardize
      if state_index is not None:
          state_index = np.atleast_1d(
              np.sort(np.array(state_index, dtype=int))
          )
  
      # We cannot forecast out-of-sample periods in a time-varying model
      if end > self.nobs and not self.model.time_invariant:
          raise RuntimeError(
              "Cannot compute the impacts of news on periods"
              " outside of the sample in time-varying"
              " models."
          )
  
      # For time-varying case, figure out extension kwargs
      extend_kwargs = {}
      for key in self.model.shapes.keys():
          if key == "obs":
              continue
          mat = getattr(self, key)
          prev_mat = getattr(previous, key)
          if mat.shape[-1] > prev_mat.shape[-1]:
              extend_kwargs[key] = mat[..., prev_mat.shape[-1] :]
  
      # Figure out which indices have changed
      revisions_ix, updates_ix = previous.model.diff_endog(self.endog.T)
  
      # Compute prev / post impact forecasts
      prev_impacted_forecasts = previous.predict(
          start=start, end=end, **extend_kwargs
      ).smoothed_forecasts
      post_impacted_forecasts = self.predict(
          start=start, end=end
      ).smoothed_forecasts
  
      # Separate revisions into those with detailed impacts and those where
      # impacts are grouped together
      if revisions_details_start is True:
          revisions_details_start = 0
      elif revisions_details_start is False:
          revisions_details_start = previous.nobs
      elif revisions_details_start < 0:
          revisions_details_start = (
              previous.nobs + revisions_details_start
          )
  
      revisions_grouped = []
      revisions_details = []
      if revisions_details_start > 0:
          for s, i in revisions_ix:
              if s < revisions_details_start:
                  revisions_grouped.append((s, i))
              else:
                  revisions_details.append((s, i))
      else:
          revisions_details = revisions_ix
  
      # Practically, don't compute impacts of revisions prior to first
      # point that was actually revised
      if len(revisions_ix) > 0:
          revisions_details_start = max(
              revisions_ix[0][0], revisions_details_start
          )
  
      # Setup default (empty) output for revisions
      revised_endog = None
      revised_all = None
      revised_prev_all = None
      revisions_all = None
  
      revised = None
      revised_prev = None
      revisions = None
      revision_weights = None
      revision_detailed_impacts = None
      revision_results = None
      revision_impacts = None
  
      # Get revisions datapoints for all revisions (regardless of whether
      # or not we are computing detailed impacts)
      if len(revisions_ix) > 0:
          # Indexes
          revised_j, revised_p = zip(*revisions_ix)
          compute_j = np.arange(revised_j[0], revised_j[-1] + 1)
  
          # Data from updated model
          revised_endog = self.endog[:, : previous.nobs].copy()
          # ("revisions" are points where data was previously published and
          # then changed, so we need to ignore "updates", which are points
          # that were not previously published)
          revised_endog[previous.missing.astype(bool)] = np.nan
          # subset to revision periods
          revised_all = revised_endog.T[compute_j]
  
          # Data from original model
          revised_prev_all = previous.endog.T[compute_j]
  
          # revision = updated - original
          revisions_all = revised_all - revised_prev_all
  
          # Construct a model from which we can create weights for impacts
          # through `end`
          # Construct endog for the new model
          tmp_endog = revised_endog.T.copy()
          tmp_nobs = max(end, previous.nobs)
          oos_nobs = tmp_nobs - previous.nobs
          if oos_nobs > 0:
              tmp_endog = np.concatenate(
                  [
                      tmp_endog,
                      np.zeros((oos_nobs, self.k_endog)) * np.nan,
                  ],
                  axis=0,
              )
  
          # Copy time-varying matrices (required by clone)
          clone_kwargs = {}
          for key in self.model.shapes.keys():
              if key == "obs":
                  continue
              mat = getattr(self, key)
              if mat.shape[-1] > 1:
                  clone_kwargs[key] = mat[..., :tmp_nobs]
  
          rev_mod = previous.model.clone(tmp_endog, **clone_kwargs)
          init = initialization.Initialization.from_results(self)
          rev_mod.initialize(init)
          revision_results = rev_mod.smooth()
  
          # Get detailed revision weights, impacts, and forecasts
          if len(revisions_details) > 0:
              # Indexes for the subset of revisions for which we are
              # computing detailed impacts
              compute_j = np.arange(
                  revisions_details_start, revised_j[-1] + 1
              )
              # Offset describing revisions for which we are not computing
              # detailed impacts
              offset = revisions_details_start - revised_j[0]
              revised = revised_all[offset:]
              revised_prev = revised_prev_all[offset:]
              revisions = revisions_all[offset:]
  
              # Compute the weights of the smoothed state vector
              compute_t = np.arange(start, end)
  
              (
                  smoothed_state_weights,
                  _,
                  _,
              ) = tools._compute_smoothed_state_weights(
                  rev_mod,
                  compute_t=compute_t,
                  compute_j=compute_j,
                  compute_prior_weights=False,
                  scale=previous.scale,
              )
  
              # Convert the weights in terms of smoothed forecasts
              # t, j, m, p, i
              ZT = rev_mod.design.T
              if ZT.shape[0] > 1:
                  ZT = ZT[compute_t]
  
              # Subset the states used for the impacts if applicable
              if state_index is not None:
                  ZT = ZT[:, state_index, :]
                  smoothed_state_weights = smoothed_state_weights[
                      :, :, state_index
                  ]
  
              # Multiplication gives: t, j, m, p * t, j, m, p, k
              # Sum along axis=2 gives: t, j, p, k
              # Transpose to: t, j, k, p (i.e. like t, j, m, p but with k
              # instead of m)
              revision_weights = np.nansum(
                  smoothed_state_weights[..., None]
                  * ZT[:, None, :, None, :],
                  axis=2,
              ).transpose(0, 1, 3, 2)
  
              # Multiplication gives: t, j, k, p * t, j, k, p
              # Sum along axes 1, 3 gives: t, k
              # This is also a valid way to compute impacts, but it employs
              # unnecessary multiplications with zeros; it is better to use
              # the below method that flattens the revision indices before
              # computing the impacts
              # revision_detailed_impacts = np.nansum(
              #     revision_weights * revisions[None, :, None, :],
              #     axis=(1, 3))
  
              # Flatten the weights and revisions along the revised j, k
              # dimensions so that we only retain the actual revision
              # elements
              revised_j, revised_p = zip(
                  *[
                      s
                      for s in revisions_ix
                      if s[0] >= revisions_details_start
                  ]
              )
              ix_j = revised_j - revised_j[0]
              # Shape is: t, k, j * p
              # Note: have to transpose first so that the two advanced
              # indexes are next to each other, so that "the dimensions from
              # the advanced indexing operations are inserted into the result
              # array at the same spot as they were in the initial array"
              # (see https://numpy.org/doc/stable/user/basics.indexing.html,
              # "Combining advanced and basic indexing")
              revision_weights = revision_weights.transpose(0, 2, 1, 3)[
                  :, :, ix_j, revised_p
              ]
              # Shape is j * k
              revisions = revisions[ix_j, revised_p]
              # Shape is t, k
              revision_detailed_impacts = revision_weights @ revisions
  
              # Similarly, flatten the revised and revised_prev series
              revised = revised[ix_j, revised_p]
              revised_prev = revised_prev[ix_j, revised_p]
  
              # Squeeze if `t` argument used
              if t is not None:
                  revision_weights = revision_weights[0]
                  revision_detailed_impacts = revision_detailed_impacts[
                      0
                  ]
  
          # Get total revision impacts
          revised_impact_forecasts = (
              revision_results.smoothed_forecasts[..., start:end]
          )
          if end > revision_results.nobs:
              predict_start = max(start, revision_results.nobs)
              p = revision_results.predict(
                  start=predict_start, end=end, **extend_kwargs
              )
              revised_impact_forecasts = np.concatenate(
                  (revised_impact_forecasts, p.forecasts), axis=1
              )
  
          revision_impacts = (
              revised_impact_forecasts - prev_impacted_forecasts
          ).T
          if t is not None:
              revision_impacts = revision_impacts[0]
  
      # Need to also flatten the revisions items that contain all revisions
      if len(revisions_ix) > 0:
          revised_j, revised_p = zip(*revisions_ix)
          ix_j = revised_j - revised_j[0]
  
          revisions_all = revisions_all[ix_j, revised_p]
          revised_all = revised_all[ix_j, revised_p]
          revised_prev_all = revised_prev_all[ix_j, revised_p]
  
      # Now handle updates
      if len(updates_ix) > 0:
          # Figure out which time points we need forecast errors for
          update_t, update_k = zip(*updates_ix)
          update_start_t = np.min(update_t)
          update_end_t = np.max(update_t)
  
          if revision_results is None:
              forecasts = previous.predict(
                  start=update_start_t,
                  end=update_end_t + 1,
                  **extend_kwargs,
              ).smoothed_forecasts.T
          else:
              forecasts = revision_results.predict(
                  start=update_start_t, end=update_end_t + 1
              ).smoothed_forecasts.T
          realized = self.endog.T[update_start_t : update_end_t + 1]
          forecasts_error = realized - forecasts
  
          # Now subset forecast errors to only the (time, endog) elements
          # that are updates
          ix_t = update_t - update_start_t
          update_realized = realized[ix_t, update_k]
          update_forecasts = forecasts[ix_t, update_k]
          update_forecasts_error = forecasts_error[ix_t, update_k]
  
          # Get the gains associated with each of the periods
          if self.design.shape[2] == 1:
              design = self.design[..., 0][None, ...]
          elif end <= self.nobs:
              design = self.design[..., start:end].transpose(2, 0, 1)
          else:
              # Note: this case is no longer possible, since above we raise
              # ValueError for time-varying case with end > self.nobs
              if design is None:
                  raise ValueError(
                      "Model has time-varying design matrix, so"
                      " an updated time-varying matrix for"
                      " period `t` is required."
                  )
              elif design.ndim == 2:
                  design = design[None, ...]
              else:
                  design = design.transpose(2, 0, 1)
  
          state_gain = previous.smoothed_state_gain(
              updates_ix,
              start=start,
              end=end,
              extend_kwargs=extend_kwargs,
          )
  
          # Subset the states used for the impacts if applicable
          if state_index is not None:
              design = design[:, :, state_index]
              state_gain = state_gain[:, state_index]
  
          # Compute the gain in terms of observed variables
          obs_gain = design @ state_gain
  
          # Get the news
          update_impacts = obs_gain @ update_forecasts_error
  
          # Squeeze if `t` argument used
          if t is not None:
              obs_gain = obs_gain[0]
              update_impacts = update_impacts[0]
      else:
          update_impacts = None
          update_forecasts = None
          update_realized = None
          update_forecasts_error = None
          obs_gain = None
  
      # Results
      out = SimpleNamespace(
          # update to forecast of impacted variables from news
          # = E[y^i | post] - E[y^i | revision] = weight @ news
          update_impacts=update_impacts,
          # update to forecast of variables of interest from revisions
          # = E[y^i | revision] - E[y^i | previous]
          revision_detailed_impacts=revision_detailed_impacts,
          # news = A = y^u - E[y^u | previous]
          news=update_forecasts_error,
          # revivions y^r(updated) - y^r(previous) for periods in which
          # detailed impacts were computed
          revisions=revisions,
          # revivions y^r(updated) - y^r(previous)
          revisions_all=revisions_all,
          # gain matrix = E[y A'] E[A A']^{-1}
          gain=obs_gain,
          # weights on observations for the smoothed signal
          revision_weights=revision_weights,
          # forecasts of the updated periods used to construct the news
          # = E[y^u | revised]
          update_forecasts=update_forecasts,
          # realizations of the updated periods used to construct the news
          # = y^u
          update_realized=update_realized,
          # revised observations of the periods that were revised and for
          # which detailed impacts were computed
          # = y^r_{revised}
          revised=revised,
          # revised observations of the periods that were revised
          # = y^r_{revised}
          revised_all=revised_all,
          # previous observations of the periods that were revised and for
          # which detailed impacts were computed
          # = y^r_{previous}
          revised_prev=revised_prev,
          # previous observations of the periods that were revised
          # = y^r_{previous}
          revised_prev_all=revised_prev_all,
          # previous forecast of the periods of interest, E[y^i | previous]
          prev_impacted_forecasts=prev_impacted_forecasts,
          # post. forecast of the periods of interest, E[y^i | post]
          post_impacted_forecasts=post_impacted_forecasts,
          # results object associated with the revision
          revision_results=revision_results,
          # total impacts from all revisions (both grouped and detailed)
          revision_impacts=revision_impacts,
          # list of (x, y) positions of revisions to endog
          revisions_ix=revisions_ix,
          # list of (x, y) positions of revisions to endog for which details
          # of impacts were computed
          revisions_details=revisions_details,
          # list of (x, y) positions of revisions to endog for which impacts
          # were grouped
          revisions_grouped=revisions_grouped,
          # period in which revision details start to be computed
          revisions_details_start=revisions_details_start,
          # list of (x, y) positions of updates to endog
          updates_ix=updates_ix,
          # index of state variables used to compute impacts
          state_index=state_index,
      )
  
      return out
  
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 5 for calling the SmootherResults obj's underlying member method code with example usage: obj.news(previous, t, start, end, revisions_details_start, design, state_index) and returns: out