Recall that the likelihood of a model is the probability of the data set given the model ().
The deviance of a model is defined by
where is the saturated model which is so named because it perfectly fits the data.
In the case of normally distributed errors the likelihood for a single prediction () and data point () is given by
and the log-likelihood by
The log-likelihood for the saturated model, which is when , is therefore simply
It follows that the unit deviance is
As the deviance residual is the signed squared root of the unit deviance,
in the case of normally distributed errors we arrive at which is the Pearson residual.
To confirm this consider a normal distribution with a and and a value of 1.
library(extras)
#>
#> Attaching package: 'extras'
#> The following object is masked from 'package:stats':
#>
#> step
mu <- 2
sigma <- 0.5
y <- 1
(y - mu) / sigma
#> [1] -2
dev_norm(y, mu, sigma, res = TRUE)
#> [1] -2
sign(y - mu) * sqrt(dev_norm(y, mu, sigma))
#> [1] -2
sign(y - mu) * sqrt(2 * (log(dnorm(y, y, sigma)) - log(dnorm(y, mu, sigma))))
#> [1] -2