class_docstr: State space representation of a time series process, with Kalman filter
  
  Parameters
  ----------
  k_endog : {array_like, int}
      The observed time-series process :math:`y` if array like or the
      number of variables in the process if an integer.
  k_states : int
      The dimension of the unobserved state process.
  k_posdef : int, optional
      The dimension of a guaranteed positive definite covariance matrix
      describing the shocks in the transition equation. Must be less than
      or equal to `k_states`. Default is `k_states`.
  loglikelihood_burn : int, optional
      The number of initial periods during which the loglikelihood is not
      recorded. Default is 0.
  tolerance : float, optional
      The tolerance at which the Kalman filter determines convergence to
      steady-state. Default is 1e-19.
  results_class : class, optional
      Default results class to use to save filtering output. Default is
      `FilterResults`. If specified, class must extend from `FilterResults`.
  **kwargs
      Keyword arguments may be used to provide values for the filter,
      inversion, and stability methods. See `set_filter_method`,
      `set_inversion_method`, and `set_stability_method`.
      Keyword arguments may be used to provide default values for state space
      matrices. See `Representation` for more details.
  
  See Also
  --------
  FilterResults
  statsmodels.tsa.statespace.representation.Representation
  
  Notes
  -----
  There are several types of options available for controlling the Kalman
  filter operation. All options are internally held as bitmasks, but can be
  manipulated by setting class attributes, which act like boolean flags. For
  more information, see the `set_*` class method documentation. The options
  are:
  
  filter_method
      The filtering method controls aspects of which
      Kalman filtering approach will be used.
  inversion_method
      The Kalman filter may contain one matrix inversion: that of the
      forecast error covariance matrix. The inversion method controls how and
      if that inverse is performed.
  stability_method
      The Kalman filter is a recursive algorithm that may in some cases
      suffer issues with numerical stability. The stability method controls
      what, if any, measures are taken to promote stability.
  conserve_memory
      By default, the Kalman filter computes a number of intermediate
      matrices at each iteration. The memory conservation options control
      which of those matrices are stored.
  filter_timing
      By default, the Kalman filter follows Durbin and Koopman, 2012, in
      initializing the filter with predicted values. Kim and Nelson, 1999,
      instead initialize the filter with filtered values, which is
      essentially just a different timing convention.
  
  The `filter_method` and `inversion_method` options intentionally allow
  the possibility that multiple methods will be indicated. In the case that
  multiple methods are selected, the underlying Kalman filter will attempt to
  select the optional method given the input data.
  
  For example, it may be that INVERT_UNIVARIATE and SOLVE_CHOLESKY are
  indicated (this is in fact the default case). In this case, if the
  endogenous vector is 1-dimensional (`k_endog` = 1), then INVERT_UNIVARIATE
  is used and inversion reduces to simple division, and if it has a larger
  dimension, the Cholesky decomposition along with linear solving (rather
  than explicit matrix inversion) is used. If only SOLVE_CHOLESKY had been
  set, then the Cholesky decomposition method would *always* be used, even in
  the case of 1-dimensional data.
