statsmodels.genmod.families.family.NegativeBinomial.loglike_obs¶
- NegativeBinomial.loglike_obs(endog, mu, var_weights=1.0, scale=1.0)[source]¶
The log-likelihood function for each observation in terms of the fitted mean response for the Negative Binomial distribution.
- Parameters:
- endog
ndarray
Usually the endogenous response variable.
- mu
ndarray
Usually but not always the fitted mean response variable.
- var_weightsarray_like
1d array of variance (analytic) weights. The default is 1.
- scale
float
The scale parameter. The default is 1.
- endog
- Returns:
- ll_i
float
The value of the loglikelihood evaluated at (endog, mu, var_weights, scale) as defined below.
- ll_i
Notes
Defined as:
\[llf = \sum_i var\_weights_i / scale * (Y_i * \log{(\alpha * \mu_i / (1 + \alpha * \mu_i))} - \log{(1 + \alpha * \mu_i)}/ \alpha + Constant)\]where \(Constant\) is defined as:
\[Constant = \ln \Gamma{(Y_i + 1/ \alpha )} - \ln \Gamma(Y_i + 1) - \ln \Gamma{(1/ \alpha )}\]- constant = (special.gammaln(endog + 1 / self.alpha) -
special.gammaln(endog+1)-special.gammaln(1/self.alpha))
- return (endog * np.log(self.alpha * mu / (1 + self.alpha * mu)) -
np.log(1 + self.alpha * mu) / self.alpha + constant) * var_weights / scale