Tutorials › Generalized Linear Models › Randomized Quantile Residuals from Fitted Distributions

Residuals and Deviance · Tutorial 750 of 981

Randomized Quantile Residuals from Fitted Distributions

Learn how to transform fitted-CDF probabilities into randomized quantile residuals and identify when standard-normal reference behavior is exact or only a diagnostic target.

Intermediate 11 min read

What You'll Learn

  • Define randomized quantile residuals using a fitted response CDF and an independent uniform draw
  • Explain why randomization fills the probability interval associated with an atom
  • Prove that the randomized probability is uniform under the correct response distribution
  • Derive the standard-normal reference distribution through the inverse normal CDF
  • Calculate residuals from fitted Gaussian, Gamma, and logistic distributions
  • Distinguish exact reference behavior with known distributions from plug-in behavior after fitting

Why Transform Residuals Through a Distribution?

A response residual is measured in the response's original units, so its size depends on the family and scale of the outcome. A difference of 2 may be modest for one response distribution and extreme for another. Pearson and deviance residuals address some of this scale dependence, but a different approach is to locate the observed response within its fitted distribution and express that location on a common scale.

The randomized quantile residual does this in two stages. First, it converts the observed response into a probability using its fitted cumulative distribution function (CDF). Then it applies the standard normal quantile function to that probability. If the CDF used is the true conditional distribution, this transformation has a standard normal reference distribution. With estimated parameters, that result is generally a target rather than an exact finite-sample guarantee.

Definition and Construction

For observation \(i\), let \(F_i(y)\) denote the fitted conditional CDF of \(Y_i\), evaluated at response value \(y\) and at that observation's covariates. Write \(F_i(y^-)=P(Y_i<y)\) under that distribution, and let \(V_i\) be a Uniform\((0,1)\) random variable independent of the response. The randomized probability and residual are defined as follows.

Definition: The randomized quantile probability for observation \(i\) is \(U_i=F_i(y_i^-)+V_i\{F_i(y_i)-F_i(y_i^-)\}\). The randomized quantile residual is \(r_i=\Phi^{-1}(U_i)\), where \(\Phi\) is the standard normal CDF and \(\Phi^{-1}\) is its quantile function. The random variables used for different observations are ordinarily drawn independently.

The interval from \(F_i(y_i^-)\) to \(F_i(y_i)\) has length equal to the fitted probability mass at \(y_i\). Randomization selects a location within that interval. If the fitted distribution is continuous at the observed response, the interval has length zero, so \(U_i=F_i(y_i)\); the added random variable has no effect. If the distribution has an atom at the response, the interval has positive length and randomization matters.

This definition uses the fitted distribution, which in a generalized linear model is determined by the fitted parameters and the observation's covariates. It does not require that the response itself be normal. The normal scale enters only in the final transformation \(\Phi^{-1}\).

Worked Calculations

Worked Example: A Gaussian Fitted Distribution

Suppose the fitted conditional distribution for an observation is \(N(10,4)\), so its mean is 10 and its variance is 4. The observed response is \(y=13\). Find the randomized quantile residual.

The standard deviation is \(\sqrt{4}=2\). Since this fitted distribution is continuous, the randomized probability is just its fitted CDF value:

$$ U=F(13)=\Phi\left(\frac{13-10}{2}\right)=\Phi(1.5)\approx 0.9332. $$

Applying the standard normal quantile gives \(r=\Phi^{-1}(0.9332)\approx 1.50\). The result also follows directly because the fitted distribution is normal with mean 10 and standard deviation 2. The residual is positive because the observed response is above the fitted mean.

Worked Example: A Gamma Fitted Distribution

Suppose a positive response has a fitted Gamma distribution with shape 2 and scale 3, and the observed value is \(y=3\). For this parameterization, its CDF is \(F(y)=1-e^{-y/3}(1+y/3)\) for \(y\geq 0\). Calculate the quantile residual.

The distribution is continuous, so no random draw is needed. Substitution gives

$$ U=F(3)=1-e^{-1}(1+1)=1-\frac{2}{e}\approx 0.2642. $$

The standard normal quantile at approximately \(0.2642\) is about \(-0.630\), since \(\Phi(-0.630)\approx 0.2643\). Thus \(r\approx -0.630\). The response is below the fitted distribution's median, so a negative residual is appropriate. This calculation uses the CDF, not a standardized difference between the observation and the fitted mean.

Worked Example: A Logistic Fitted Distribution

Let the fitted response distribution have logistic CDF \(F(y)=1/(1+e^{-y})\), and suppose \(y=\log(3)\). Find the residual.

The fitted probability is

$$ U=F(\log 3)=\frac{1}{1+e^{-\log 3}} =\frac{1}{1+1/3}=\frac{3}{4}. $$

Therefore \(r=\Phi^{-1}(0.75)\approx 0.6745\), using \(\Phi(0.6745)\approx 0.75\). The residual is not \(\log(3)\): the response is first mapped to its fitted cumulative probability, and only then to the normal scale.

Why the Randomized Probability Is Uniform

The key fact behind the construction is the randomized probability integral transform. It applies even when a distribution has atoms. For a continuous distribution, the familiar probability integral transform is recovered because there is no probability mass to spread across an interval.