class_docstr_tok: ["State","space","representation","of","a","time","series","process",",","with","Kalman","filter","Parameters","--","--","--","--","--","k_endog",":","{","array_like",",","int","}","The","observed","time-series","process",":","math",":","`","y","`","if","array","like","or","the","number","of","variables","in","the","process","if","an","integer",".","k_states",":","int","The","dimension","of","the","unobserved","state","process",".","k_posdef",":","int",",","optional","The","dimension","of","a","guaranteed","positive","definite","covariance","matrix","describing","the","shocks","in","the","transition","equation",".","Must","be","less","than","or","equal","to","`","k_states","`",".","Default","is","`","k_states","`",".","loglikelihood_burn",":","int",",","optional","The","number","of","initial","periods","during","which","the","loglikelihood","is","not","recorded",".","Default","is","0.","tolerance",":","float",",","optional","The","tolerance","at","which","the","Kalman","filter","determines","convergence","to","steady-state",".","Default","is","1e-19",".","results_class",":","class",",","optional","Default","results","class","to","use","to","save","filtering","output",".","Default","is","`","FilterResults","`",".","If","specified",",","class","must","extend","from","`","FilterResults","`",".","*","*","kwargs","Keyword","arguments","may","be","used","to","provide","values","for","the","filter",",","inversion",",","and","stability","methods",".","See","`","set_filter_method","`",",","`","set_inversion_method","`",",","and","`","set_stability_method","`",".","Keyword","arguments","may","be","used","to","provide","default","values","for","state","space","matrices",".","See","`","Representation","`","for","more","details",".","See","Also","--","--","--","--","FilterResults","statsmodels.tsa.statespace.representation.Representation","Notes","--","--","-","There","are","several","types","of","options","available","for","controlling","the","Kalman","filter","operation",".","All","options","are","internally","held","as","bitmasks",",","but","can","be","manipulated","by","setting","class","attributes",",","which","act","like","boolean","flags",".","For","more","information",",","see","the","`","set_","*","`","class","method","documentation",".","The","options","are",":","filter_method","The","filtering","method","controls","aspects","of","which","Kalman","filtering","approach","will","be","used",".","inversion_method","The","Kalman","filter","may","contain","one","matrix","inversion",":","that","of","the","forecast","error","covariance","matrix",".","The","inversion","method","controls","how","and","if","that","inverse","is","performed",".","stability_method","The","Kalman","filter","is","a","recursive","algorithm","that","may","in","some","cases","suffer","issues","with","numerical","stability",".","The","stability","method","controls","what",",","if","any",",","measures","are","taken","to","promote","stability",".","conserve_memory","By","default",",","the","Kalman","filter","computes","a","number","of","intermediate","matrices","at","each","iteration",".","The","memory","conservation","options","control","which","of","those","matrices","are","stored",".","filter_timing","By","default",",","the","Kalman","filter","follows","Durbin","and","Koopman",",","2012",",","in","initializing","the","filter","with","predicted","values",".","Kim","and","Nelson",",","1999",",","instead","initialize","the","filter","with","filtered","values",",","which","is","essentially","just","a","different","timing","convention",".","The","`","filter_method","`","and","`","inversion_method","`","options","intentionally","allow","the","possibility","that","multiple","methods","will","be","indicated",".","In","the","case","that","multiple","methods","are","selected",",","the","underlying","Kalman","filter","will","attempt","to","select","the","optional","method","given","the","input","data",".","For","example",",","it","may","be","that","INVERT_UNIVARIATE","and","SOLVE_CHOLESKY","are","indicated","(","this","is","in","fact","the","default","case",")",".","In","this","case",",","if","the","endogenous","vector","is","1-dimensional","(","`","k_endog","`","=","1",")",",","then","INVERT_UNIVARIATE","is","used","and","inversion","reduces","to","simple","division",",","and","if","it","has","a","larger","dimension",",","the","Cholesky","decomposition","along","with","linear","solving","(","rather","than","explicit","matrix","inversion",")","is","used",".","If","only","SOLVE_CHOLESKY","had","been","set",",","then","the","Cholesky","decomposition","method","would","*","always","*","be","used",",","even","in","the","case","of","1-dimensional","data","."]
docstr: Set the inversion method
  
  The Kalman filter may contain one matrix inversion: that of the
  forecast error covariance matrix. The inversion method controls how and
  if that inverse is performed.
  
  Parameters
  ----------
  inversion_method : int, optional
      Bitmask value to set the inversion method to. See notes for
      details.
  **kwargs
      Keyword arguments may be used to influence the inversion method by
      setting individual boolean flags. See notes for details.
  
  Notes
  -----
  The inversion method is defined by a collection of boolean flags, and
  is internally stored as a bitmask. The methods available are:
  
  INVERT_UNIVARIATE
      If the endogenous time series is univariate, then inversion can be
      performed by simple division. If this flag is set and the time
      series is univariate, then division will always be used even if
      other flags are also set.
  SOLVE_LU
      Use an LU decomposition along with a linear solver (rather than
      ever actually inverting the matrix).
  INVERT_LU
      Use an LU decomposition along with typical matrix inversion.
  SOLVE_CHOLESKY
      Use a Cholesky decomposition along with a linear solver.
  INVERT_CHOLESKY
      Use an Cholesky decomposition along with typical matrix inversion.
  
  If the bitmask is set directly via the `inversion_method` argument,
  then the full method must be provided.
  
  If keyword arguments are used to set individual boolean flags, then
  the lowercase of the method must be used as an argument name, and the
  value is the desired value of the boolean flag (True or False).
  
  Note that the inversion method may also be specified by directly
  modifying the class attributes which are defined similarly to the
  keyword arguments.
  
  The default inversion method is `INVERT_UNIVARIATE | SOLVE_CHOLESKY`
  
  Several things to keep in mind are:
  
  - If the filtering method is specified to be univariate, then simple
    division is always used regardless of the dimension of the endogenous
    time series.
  - Cholesky decomposition is about twice as fast as LU decomposition,
    but it requires that the matrix be positive definite. While this
    should generally be true, it may not be in every case.
  - Using a linear solver rather than true matrix inversion is generally
    faster and is numerically more stable.
  
  Examples
  --------
  >>> mod = sm.tsa.statespace.SARIMAX(range(10))
  >>> mod.ssm.inversion_method
  1
  >>> mod.ssm.solve_cholesky
  True
  >>> mod.ssm.invert_univariate
  True
  >>> mod.ssm.invert_lu
  False
  >>> mod.ssm.invert_univariate = False
  >>> mod.ssm.inversion_method
  8
  >>> mod.ssm.set_inversion_method(solve_cholesky=False,
  ...                              invert_cholesky=True)
  >>> mod.ssm.inversion_method
  16
