Deviance Calculations for GLMs I am having trouble calculating deviance statistics for GLMs. For example,
for the exponential distribution $f(y)=\lambda*e^{\lambda*y}$ the deviance expressed in terms of responses and fitted values is $2*$ $ \sum $ $ $[$ y_{i}-\hat{\mu}\over \hat{\mu}$ - $log$ $y_{i} \over \hat{\mu}$ $]$ 
However, I'm not sure how to reach these solutions in a general way.... ie, step 1, step 2, etc to arrive at the deviance formula. For other distributions this becomes more complicated. I know ultimately that deviance compares reduced and full models, but not sure how to apply this fact to derive the solutions. I'd appreciate any assistance! 
 A: The deviance is defined as $-2\ln L(\hat{\theta}) - 2\ln L(\text{saturated model})$.
The "saturated model" in this case is one where every observation has its own estimate of $\lambda$, which in this case would be the MLE $1/y_i$ (that's definitional.)  To reparameterize to $\mu_i$ we just use $y_i$.
Writing this out with $\mu$ instead of $\lambda$ gives us:
$-2\sum [ -\ln \hat{\mu_i} - y_i/\hat{\mu_i} + \ln y_i + y_i/y_i]$
Noting that $y_i/y_i = \hat{\mu_i}/\hat{\mu_i} = 1$, substituting, and doing some minor rearrangement gives us:
$-2\sum [ -y_i/\hat{\mu_i} + \hat{\mu_i}/\hat{\mu_i} -\ln \hat{\mu_i} + \ln y_i]$
Multiplying through by the negative sign and a little more rearrangement gets us to:
$2\sum[\frac{y_i-\hat{\mu_i}}{\hat{\mu_i}} - \ln \frac{y_i}{\hat{\mu_i}}]$
Figuring out what the "saturated model" is may be the most difficult part.  Often, when comparing two different models with similar structure (e.g., a Poisson regression with and without a particular regressor), the terms brought in by using the "saturated model" will be the same and therefore will, in effect, cancel out in the comparison, leaving you with the difference between the two deviances equalling the difference between $2*$ the log likelihood ratios.
