statsmodels.genmod.families.family.Binomial.loglike

Binomial.loglike(endog, mu, freq_weights=1, scale=1.0)[source]

The log-likelihood function in terms of the fitted mean response.

Parameters:

endog : array-like

Endogenous response variable

mu : array-like

Fitted mean response variable

freq_weights : array-like

1d array of frequency weights. The default is 1.

scale : float, optional

Not used for the Binomial GLM.

Returns:

llf : float

The value of the loglikelihood function evaluated at (endog,mu,freq_weights,scale) as defined below.

Notes

If the endogenous variable is binary:

\[llf = scale * \sum_i (y_i * \log(\mu_i/(1-\mu_i)) + \log(1-\mu_i)) * freq\_weights_i\]

If the endogenous variable is binomial:

\[llf = scale * \sum_i freq\_weights_i * (\ln \Gamma(n+1) - \ln \Gamma(y_i + 1) - \ln \Gamma(n_i - y_i +1) + y_i * \log(\mu_i / (1 - \mu_i)) + n * \log(1 - \mu_i))\]

where \(y_i = Y_i * n_i\) with \(Y_i\) and \(n_i\) as defined in Binomial initialize. This simply makes \(y_i\) the original number of successes.