'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 : boolean, 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.'

def update(self, params, transformed=True, complex_step=False):

    params = super(DynamicFactor, self).update(params, transformed=transformed, complex_step=complex_step)
    self.ssm[self._idx_loadings] = params[self._params_loadings].reshape(self.k_endog, self.k_factors)
    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
    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)
    self.ssm[self._idx_factor_transition] = params[self._params_factor_transition].reshape(self.k_factors, (self.factor_order * self.k_factors))
    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]