docstr_tok: ["Set","the","inversion","method","The","Kalman","filter","may","contain","one","matrix","inversion",":","that","of","the","forecast","error","covariance","matrix",".","The","inversion","method","controls","how","and","if","that","inverse","is","performed",".","Parameters","--","--","--","--","--","inversion_method",":","int",",","optional","Bitmask","value","to","set","the","inversion","method","to",".","See","notes","for","details",".","*","*","kwargs","Keyword","arguments","may","be","used","to","influence","the","inversion","method","by","setting","individual","boolean","flags",".","See","notes","for","details",".","Notes","--","--","-","The","inversion","method","is","defined","by","a","collection","of","boolean","flags",",","and","is","internally","stored","as","a","bitmask",".","The","methods","available","are",":","INVERT_UNIVARIATE","If","the","endogenous","time","series","is","univariate",",","then","inversion","can","be","performed","by","simple","division",".","If","this","flag","is","set","and","the","time","series","is","univariate",",","then","division","will","always","be","used","even","if","other","flags","are","also","set",".","SOLVE_LU","Use","an","LU","decomposition","along","with","a","linear","solver","(","rather","than","ever","actually","inverting","the","matrix",")",".","INVERT_LU","Use","an","LU","decomposition","along","with","typical","matrix","inversion",".","SOLVE_CHOLESKY","Use","a","Cholesky","decomposition","along","with","a","linear","solver",".","INVERT_CHOLESKY","Use","an","Cholesky","decomposition","along","with","typical","matrix","inversion",".","If","the","bitmask","is","set","directly","via","the","`","inversion_method","`","argument",",","then","the","full","method","must","be","provided",".","If","keyword","arguments","are","used","to","set","individual","boolean","flags",",","then","the","lowercase","of","the","method","must","be","used","as","an","argument","name",",","and","the","value","is","the","desired","value","of","the","boolean","flag","(","True","or","False",")",".","Note","that","the","inversion","method","may","also","be","specified","by","directly","modifying","the","class","attributes","which","are","defined","similarly","to","the","keyword","arguments",".","The","default","inversion","method","is","`","INVERT_UNIVARIATE","|","SOLVE_CHOLESKY","`","Several","things","to","keep","in","mind","are",":","-","If","the","filtering","method","is","specified","to","be","univariate",",","then","simple","division","is","always","used","regardless","of","the","dimension","of","the","endogenous","time","series",".","-","Cholesky","decomposition","is","about","twice","as","fast","as","LU","decomposition",",","but","it","requires","that","the","matrix","be","positive","definite",".","While","this","should","generally","be","true",",","it","may","not","be","in","every","case",".","-","Using","a","linear","solver","rather","than","true","matrix","inversion","is","generally","faster","and","is","numerically","more","stable",".","Examples","--","--","--","--",">",">",">","mod","=","sm.tsa.statespace.SARIMAX","(","range","(","10",")",")",">",">",">","mod.ssm.inversion_method","1",">",">",">","mod.ssm.solve_cholesky","True",">",">",">","mod.ssm.invert_univariate","True",">",">",">","mod.ssm.invert_lu","False",">",">",">","mod.ssm.invert_univariate","=","False",">",">",">","mod.ssm.inversion_method","8",">",">",">","mod.ssm.set_inversion_method","(","solve_cholesky=False",",","...","invert_cholesky=True",")",">",">",">","mod.ssm.inversion_method","16"]
code: def set_inversion_method(self, inversion_method=None, **kwargs):
      r"""
      Set the inversion method
  
      The Kalman filter may contain one matrix inversion: that of the
      forecast error covariance matrix. The inversion method controls how and
      if that inverse is performed.
  
      Parameters
      ----------
      inversion_method : int, optional
          Bitmask value to set the inversion method to. See notes for
          details.
      **kwargs
          Keyword arguments may be used to influence the inversion method by
          setting individual boolean flags. See notes for details.
  
      Notes
      -----
      The inversion method is defined by a collection of boolean flags, and
      is internally stored as a bitmask. The methods available are:
  
      INVERT_UNIVARIATE
          If the endogenous time series is univariate, then inversion can be
          performed by simple division. If this flag is set and the time
          series is univariate, then division will always be used even if
          other flags are also set.
      SOLVE_LU
          Use an LU decomposition along with a linear solver (rather than
          ever actually inverting the matrix).
      INVERT_LU
          Use an LU decomposition along with typical matrix inversion.
      SOLVE_CHOLESKY
          Use a Cholesky decomposition along with a linear solver.
      INVERT_CHOLESKY
          Use an Cholesky decomposition along with typical matrix inversion.
  
      If the bitmask is set directly via the `inversion_method` argument,
      then the full method must be provided.
  
      If keyword arguments are used to set individual boolean flags, then
      the lowercase of the method must be used as an argument name, and the
      value is the desired value of the boolean flag (True or False).
  
      Note that the inversion method may also be specified by directly
      modifying the class attributes which are defined similarly to the
      keyword arguments.
  
      The default inversion method is `INVERT_UNIVARIATE | SOLVE_CHOLESKY`
  
      Several things to keep in mind are:
  
      - If the filtering method is specified to be univariate, then simple
        division is always used regardless of the dimension of the endogenous
        time series.
      - Cholesky decomposition is about twice as fast as LU decomposition,
        but it requires that the matrix be positive definite. While this
        should generally be true, it may not be in every case.
      - Using a linear solver rather than true matrix inversion is generally
        faster and is numerically more stable.
  
      Examples
      --------
      >>> mod = sm.tsa.statespace.SARIMAX(range(10))
      >>> mod.ssm.inversion_method
      1
      >>> mod.ssm.solve_cholesky
      True
      >>> mod.ssm.invert_univariate
      True
      >>> mod.ssm.invert_lu
      False
      >>> mod.ssm.invert_univariate = False
      >>> mod.ssm.inversion_method
      8
      >>> mod.ssm.set_inversion_method(solve_cholesky=False,
      ...                              invert_cholesky=True)
      >>> mod.ssm.inversion_method
      16
      """
      if inversion_method is not None:
          self.inversion_method = inversion_method
      for name in KalmanFilter.inversion_methods:
          if name in kwargs:
              setattr(self, name, kwargs[name])
  
imports: import contextlib
  from warnings import warn
  import numpy
  from .representation import OptionWrapper, Representation, FrozenRepresentation
  from .tools import reorder_missing_matrix, reorder_missing_vector
  from .None import tools
  from statsmodels.tools.sm_exceptions import ValueWarning
label_desc: Use image node_id 12 for calling the KalmanFilter obj's underlying member method code with example usage: obj.set_inversion_method(inversion_method) without return types