'Compute the score per observation, evaluated at params
Parameters
params : array_like
Array of parameters at which to evaluate the score.
kwargs
Additional arguments to the `loglike` method.
Returns
score : array
Score per observation, evaluated at `params`.
Notes
This is a numerical approximation, calculated using first-order complex
step differentiation on the `loglikeobs` method.'

def score_obs(self, params, method='approx', transformed=True, approx_complex_step=None, approx_centered=False, **kwargs):

    params = np.array(params, ndmin=1)
    if ((not transformed) and approx_complex_step):
        raise ValueError('Cannot    use    complex-step    approximations    to    calculate    the    score    at    each    observation    with    untransformed    parameters.')
    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 (method == 'harvey'):
        score = self._score_obs_harvey(params, transformed=transformed, approx_complex_step=approx_complex_step, **kwargs)
    elif ((method == 'approx') and approx_complex_step):
        epsilon = _get_epsilon(params, 2.0, None, len(params))
        kwargs['complex_step'] = True
        kwargs['transformed'] = True
        score = approx_fprime_cs(params, self.loglikeobs, epsilon=epsilon, kwargs=kwargs)
    elif (method == 'approx'):
        kwargs['transformed'] = transformed
        score = approx_fprime(params, self.loglikeobs, kwargs=kwargs, centered=approx_centered)
    else:
        raise NotImplementedError('Invalid    scoreobs    method.')
    return score
