Binomial.deviance(endog, mu, scale=1.0)[source]

Deviance function for either Bernoulli or Binomial data.


endog : array-like

Endogenous response variable (already transformed to a probability if appropriate).

mu : array

Fitted mean response variable

scale : float, optional

An optional scale argument


deviance : float

The deviance function as defined below


If the endogenous variable is binary:

deviance = -2*sum(I_one * log(mu) + (I_zero)*log(1-mu))

where I_one is an indicator function that evalueates to 1 if endog_i == 1. and I_zero is an indicator function that evaluates to 1 if endog_i == 0.

If the model is ninomial:

deviance = 2*sum(log(endog/mu) + (n-endog)*log((n-endog)/(n-mu))) where endog and n are as defined in Binomial.initialize.