'The loglikelihood for an ARMA model using the Kalman Filter recursions.
Parameters
params : array
The coefficients of the ARMA model, assumed to be in the order of
trend variables and `k` exogenous coefficients, the `p` AR
coefficients, then the `q` MA coefficients.
arma_model : `statsmodels.tsa.arima.ARMA` instance
A reference to the ARMA model instance.
set_sigma2 : bool, optional
True if arma_model.sigma2 should be set.
Note that sigma2 will be computed in any case,
but it will be discarded if set_sigma2 is False.
Notes
This works for both real valued and complex valued parameters. The
complex values being used to compute the numerical derivative. If
available will use a Cython version of the Kalman Filter.'

@classmethod
def loglike(cls, params, arma_model, set_sigma2=True):

    (y, k, nobs, k_ar, k_ma, k_lags, newparams, Z_mat, m, R_mat, T_mat, paramsdtype) = cls._init_kalman_state(params, arma_model)
    if issubdtype(paramsdtype, float):
        (loglike, sigma2) = kalman_loglike.kalman_loglike_double(y, k, k_ar, k_ma, k_lags, int(nobs), Z_mat, R_mat, T_mat)
    elif issubdtype(paramsdtype, complex):
        (loglike, sigma2) = kalman_loglike.kalman_loglike_complex(y, k, k_ar, k_ma, k_lags, int(nobs), Z_mat.astype(complex), R_mat, T_mat)
    else:
        raise TypeError(('This    dtype    %s    is    not    supported        Please    files    a    bug    report.' % paramsdtype))
    if set_sigma2:
        arma_model.sigma2 = sigma2
    return loglike
