I was calculating the deviance from a regression model that I fitted following the same idea from here Deviance.
For a likelihood $p(y|\theta)$, we define the deviance as $$D(\theta)=-2\log p(y|\theta)$$
The problem is that in this model the deviance is negative and I was trying to calculate the deviance residuals for this model, but it doesn't make much sense since $$D(\theta)=\sum (r_i^D)^2$$ where $r_i^D$ is the deviance residuals. So how the deviance residuals are calculated when the deviance is negative?
I notice from Wikipedia definition of Deviance Wikipedia that maybe this definition of deviance that I'm using is not appropriate.