'Compute the score function at params.
Parameters
params : array_like
Array of parameters at which to evaluate the score.
args
Additional positional arguments to the `loglike` method.
kwargs
Additional keyword arguments to the `loglike` method.
Returns
score : array
Score, evaluated at `params`.
Notes
This is a numerical approximation, calculated using first-order complex
step differentiation on the `loglike` method.
Both \*args and \*\*kwargs are necessary because the optimizer from
`fit` must call this function and only supports passing arguments via
\*args (for example `scipy.optimize.fmin_l_bfgs`).'

def score(self, params, *args, **kwargs):

    params = np.array(params, ndmin=1)
    (transformed, method, approx_complex_step, approx_centered, kwargs) = self._handle_args(MLEModel._score_param_names, MLEModel._score_param_defaults, *args, **kwargs)
    if ('method' in kwargs):
        method = kwargs.pop('method')
    if (approx_complex_step is None):
        approx_complex_step = (not self.ssm._complex_endog)
    if (approx_complex_step and self.ssm._complex_endog):
        raise ValueError('Cannot    use    complex    step    derivatives    when    data    or    parameters    are    complex.')
    if (not transformed):
        transform_score = self.transform_jacobian(params)
        params = self.transform_params(params)
    if (method == 'harvey'):
        score = self._score_harvey(params, approx_complex_step=approx_complex_step, **kwargs)
    elif ((method == 'approx') and approx_complex_step):
        score = self._score_complex_step(params, **kwargs)
    elif (method == 'approx'):
        score = self._score_finite_difference(params, approx_centered=approx_centered, **kwargs)
    else:
        raise NotImplementedError('Invalid    score    method.')
    if (not transformed):
        score = np.dot(transform_score, score)
    return score
