class_docstr: Dynamic factor model
  
  Parameters
  ----------
  endog : array_like
      The observed time-series process :math:`y`
  exog : array_like, optional
      Array of exogenous regressors for the observation equation, shaped
      nobs x k_exog.
  k_factors : int
      The number of unobserved factors.
  factor_order : int
      The order of the vector autoregression followed by the factors.
  error_cov_type : {'scalar', 'diagonal', 'unstructured'}, optional
      The structure of the covariance matrix of the observation error term,
      where "unstructured" puts no restrictions on the matrix, "diagonal"
      requires it to be any diagonal matrix (uncorrelated errors), and
      "scalar" requires it to be a scalar times the identity matrix. Default
      is "diagonal".
  error_order : int, optional
      The order of the vector autoregression followed by the observation
      error component. Default is None, corresponding to white noise errors.
  error_var : bool, optional
      Whether or not to model the errors jointly via a vector autoregression,
      rather than as individual autoregressions. Has no effect unless
      `error_order` is set. Default is False.
  enforce_stationarity : bool, optional
      Whether or not to transform the AR parameters to enforce stationarity
      in the autoregressive component of the model. Default is True.
  **kwargs
      Keyword arguments may be used to provide default values for state space
      matrices or for Kalman filtering options. See `Representation`, and
      `KalmanFilter` for more details.
  
  Attributes
  ----------
  exog : array_like, optional
      Array of exogenous regressors for the observation equation, shaped
      nobs x k_exog.
  k_factors : int
      The number of unobserved factors.
  factor_order : int
      The order of the vector autoregression followed by the factors.
  error_cov_type : {'diagonal', 'unstructured'}
      The structure of the covariance matrix of the error term, where
      "unstructured" puts no restrictions on the matrix and "diagonal"
      requires it to be a diagonal matrix (uncorrelated errors).
  error_order : int
      The order of the vector autoregression followed by the observation
      error component.
  error_var : bool
      Whether or not to model the errors jointly via a vector autoregression,
      rather than as individual autoregressions. Has no effect unless
      `error_order` is set.
  enforce_stationarity : bool, optional
      Whether or not to transform the AR parameters to enforce stationarity
      in the autoregressive component of the model. Default is True.
  
  Notes
  -----
  The dynamic factor model considered here is in the so-called static form,
  and is specified:
  
  .. math::
  
      y_t & = \Lambda f_t + B x_t + u_t \\
      f_t & = A_1 f_{t-1} + \dots + A_p f_{t-p} + \eta_t \\
      u_t & = C_1 u_{t-1} + \dots + C_q u_{t-q} + \varepsilon_t
  
  where there are `k_endog` observed series and `k_factors` unobserved
  factors. Thus :math:`y_t` is a `k_endog` x 1 vector and :math:`f_t` is a
  `k_factors` x 1 vector.
  
  :math:`x_t` are optional exogenous vectors, shaped `k_exog` x 1.
  
  :math:`\eta_t` and :math:`\varepsilon_t` are white noise error terms. In
  order to identify the factors, :math:`Var(\eta_t) = I`. Denote
  :math:`Var(\varepsilon_t) \equiv \Sigma`.
  
  Options related to the unobserved factors:
  
  - `k_factors`: this is the dimension of the vector :math:`f_t`, above.
    To exclude factors completely, set `k_factors = 0`.
  - `factor_order`: this is the number of lags to include in the factor
    evolution equation, and corresponds to :math:`p`, above. To have static
    factors, set `factor_order = 0`.
  
  Options related to the observation error term :math:`u_t`:
  
  - `error_order`: the number of lags to include in the error evolution
    equation; corresponds to :math:`q`, above. To have white noise errors,
    set `error_order = 0` (this is the default).
  - `error_cov_type`: this controls the form of the covariance matrix
    :math:`\Sigma`. If it is "dscalar", then :math:`\Sigma = \sigma^2 I`. If
    it is "diagonal", then
    :math:`\Sigma = \text{diag}(\sigma_1^2, \dots, \sigma_n^2)`. If it is
    "unstructured", then :math:`\Sigma` is any valid variance / covariance
    matrix (i.e. symmetric and positive definite).
  - `error_var`: this controls whether or not the errors evolve jointly
    according to a VAR(q), or individually according to separate AR(q)
    processes. In terms of the formulation above, if `error_var = False`,
    then the matrices :math:C_i` are diagonal, otherwise they are general
    VAR matrices.
  
  References
  ----------
  .. [*] Lütkepohl, Helmut. 2007.
     New Introduction to Multiple Time Series Analysis.
     Berlin: Springer.
class_docstr_tok: ["Dynamic","factor","model","Parameters","--","--","--","--","--","endog",":","array_like","The","observed","time-series","process",":","math",":","`","y","`","exog",":","array_like",",","optional","Array","of","exogenous","regressors","for","the","observation","equation",",","shaped","nobs","x","k_exog",".","k_factors",":","int","The","number","of","unobserved","factors",".","factor_order",":","int","The","order","of","the","vector","autoregression","followed","by","the","factors",".","error_cov_type",":","{","'scalar","'",",","'diagonal","'",",","'unstructured","'","}",",","optional","The","structure","of","the","covariance","matrix","of","the","observation","error","term",",","where","``","unstructured","''","puts","no","restrictions","on","the","matrix",",","``","diagonal","''","requires","it","to","be","any","diagonal","matrix","(","uncorrelated","errors",")",",","and","``","scalar","''","requires","it","to","be","a","scalar","times","the","identity","matrix",".","Default","is","``","diagonal","''",".","error_order",":","int",",","optional","The","order","of","the","vector","autoregression","followed","by","the","observation","error","component",".","Default","is","None",",","corresponding","to","white","noise","errors",".","error_var",":","bool",",","optional","Whether","or","not","to","model","the","errors","jointly","via","a","vector","autoregression",",","rather","than","as","individual","autoregressions",".","Has","no","effect","unless","`","error_order","`","is","set",".","Default","is","False",".","enforce_stationarity",":","bool",",","optional","Whether","or","not","to","transform","the","AR","parameters","to","enforce","stationarity","in","the","autoregressive","component","of","the","model",".","Default","is","True",".","*","*","kwargs","Keyword","arguments","may","be","used","to","provide","default","values","for","state","space","matrices","or","for","Kalman","filtering","options",".","See","`","Representation","`",",","and","`","KalmanFilter","`","for","more","details",".","Attributes","--","--","--","--","--","exog",":","array_like",",","optional","Array","of","exogenous","regressors","for","the","observation","equation",",","shaped","nobs","x","k_exog",".","k_factors",":","int","The","number","of","unobserved","factors",".","factor_order",":","int","The","order","of","the","vector","autoregression","followed","by","the","factors",".","error_cov_type",":","{","'diagonal","'",",","'unstructured","'","}","The","structure","of","the","covariance","matrix","of","the","error","term",",","where","``","unstructured","''","puts","no","restrictions","on","the","matrix","and","``","diagonal","''","requires","it","to","be","a","diagonal","matrix","(","uncorrelated","errors",")",".","error_order",":","int","The","order","of","the","vector","autoregression","followed","by","the","observation","error","component",".","error_var",":","bool","Whether","or","not","to","model","the","errors","jointly","via","a","vector","autoregression",",","rather","than","as","individual","autoregressions",".","Has","no","effect","unless","`","error_order","`","is","set",".","enforce_stationarity",":","bool",",","optional","Whether","or","not","to","transform","the","AR","parameters","to","enforce","stationarity","in","the","autoregressive","component","of","the","model",".","Default","is","True",".","Notes","--","--","-","The","dynamic","factor","model","considered","here","is","in","the","so-called","static","form",",","and","is","specified",":","..","math",":",":","y_t","&","=","\\Lambda","f_t","+","B","x_t","+","u_t","\\\\","f_t","&","=","A_1","f_","{","t-1","}","+","\\dots","+","A_p","f_","{","t-p","}","+","\\eta_t","\\\\","u_t","&","=","C_1","u_","{","t-1","}","+","\\dots","+","C_q","u_","{","t-q","}","+","\\varepsilon_t","where","there","are","`","k_endog","`","observed","series","and","`","k_factors","`","unobserved","factors",".","Thus",":","math",":","`","y_t","`","is","a","`","k_endog","`","x","1","vector","and",":","math",":","`","f_t","`","is","a","`","k_factors","`","x","1","vector",".",":","math",":","`","x_t","`","are","optional","exogenous","vectors",",","shaped","`","k_exog","`","x","1.",":","math",":","`","\\eta_t","`","and",":","math",":","`","\\varepsilon_t","`","are","white","noise","error","terms",".","In","order","to","identify","the","factors",",",":","math",":","`","Var","(","\\eta_t",")","=","I","`",".","Denote",":","math",":","`","Var","(","\\varepsilon_t",")","\\equiv","\\Sigma","`",".","Options","related","to","the","unobserved","factors",":","-","`","k_factors","`",":","this","is","the","dimension","of","the","vector",":","math",":","`","f_t","`",",","above",".","To","exclude","factors","completely",",","set","`","k_factors","=","0","`",".","-","`","factor_order","`",":","this","is","the","number","of","lags","to","include","in","the","factor","evolution","equation",",","and","corresponds","to",":","math",":","`","p","`",",","above",".","To","have","static","factors",",","set","`","factor_order","=","0","`",".","Options","related","to","the","observation","error","term",":","math",":","`","u_t","`",":","-","`","error_order","`",":","the","number","of","lags","to","include","in","the","error","evolution","equation",";","corresponds","to",":","math",":","`","q","`",",","above",".","To","have","white","noise","errors",",","set","`","error_order","=","0","`","(","this","is","the","default",")",".","-","`","error_cov_type","`",":","this","controls","the","form","of","the","covariance","matrix",":","math",":","`","\\Sigma","`",".","If","it","is","``","dscalar","''",",","then",":","math",":","`","\\Sigma","=","\\sigma^2","I","`",".","If","it","is","``","diagonal","''",",","then",":","math",":","`","\\Sigma","=","\\text","{","diag","}","(","\\sigma_1^2",",","\\dots",",","\\sigma_n^2",")","`",".","If","it","is","``","unstructured","''",",","then",":","math",":","`","\\Sigma","`","is","any","valid","variance","\/","covariance","matrix","(","i.e",".","symmetric","and","positive","definite",")",".","-","`","error_var","`",":","this","controls","whether","or","not","the","errors","evolve","jointly","according","to","a","VAR","(","q",")",",","or","individually","according","to","separate","AR","(","q",")","processes",".","In","terms","of","the","formulation","above",",","if","`","error_var","=","False","`",",","then","the","matrices",":","math",":","C_i","`","are","diagonal",",","otherwise","they","are","general","VAR","matrices",".","References","--","--","--","--","--","..","[","*","]","L\u00fctkepohl",",","Helmut",".","2007",".","New","Introduction","to","Multiple","Time","Series","Analysis",".","Berlin",":","Springer","."]
docstr: Update the parameters of the model
  
  Updates the representation matrices to fill in the new parameter
  values.
  
  Parameters
  ----------
  params : array_like
      Array of new parameters.
  transformed : bool, optional
      Whether or not `params` is already transformed. If set to False,
      `transform_params` is called. Default is True..
  
  Returns
  -------
  params : array_like
      Array of parameters.
  
  Notes
  -----
  Let `n = k_endog`, `m = k_factors`, and `p = factor_order`. Then the
  `params` vector has length
  :math:`[n       imes m] + [n] + [m^2    imes p]`.
  It is expanded in the following way:
  
  - The first :math:`n    imes m` parameters fill out the factor loading
    matrix, starting from the [0,0] entry and then proceeding along rows.
    These parameters are not modified in `transform_params`.
  - The next :math:`n` parameters provide variances for the error_cov
    errors in the observation equation. They fill in the diagonal of the
    observation covariance matrix, and are constrained to be positive by
    `transofrm_params`.
  - The next :math:`m^2   imes p` parameters are used to create the `p`
    coefficient matrices for the vector autoregression describing the
    factor transition. They are transformed in `transform_params` to
    enforce stationarity of the VAR(p). They are placed so as to make
    the transition matrix a companion matrix for the VAR. In particular,
    we assume that the first :math:`m^2` parameters fill the first
    coefficient matrix (starting at [0,0] and filling along rows), the
    second :math:`m^2` parameters fill the second matrix, etc.
