'Loglikelihood for observations of Generalized Poisson model
Parameters
params : array-like
The parameters of the model.
Returns
loglike : ndarray (nobs,)
The log likelihood for each observation of the model evaluated
at `params`. See Notes
Notes
.. math:: \ln L=\sum_{i=1}^{n}\left[\mu_{i}+(y_{i}-1)*ln(\mu_{i}+
\alpha*\mu_{i}^{p-1}*y_{i})-y_{i}*ln(1+\alpha*\mu_{i}^{p-1})-
ln(y_{i}!)-\frac{\mu_{i}+\alpha*\mu_{i}^{p-1}*y_{i}}{1+\alpha*
\mu_{i}^{p-1}}\right]
for observations :math:`i=1,...,n`'

def loglikeobs(self, params):

    if self._transparams:
        alpha = np.exp(params[(-1)])
    else:
        alpha = params[(-1)]
    params = params[:(-1)]
    p = self.parameterization
    endog = self.endog
    mu = self.predict(params)
    mu_p = np.power(mu, p)
    a1 = (1 + (alpha * mu_p))
    a2 = (mu + ((a1 - 1) * endog))
    return ((((np.log(mu) + ((endog - 1) * np.log(a2))) - (endog * np.log(a1))) - gammaln((endog + 1))) - (a2 / a1))
