'Generalized Poisson model score (gradient) vector of the log-likelihood
Parameters
params : array-like
The parameters of the model
Returns
score : ndarray, 1-D
The score vector of the model, i.e. the first derivative of the
loglikelihood function, evaluated at `params`'

def score(self, params):

    if self._transparams:
        alpha = np.exp(params[(-1)])
    else:
        alpha = params[(-1)]
    params = params[:(-1)]
    p = self.parameterization
    exog = self.exog
    y = self.endog[:, None]
    mu = self.predict(params)[:, None]
    mu_p = np.power(mu, p)
    a1 = (1 + (alpha * mu_p))
    a2 = (mu + ((alpha * mu_p) * y))
    a3 = ((alpha * p) * (mu ** (p - 1)))
    a4 = (a3 * y)
    dmudb = (mu * exog)
    dalpha = (mu_p * ((y * (((y - 1) / a2) - (2 / a1))) + (a2 / (a1 ** 2)))).sum()
    dparams = (dmudb * (((((- a4) / a1) + ((a3 * a2) / (a1 ** 2))) + ((1 + a4) * (((y - 1) / a2) - (1 / a1)))) + (1 / mu)))
    if self._transparams:
        return np.r_[(dparams.sum(0), (dalpha * alpha))]
    else:
        return np.r_[(dparams.sum(0), dalpha)]