code: def update(
      self,
      params,
      transformed=True,
      includes_fixed=False,
      complex_step=False,
  ):
      """
      Update the parameters of the model
  
      Updates the representation matrices to fill in the new parameter
      values.
  
      Parameters
      ----------
      params : array_like
          Array of new parameters.
      transformed : bool, optional
          Whether or not `params` is already transformed. If set to False,
          `transform_params` is called. Default is True..
  
      Returns
      -------
      params : array_like
          Array of parameters.
  
      Notes
      -----
      Let `n = k_endog`, `m = k_factors`, and `p = factor_order`. Then the
      `params` vector has length
      :math:`[n \times m] + [n] + [m^2 \times p]`.
      It is expanded in the following way:
  
      - The first :math:`n \times m` parameters fill out the factor loading
        matrix, starting from the [0,0] entry and then proceeding along rows.
        These parameters are not modified in `transform_params`.
      - The next :math:`n` parameters provide variances for the error_cov
        errors in the observation equation. They fill in the diagonal of the
        observation covariance matrix, and are constrained to be positive by
        `transofrm_params`.
      - The next :math:`m^2 \times p` parameters are used to create the `p`
        coefficient matrices for the vector autoregression describing the
        factor transition. They are transformed in `transform_params` to
        enforce stationarity of the VAR(p). They are placed so as to make
        the transition matrix a companion matrix for the VAR. In particular,
        we assume that the first :math:`m^2` parameters fill the first
        coefficient matrix (starting at [0,0] and filling along rows), the
        second :math:`m^2` parameters fill the second matrix, etc.
      """
      params = self.handle_params(
          params, transformed=transformed, includes_fixed=includes_fixed
      )
  
      # 1. Factor loadings
      # Update the design / factor loading matrix
      self.ssm[self._idx_loadings] = params[
          self._params_loadings
      ].reshape(self.k_endog, self.k_factors)
  
      # 2. Exog
      if self.k_exog > 0:
          exog_params = (
              params[self._params_exog]
              .reshape(self.k_endog, self.k_exog)
              .T
          )
          self.ssm[self._idx_exog] = np.dot(self.exog, exog_params).T
  
      # 3. Error covariances
      if self.error_cov_type in ["scalar", "diagonal"]:
          self.ssm[self._idx_error_cov] = params[self._params_error_cov]
      elif self.error_cov_type == "unstructured":
          error_cov_lower = np.zeros(
              (self.k_endog, self.k_endog), dtype=params.dtype
          )
          error_cov_lower[self._idx_lower_error_cov] = params[
              self._params_error_cov
          ]
          self.ssm[self._idx_error_cov] = np.dot(
              error_cov_lower, error_cov_lower.T
          )
  
      # 4. Factor transition VAR
      self.ssm[self._idx_factor_transition] = params[
          self._params_factor_transition
      ].reshape(self.k_factors, self.factor_order * self.k_factors)
  
      # 5. Error transition VAR
      if self.error_var:
          self.ssm[self._idx_error_transition] = params[
              self._params_error_transition
          ].reshape(self.k_endog, self._error_order)
      else:
          self.ssm[self._idx_error_transition] = params[
              self._params_error_transition
          ]
  
imports: import numpy
  from .mlemodel import MLEModel, MLEResults, MLEResultsWrapper
  from .tools import is_invertible, prepare_exog, constrain_stationary_univariate, unconstrain_stationary_univariate, constrain_stationary_multivariate, unconstrain_stationary_multivariate
  from statsmodels.multivariate.pca import PCA
  from statsmodels.regression.linear_model import OLS
  from statsmodels.tsa.vector_ar.var_model import VAR
  from statsmodels.tsa.arima.model import ARIMA
  from statsmodels.tools.tools import Bunch
  from statsmodels.tools.data import _is_using_pandas
  from statsmodels.tsa.tsatools import lagmat
  from statsmodels.tools.decorators import cache_readonly
  import statsmodels.base.wrapper
  from statsmodels.compat.pandas import Appender
label_desc: Use image node_id 20 for calling the DynamicFactor obj's underlying member method code with example usage: obj.update(params, transformed, includes_fixed, complex_step) without return types