Theorem: Let \(Y\) have CDF \(F\), let \(V\sim\operatorname{Uniform}(0,1)\) be independent of \(Y\), and define \(U=F(Y^-)+V\{F(Y)-F(Y^-)\}\). Then \(U\sim\operatorname{Uniform}(0,1)\).

Proof. Fix \(u\) with \(0<u<1\), and let \(x=\inf\{t:F(t)\geq u\}\). The CDF's right-continuity and monotonicity give \(a=F(x^-)\leq u\leq b=F(x)\). If \(a<u<b\), then \(P(Y<x)=a\), and the event \(Y=x\) has probability \(b-a\). For \(Y<x\), the randomized value is at most \(a<u\); for \(Y>x\), it is at least \(F(Y^-)\geq b>u\). Conditional on \(Y=x\), the randomized value is \(a+V(b-a)\), so its probability of being at most \(u\) is \((u-a)/(b-a)\). Consequently,

$$ P(U\leq u) =a+(b-a)\frac{u-a}{b-a} =u. $$

If \(u=a\) or \(u=b\), the same result follows by taking the corresponding endpoint probability; the uniform variable has zero probability of equaling either endpoint of its interval. If \(a=b=u\), there is no atom at \(x\), and the CDF probability accumulated below the crossing is \(u\), giving \(P(U\leq u)=u\) as well. Thus \(P(U\leq u)=u\) for every \(u\) in \((0,1)\), with the endpoint values following by limits. This is the CDF of a Uniform\((0,1)\) variable. \(\square\)

From Uniform Probabilities to Normal Residuals

The normal quantile transformation converts the uniform reference distribution into a standard normal one. This step is exact whenever the probability entering it is uniform; the calculation is a direct consequence of monotonicity of \(\Phi^{-1}\).

Result: If \(U\sim\operatorname{Uniform}(0,1)\) and \(R=\Phi^{-1}(U)\), then \(R\sim N(0,1)\).

Derivation. For every real \(z\), the standard normal CDF is strictly increasing, so

$$ P(R\leq z) =P\{\Phi^{-1}(U)\leq z\} =P\{U\leq\Phi(z)\} =\Phi(z). $$

This is precisely the CDF of \(N(0,1)\). Combining this result with the randomized probability theorem shows why the construction has a standard normal target under a correctly specified distribution.

Exact reference condition: If the conditional CDF \(F_i\) is the true CDF of \(Y_i\) given its covariates, and the randomization variables are independent Uniform\((0,1)\) draws independent of the responses, then each randomized quantile residual \(r_i\) has distribution \(N(0,1)\). If the responses are conditionally independent and the randomization draws are mutually independent, the residuals are also independent.

For the independence statement, each residual is a function only of its own response, its fixed conditional distribution, and its own independent randomization draw. Under conditional independence of the responses, these inputs are independent across observations. Applying separate deterministic transformations to independent inputs preserves independence.

Fitted Distributions and the Reference Target

In practice, \(F_i\) is usually estimated from the data. The randomized probability theorem requires the distribution used in the transformation to be the distribution that generated the response. Replacing unknown parameters by fitted estimates changes that condition. In particular, when the same responses are used both to estimate parameters and to calculate residuals, the fitted CDFs depend on the data. The residuals therefore do not generally have an exact, independent \(N(0,1)\) distribution in finite samples.

The standard normal distribution remains a useful reference for assessing whether the fitted model describes the response distributions adequately. But the comparison must be interpreted as a diagnostic, not as an automatic exact calibration. Estimation, shared fitted parameters, and the design can affect the residual distribution and dependence. A close match to a normal reference is not a proof that the model is correct; departures can flag aspects of the fitted distributions that merit investigation.

A practical calculation follows the same order for each observation: specify its fitted conditional distribution, evaluate the fitted CDF at the response (or across its probability interval when there is an atom), and then apply the standard normal quantile. The random draw is part of the construction when an interval has positive width; it should not be confused with uncertainty about the estimated model parameters.

Common Mistake

  • Wrong reasoning: “The residual is transformed to a normal scale, so the fitted residuals must be independent standard normal variables.”
  • Correction: The exact conclusion follows when the CDFs used are the true conditional distributions and the required independence conditions hold. Plugging in estimates from the same data does not preserve that exact result in general. Treat \(N(0,1)\) as a reference for fitted residuals, and account for estimation when making formal claims.
  • Another frequent error: Applying \(\Phi^{-1}\) directly to a response or to a response residual. The input must be a probability in \((0,1)\), obtained from the fitted CDF.
Key takeaway: Randomized quantile residuals map responses through fitted conditional CDF probabilities and then through the standard normal quantile function. The uniform-to-normal reference result is exact for true distributions; after fitting, it is generally a diagnostic target rather than a finite-sample guarantee.

Check Your Understanding

Use the definitions and reference conditions above to answer these questions.

  1. For a continuous fitted response distribution, what does the randomization term contribute to the quantile probability?
  2. Why does the randomized probability theorem apply when the response distribution has atoms?
  3. If a randomized probability is \(0.90\), how is its quantile residual defined, and what determines its sign?
  4. State the assumptions that give independent standard normal randomized quantile residuals when the conditional distributions are known.
  5. Why does estimating the model parameters from the same observations make the normal reference a target rather than an automatic exact result?
Clinical Biostats