'The log-likelihood in terms of the fitted mean response.
Parameters
endog : array-like
Endogenous response variable
mu : array-like
Fitted mean response variable
iweights : array-like
1d array of weights. The default is 1.
scale : float, optional
Scales the loglikelihood function. The default is 1.
Returns
llf : float
The value of the loglikelihood function evaluated at
(endog,mu,iweights,scale) as defined below.
Notes
If the link is the identity link function then the
loglikelihood function is the same as the classical OLS model.
.. math::
llf = -nobs / 2 * (\log(SSR) + (1 + \log(2 \pi / nobs)))
where
.. math::
SSR = \sum_i (Y_i - g^{-1}(\mu_i))^2
If the links is not the identity link then the loglikelihood
function is defined as
.. math::
llf = -1 / 2 \sum_i  * iweights_i * ((Y_i - mu_i)^2 / scale +
\log(2 * \pi * scale))'

def loglike(self, endog, mu, iweights=1.0, scale=1.0):

    if (isinstance(self.link, L.Power) and (self.link.power == 1)):
        nobs2 = (np.sum(iweights, axis=0) / 2.0)
        SSR = np.sum(((endog - self.fitted(mu)) ** 2), axis=0)
        llf = ((- np.log(SSR)) * nobs2)
        llf -= ((1 + np.log((np.pi / nobs2))) * nobs2)
        return llf
    else:
        return np.sum((((-0.5) * iweights) * ((((endog - mu) ** 2) / scale) + np.log(((2 * np.pi) * scale)))))
