AI Glossary / Statistics and probability / Intermediate
Glejser test
Definition
The Glejser test is a regression diagnostic that investigates heteroscedasticity by relating the absolute residuals from a fitted model to selected explanatory variables or their transformations. Heteroscedasticity means that the conditional variance of the model errors is not constant. The diagnostic asks whether residual magnitude changes systematically with the selected predictors; it does not directly test whether the model's mean predictions are accurate.
What it means
A forecasting model may make small errors for small orders and much larger errors for large orders. Positive and negative errors can cancel when averaged, hiding this changing spread. Taking absolute values retains error size while removing its direction.
The Glejser approach examines this magnitude pattern through an auxiliary regression. A relationship can alert an analyst that one common error scale is unsuitable across the data. Its relevance depends on the variables and functional forms chosen, so an insignificant result does not establish that every possible variance pattern is absent.
For AI teams, it is a useful classical diagnostic around an appropriate regression model, rather than a universal certification test for any machine-learning system.
How it works
Fit the original mean model and calculate residuals e_i = y_i - fitted_y_i. Specify an auxiliary regression such as |e_i| = a + b*z_i + v_i, where z represents a plausible driver of spread. More than one predictor or a justified transformation can be included.
Test the relevant auxiliary slope or slopes using the chosen implementation's statistic and assumptions. Software can report different related statistics, including an auxiliary F statistic and asymptotic statistics; they should be identified rather than treated as interchangeable exact tests.
Inspect residual plots and the original mean specification as well. Omitted curvature can create a pattern in absolute residuals without establishing the intended variance explanation. Dependence, leverage, unusual observations, and small samples can complicate interpretation. The diagnostic supplies evidence about a proposed pattern, not a complete model repair.
Three practical examples
- Demand forecasting: investigate whether absolute regression residuals grow with store size, helping the team examine whether uncertainty should vary across stores.
- Operations planning: test a prespecified relationship between workload and residual magnitude in a processing-time model, alongside checks for nonlinear mean effects.
- AI model assessment: use a regression diagnostic on a suitable statistical baseline to reveal changing error spread that an overall average error could hide.
Think of it this way
Think of checking whether an archer's shots spread farther apart as the target moves away. The average shot could remain centered at every distance. Measuring the size of each miss, rather than its left-or-right direction, helps reveal the change in precision. The statistical test still needs an appropriate model and enough observations.
Worked example
Consider an original teaching dataset with x values 1, 1, 2, 2, 3, 3, 4, 4. Construct responses as y = 10 + 3*x + e, using errors -1, 1, -2, 2, -2, 2, -4, 4. Each pair's errors sum to zero, and their products with x also sum to zero. Therefore ordinary least squares with an intercept recovers exactly 10 + 3*x.
The absolute residuals are 1, 1, 2, 2, 2, 2, 4, 4. Regressing these on an intercept and x gives fitted magnitude 0 + 0.9*x. Their total sum of squared deviations from their mean is 9.5; the auxiliary residual sum of squares is 1.4. Thus R-squared = 1 - 1.4/9.5 = 0.8526.
The conventional auxiliary F calculation is [(9.5 - 1.4)/1]/[1.4/(8 - 2)] = 34.7143. Direct least-squares computation independently confirms the coefficients and sums of squares. This deliberately constructed eight-observation example illustrates the calculation, not a dependable small-sample significance claim. It supplies neither an exact reference distribution nor evidence about a real business process.
Illustrative case study
In a fictional delivery business, an analyst fits a model of handling time using shipment characteristics. A plot suggests larger residual magnitudes for heavier shipments. The analyst specifies weight as a spread predictor and runs a Glejser diagnostic.
The team also checks whether missing nonlinear weight effects explain the pattern. After revising the mean model, it reassesses the residuals and compares suitable uncertainty estimates on later shipments. The operational decision concerns prediction intervals and staffing buffers; a test result alone does not establish the cause of variability or prove that a proposed correction improves performance.
Common misconceptions and mistakes
Common mistakes include regressing signed residuals when the intended diagnostic requires absolute values; declaring constant variance after a nonsignificant result; and selecting many transformations until one produces a small p-value.
A significant result does not automatically make ordinary least-squares coefficients biased. Under appropriate exogeneity conditions, changing error variance can instead undermine conventional standard errors and efficiency. Conversely, robust standard errors do not correct a wrong mean model, data leakage, or a flawed sampling design.
The auxiliary regression's fitted magnitude is also not automatically a valid variance function. Any weighting scheme derived from it needs its own justification and positivity checks.
Business use
Use the diagnostic when a regression analysis relies on assumptions about error spread and there is a defensible candidate driver. Record the original model, auxiliary variables, test statistic, sample structure, and follow-up action. Business reporting should describe how the finding affects uncertainty or decisions, rather than presenting a p-value as a standalone quality score.
People also ask
Does it test normality?
No. It investigates a selected pattern in residual magnitude.
Can it prove equal variance?
No. Failure to detect a pattern may reflect limited power or an unsuitable auxiliary specification.
Does it replace residual plots?
No. Plots help identify misspecification and observations that a single statistic can conceal.
Check your understanding
If a model's positive and negative errors cancel at every workload level, can its error spread still grow with workload?
Answer: Yes. Cancellation concerns direction and average error; absolute residuals can increase despite a zero average. This is why a magnitude diagnostic can reveal something that a signed-residual average misses.
Related terms
- Ordinary Least Squares
- White test
- Weighted least squares
- Heteroscedasticity
- residual analysis
- Breusch-Pagan test
- robust standard errors
Learn next
Learn residual-versus-fitted plots first, then compare different heteroscedasticity tests and the distinction between robust inference and explicit variance modeling. Practice checking mean misspecification before interpreting changes in spread.
More in Statistics and probability
- Geomteric mean - The geometric mean is an average obtained by multiplying positive values and taking the root corresponding to the number of values.
- German tank problem - The German tank problem is a statistical estimation problem in which an unknown population size is inferred from a sample of consecutive serial numbers.
- Gini's mean difference - Gini’s mean difference is a measure of dispersion defined as the average absolute difference between pairs of observations.
- Global calibration - Global calibration, in the computer-experiment sense used by the NIST engineering-statistics glossary, means developing a function that transforms a...
- Gold standard - A gold standard is an accepted reference used to judge the correctness or quality of another result.
- Goldfeld - Quandt test - The Goldfeld - Quandt test is a test for heteroscedasticity that compares residual variance estimates from two separately fitted regression subsamples.
Sources
EViews, Residual Diagnostics, Glejser and heteroskedasticity-test sections: https://eviews.com/help/content/testing-Residual_Diagnostics.html — primary software documentation for absolute-residual auxiliary regressions and reported statistics. SAS, Introduction to Statistical Modeling, Residual Analysis: https://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/statug_intromod_a0000000355.htm — primary explanation of fitted residuals and their leverage-dependent properties. The dataset and fictional case above are original teaching material.