nemos.observation_models.PoissonObservations.deviance#
- PoissonObservations.deviance(spike_counts, predicted_rate, scale=1.0)[source]#
Compute the residual deviance for a Poisson model.
- Parameters:
spike_counts (
Array
) – The spike counts. Shape(n_time_bins, )
or(n_time_bins, n_neurons)
for population models.predicted_rate (
Array
) – The predicted firing rates. Shape(n_time_bins, )
or(n_time_bins, n_neurons)
for population models.scale (
Union
[float
,Array
]) – Scale parameter of the model.
- Return type:
Array
- Returns:
The residual deviance of the model.
Notes
The deviance is a measure of the goodness of fit of a statistical model. For a Poisson model, the residual deviance is computed as:
\[\begin{split}\begin{aligned} D(y_{tn}, \hat{y}_{tn}) &= 2 \left[ y_{tn} \log\left(\frac{y_{tn}}{\hat{y}_{tn}}\right) - (y_{tn} - \hat{y}_{tn}) \right]\\\ &= 2 \left( \text{LL}\left(y_{tn} | y_{tn}\right) - \text{LL}\left(y_{tn} | \hat{y}_{tn}\right)\right) \end{aligned}\end{split}\]where \(y\) is the observed data, \(\hat{y}\) is the predicted data, and \(\text{LL}\) is the model log-likelihood. Lower values of deviance indicate a better fit.