betaFeedback

WorksMathematics

Model-Agnostic Influential Outlier Detection for Mixed Effects and Multi-Level Models

Abstract

Influential Outlier Detection is developed for mixed-effects models on clustered data. The Influential Outlier Metric is defined as a combination of SHapley Additive exPlanantion (SHAP) values and model residuals, both of which undergo a change of measure transformation. Building on previous work showcasing the suitability of using Normalizing flows to map arbitrary distributions to a flexible base distribution for statistical inference, the Normalizing Flows are constructed to allows contextual information and also provide a goodness of fit diagnostic for model evaluation. The use of SHAP values in the construction moves away from model specific tools and instead provides point-wise model agnostic influential outlier. The advantages and limitations of this approach are examined in several models including the linear model, the random forest, and gradient-boosted trees.

Introduction

Outlier detection remains a fundamental concern in statistical modeling and predictive analytics. Outliers are observations that depart markedly from the dominant structure of the data. While not all outliers are problematic, those that meaningfully alter model behavior are of particular interest and are commonly referred to as influential observations. Failure to properly identify and assess such points can lead to degraded predictive performance and misleading inferential conclusions [1].

To formalize this setting, consider a predictive framework in which the response vector y∈Rny \in\mathbb{R}^{n} is related to a set of pp covariates X∈Rn×pX \in\mathbb{R}^{n \times p} through an unknown function f(⋅)f(\cdot) with parameter vector θ\theta and error term ϵ∈Rn\epsilon\in\mathbb{R}^{n}, such that

y=f(X;θ)+ϵ.(1)\mathbf{y} = f(\mathbf{X}; \boldsymbol{\theta}) + \boldsymbol{\epsilon}. \tag*{(1)}

Within this general formulation, influential observations are those whose presence induces a non-negligible change in the fitted function f(⋅)f(\cdot), thereby affecting both predictions and parameter estimates. When f(⋅)f(\cdot) is specified as a linear function, the concept of influence is well understood and can be quantified through Cook’s distance [4]. This measure leverages the geometry of the design matrix via the hat matrix, whose diagonal elements hiih_{ii} capture the leverage of individual observations. Cook’s distance for observation ii can be written as

Ci=[yi−xi′β^σ^1−hii]2hiip(1−hii),(2)C_i = \left[\frac{y_i-\mathbf{x}_i^{\prime}\hat{\boldsymbol{\beta}}}{\hat{\sigma}\sqrt{1-h_{ii}}}\right]^2\frac{h_{ii}}{p(1-h_{ii})}, \tag*{(2)}

where θ^={σ^,β^}\hat{\boldsymbol{\theta}}=\{\hat{\sigma},\hat{\boldsymbol{\beta}}\} are the Ordinary Least Squares (OLS) estimators of the error standard deviation and regression coefficients and a′\mathbf{a}^{\prime} represents the transpose of vector a\mathbf{a}. This formulation highlights that influence arises from the interaction between two distinct components: the square of the residual, which reflects the discrepancy between observed and fitted values, and the leverage, which quantifies how unusual an observation is in the covariate space.

The Influential Outlier Metric (IOM) provides model-agnostic influential outlier detection in fixed effect models, including machine learning (ML) algorithms such as neural networks and bagged/boosted trees. The influence of an observation in an ML model uses a combination of SHapley Additive exPlanation (SHAP) values [11] and the residual. Both are transformed using normalizing flows (NF) [13], changing their respective measures to Gaussian distributions. The transformed SHAP values and residuals define the IOM as a product of two independent χ2\chi^2 random variables. Formally, define the model-agnostic IOM as the product

IOMi=(⟨Φ⟩Z−μΦ)i′ΣΦ−1(⟨Φ⟩Z−μΦ)i(⟨ε^⟩Zi−με^σε^)2,(3)\mathrm{IOM}_i = \left(\langle\boldsymbol{\Phi}\rangle_Z-\boldsymbol{\mu}_{\Phi}\right)^{\prime}_i\boldsymbol{\Sigma}_{\Phi}^{-1}\left(\langle\boldsymbol{\Phi}\rangle_Z-\boldsymbol{\mu}_{\Phi}\right)_i\left(\frac{\langle\hat{\varepsilon}\rangle_{Z_i}-\mu_{\hat{\varepsilon}}}{\sigma_{\hat{\varepsilon}}}\right)^2, \tag*{(3)}

where ⟨⋅⟩Z\langle\cdot\rangle_Z indicates the inverse transformation of a NF to change the measure of the SHAP values and residuals to a Gaussian random variable (⟨Φ⟩Z∼N(μΦ,ΣΦ)\langle\boldsymbol{\Phi}\rangle_Z\sim\mathcal{N}(\boldsymbol{\mu}_{\Phi},\boldsymbol{\Sigma}_{\Phi}) and ⟨ε^⟩Zi∼N(με^,σε^2)\langle\hat{\varepsilon}\rangle_{Z_i}\sim\mathcal{N}(\mu_{\hat{\varepsilon}},\sigma_{\hat{\varepsilon}}^2)). Since this is the product of independent χp2\chi_p^2 and χ12\chi_1^2 random variables, the density [8] of IOM is

fIOM(x)=x(p+1)/4−12(p+1)/2−1π Γ(p/2)K(p−1)/2(x),x>0,(4)f_{\mathrm{IOM}}(x)=\frac{x^{(p+1)/4-1}}{2^{(p+1)/2-1}\sqrt{\pi}\,\Gamma(p/2)}K_{(p-1)/2}(\sqrt{x}),\qquad x>0, \tag*{(4)}

where Γ(⋅)\Gamma(\cdot) is the gamma function and Kν(⋅)K_{\nu}(\cdot), ν≥0\nu\geq0 is the modified Bessel function of the second kind. An observation is flagged as an influential outlier at significance level α\alpha when

∫ξp,α∞fIOM(x) dx=1−α,(5)\int_{\xi_{p,\alpha}}^{\infty}f_{\mathrm{IOM}}(x)\,\mathrm{d}x=1-\alpha, \tag*{(5)}

where ξp,α\xi_{p,\alpha} is the upper-tail cutoff.

In this paper, the established framework is extended to substantially more flexible modeling environments. The key contribution of this paper is the development of the Mixed-Effects Influential Outlier Metric (MEIOM), which extends influential outlier detection to mixed-effects machine learning models. We integrate this perspective within mixed-effects machine learning models [6, 12], which jointly capture complex nonlinear relationships and hierarchical dependence structures.

Further, new functionality comes from improvements to the normalizing flow (NF) methodology used for change-of-measure inference. First, we generalize the unimodal Gaussian base distribution used in IOM to settings in which the latent distribution is better characterized by a mixture of Gaussian distributions [13]. This extension allows the NF to accommodate multimodal and more complex data topologies that may otherwise require substantial transport to map to a single Gaussian base distribution. This enables a wider range of SHAP value and residual distributions to be represented while also providing a new diagnostic tool for identifying latent multimodal structure. Second, we extend the NF to allow observed contextual information to condition the transformation when such information is available. To support this increased flexibility, we develop an information criterion for selecting the appropriate number of mixture components by balancing the complexity of the latent base distribution against the amount of transport required by the NF.

The remainder of this paper is structured as follows. § 2 introduces mixed-effects models and classical influence diagnostics as well as mixed-effect SHAP values, residuals. Next, § 3 develops the MEIOM. § 4 extends the normalizing-flow framework to Gaussian-mixture base distributions and conditional transformations, while § 5 extends the IOM to the mixture-Gaussian setting.

Section 6 introduces the Normalizing Flow Information Criterion (NFIC) for base-distribution selection, and Section 7 demonstrates its use for flexible normalizing-flow base distributions. Section 8 evaluates the proposed methodology in a simulated hierarchical setting, and Section 9 applies the MEIOM to a real-world PISA dataset. Finally, Section 10 concludes.

Mixed-Effects Models

In order to extend influence diagnostics to clustered data, consider a mixed-effects model (MEM) with a random intercept, defined by a response vector yij∈Ry_{ij} \in\mathbb{R}, individual-level (level-1) fixed effect predictors xij∈Rp\mathbf{x}_{ij} \in\mathbb{R}^{p}, cluster-level (level-2) fixed effect predictors wj∈Rr\mathbf{w}_j \in\mathbb{R}^{r}, a random intercept vector bj∈Rb_j \in\mathbb{R}, an error term εij∈R\varepsilon_{ij} \in\mathbb{R}, with i=1,…,nji = 1,\ldots,n_j, j=1,…,qj = 1,\ldots,q and n=n1+⋯+nqn = n_1 + \cdots+ n_q. Along with a model ff with parameters θ\boldsymbol{\theta}, the MEM is organized by the relation,

yij=f(xij,wj;θ)+bj+εij.(6)y_{ij} = f(\mathbf{x}_{ij}, \mathbf{w}_j; \boldsymbol{\theta}) + b_j + \varepsilon_{ij}. \tag*{(6)}

For the linear MEM, f(xij,wj;θ)=aijβf(\mathbf{x}_{ij}, \mathbf{w}_j; \boldsymbol{\theta}) = \mathbf{a}_{ij}\boldsymbol{\beta} and,

yij=aijβ+bj+εij(7)y_{ij} = \mathbf{a}_{ij}\boldsymbol{\beta} + b_j + \varepsilon_{ij} \tag*{(7)}

where aij=[xij wj]\mathbf{a}_{ij} = [\mathbf{x}_{ij}\ \mathbf{w}_j] and θ=β\boldsymbol{\theta} = \boldsymbol{\beta}. One may further suppose for the linear mixed effect model that εij∼N(0,σ2)\varepsilon_{ij} \sim\mathcal{N}(0,\sigma^2), bj∼N(0,σb2)b_j \sim\mathcal{N}(0,\sigma_b^2) and Cov⁡(εij,bj)=0\operatorname{Cov}(\varepsilon_{ij}, b_j) = 0.

Mixed-Effects Cook's Distance

In terms of influence, a full leave-one-out (or leave-one-group-out) approach to Cook’s distance is applied for the hierarchical levels (level 1 (ii) and level 2 (jj)) due to the added complexity of the random effects. Following Christensen et al. [ [3], there exists two sets of diagnostics: fixed-effects Cook’s distance and random-effects Cook’s distance. First for the fixed effects for level 1,

Ci(β^)=1p(β^−β^(i))′Var⁡^(β^)−1(β^−β^(i))(8)C_i(\hat{\boldsymbol{\beta}}) = \frac{1}{p}(\hat{\boldsymbol{\beta}}-\hat{\boldsymbol{\beta}}_{(i)})^\prime\widehat{\operatorname{Var}}(\hat{\boldsymbol{\beta}})^{-1}(\hat{\boldsymbol{\beta}}-\hat{\boldsymbol{\beta}}_{(i)}) \tag*{(8)}

where β^(i)\hat{\boldsymbol{\beta}}_{(i)} indicates the estimate of the fixed-effect parameters with the ithi^{\text{th}} individual removed. And for level 2,

Cj(β^)=1p(β^−β^(j))′Var⁡^(β^)−1(β^−β^(j))(9)C_j(\hat{\boldsymbol{\beta}}) = \frac{1}{p}(\hat{\boldsymbol{\beta}}-\hat{\boldsymbol{\beta}}_{(j)})^\prime\widehat{\operatorname{Var}}(\hat{\boldsymbol{\beta}})^{-1}(\hat{\boldsymbol{\beta}}-\hat{\boldsymbol{\beta}}_{(j)}) \tag*{(9)}

where β^(j)\hat{\boldsymbol{\beta}}_{(j)} indicates the estimate of the fixed-effect parameters with the jthj^{\text{th}} group removed.

For the random effects let ζ=[σ2,σb2]′\boldsymbol{\zeta} = [\sigma^2,\sigma_b^2]^\prime, for level 1,

Ri(ζ^)=(ζ^−ζ^(i))′Var⁡^(ζ^)−1(ζ^−ζ^(i))(10)R_i(\hat{\boldsymbol{\zeta}}) = (\hat{\boldsymbol{\zeta}}-\hat{\boldsymbol{\zeta}}_{(i)})^\prime\widehat{\operatorname{Var}}(\hat{\boldsymbol{\zeta}})^{-1}(\hat{\boldsymbol{\zeta}}-\hat{\boldsymbol{\zeta}}_{(i)}) \tag*{(10)}

where ζ^(i)\hat{\boldsymbol{\zeta}}_{(i)} indicates the estimate of the random-effect parameters with the ithi^{\text{th}} individual removed. And for level 2,

Rj(ζ^)=(ζ^−ζ^(j))′Var⁡^(ζ^)−1(ζ^−ζ^(j))(11)R_j(\hat{\boldsymbol{\zeta}}) = (\hat{\boldsymbol{\zeta}}-\hat{\boldsymbol{\zeta}}_{(j)})^\prime\widehat{\operatorname{Var}}(\hat{\boldsymbol{\zeta}})^{-1}(\hat{\boldsymbol{\zeta}}-\hat{\boldsymbol{\zeta}}_{(j)}) \tag*{(11)}

where ζ^(j)\hat{\boldsymbol{\zeta}}_{(j)} indicates the estimate of the random-effect parameters with the jthj^{\text{th}} group removed. Note there is no normalizing constant for random effect case-deletion diagnostics (see [3]).

Mixed-effect SHAP values and residuals

SHAP (SHapley Additive exPlanations) [11] values quantify the contribution of each input feature to a model’s prediction, providing a consistent and interpretable decomposition of the prediction into feature-level effects. SHAP values can be used to form an additive, linear, and local explanation model gg to approximate the complex regression model ff. Function g(φ)g(\varphi) is defined over surrogate variables, φ\varphi, used to locally interpret the impact of variables xijx_{ij} and wj\mathbf{w}_j. To account for population-level and group-specific variation in MEMs, SHAP values and residuals can be calculated for fixed-effect components (at all levels), random-effect components, and residual components.

SHAP values

For mixed-effects SHAP values, the local explanation model gg can be formulated as,

f(xij,wj)≈g(φij)=φ0i+∑k=1pφki+∑j=p+1rφj.(12)f(\mathbf{x}_{ij},\mathbf{w}_j) \approx g(\varphi_{ij}) = \varphi_{0i} + \sum_{k=1}^{p}\varphi_{ki} + \sum_{j=p+1}^{r}\varphi_j. \tag*{(12)}

Next, denote Φ(i)\boldsymbol{\Phi}^{(i)} as the collection of SHAP values for the level-1 fixed effects and Φ(j)\boldsymbol{\Phi}^{(j)} as SHAP values for the level-2 fixed effects. The construction of the MEIOM combines these mixed effect SHAP values, along with the associated MEM residuals introduced in the next section.

Residuals

Hilden-Minton [ [7] report four types of residuals for MEMs: level-1 (conditional) residuals ε^ij\hat{\varepsilon}_{ij}, level-1 marginal residuals e^ij\hat{e}_{ij}, the estimated random intercept as level-2 residuals, b^j\hat{b}_j from equation (7), and level-2 marginal residuals eˉj\bar{e}_j.

The level-1 conditional residuals,

ε^ij=yij−f(xij,wj;θ^)−b^j,(13)\hat{\varepsilon}_{ij} = y_{ij} - f(\mathbf{x}_{ij},\mathbf{w}_j;\hat{\boldsymbol{\theta}}) - \hat{b}_j, \tag*{(13)}

are the variation that is leftover after the individual, group fixed effects and the random group-specific deviation from those fixed effects are accounted for. For example, this determines how well the model explains this student’s score after adjusting for the effect of their school. The level-1 marginal residuals,

e^ij=yij−f(xij,wj;θ^),(14)\hat{e}_{ij} = y_{ij} - f(\mathbf{x}_{ij},\mathbf{w}_j;\hat{\boldsymbol{\theta}}), \tag*{(14)}

measure how well the fixed effects explain the outcome on average, ignoring individual/group variation. For example, this determines how well age and gender predict test scores, ignoring which school the student is in.

The level-2 residuals, b^j\hat{b}_j are estimated from the regression equation capturing unobserved cluster-level factors that systematically increase or decrease the outcome across all observations within a group. The level-2 marginal residuals are

eˉj=1nj∑i=1njyij−1nj∑i=1njf(xij,wj;θ^)=yˉj−fˉ(xij,wj;θ^),(15)\bar{e}_j = \frac{1}{n_j}\sum_{i=1}^{n_j} y_{ij} - \frac{1}{n_j}\sum_{i=1}^{n_j} f(\mathbf{x}_{ij},\mathbf{w}_j;\hat{\boldsymbol{\theta}}) = \bar{y}_j - \bar{f}(\mathbf{x}_{ij},\mathbf{w}_j;\hat{\boldsymbol{\theta}}), \tag*{(15)}

representing how much the average outcome for a group differs from what the fixed-effects portion of the model predicts for that group.

Mixed effect influential outlier metric

In this section, the the mixed-effect influential outlier metric (MEIOM) is developed for both individuals (level 1) and groups (level 2).

MEIOM: Level 1 (ii)

The conditional residuals capture the direct effect of each individual on the model. Let the NF transform the SHAP values (12) and conditional residuals (13) into Gaussian base distributions (⟨⋅⟩Z\langle\cdot\rangle_Z, described in § 4). The level-1 MEIOM is formulated by the product of the transformed level-1 SHAP values and transformed level-1 conditional residuals,

MEIOM⁡iZ=(⟨Φ(i)⟩Z−μΦ(i))′ΣΦ(i)−1(⟨Φ(i)⟩Z−μΦ(i))i(⟨ε^⟩Zi−με^σε^)2.(16)\operatorname{MEIOM}^{Z}_{i} = \left(\langle\boldsymbol{\Phi}^{(i)}\rangle_Z - \boldsymbol{\mu}_{\boldsymbol{\Phi}^{(i)}}\right)^{\prime}\boldsymbol{\Sigma}^{-1}_{\boldsymbol{\Phi}^{(i)}}\left(\langle\boldsymbol{\Phi}^{(i)}\rangle_Z - \boldsymbol{\mu}_{\boldsymbol{\Phi}^{(i)}}\right)_i\left(\frac{\langle\hat{\varepsilon}\rangle_{Zi}-\mu_{\hat{\varepsilon}}}{\sigma_{\hat{\varepsilon}}}\right)^2. \tag*{(16)}

MEIOM: Level 2 (jj)

At the second level, the MEIOM can be defined using the transformed group-level SHAP values (12) and the transformed estimated random intercept level-2 residual, ⟨b^j⟩Z∼N(μb^,σb^2)\langle\hat{b}_j\rangle_Z \sim\mathcal{N}(\mu_{\hat{b}},\sigma_{\hat{b}}^2),

MEIOMjZ=(ΦZ(j)−μΦ(j))TΣΦ(j)−1(ΦZ(j)−μΦ(j))j(⟨b^⟩Zj−μb^σb^)2.(17)\mathrm{MEIOM}_j^Z = \left(\boldsymbol{\Phi}^{(j)}_Z-\boldsymbol{\mu}_{\Phi^{(j)}}\right)^{\mathsf{T}}\boldsymbol{\Sigma}^{-1}_{\Phi^{(j)}}\left(\boldsymbol{\Phi}^{(j)}_Z-\boldsymbol{\mu}_{\Phi^{(j)}}\right)_j\left(\frac{\langle\hat{b}\rangle_{Z_j}-\mu_{\hat{b}}}{\sigma_{\hat{b}}}\right)^2 . \tag*{(17)}

Following this definition, a NF mapping ensures that both level-1 and level-2 MEIOMs are calibrated to a known reference distribution, facilitating principled inference and thresholding for influential observations. However, with more complex data topologies a mapping to a distribution other then a unimodal Gaussian can be advantageous. Further, conditional NF may provide more context to the flow to achieve more flexible mapping.

Extending the normalizing flows for inference

Normalizing flows use a sequence of invertible and differentiable transformations to map observations from a complex distribution to a simpler base distribution with a known density. Consider a random vector V\mathbf{V} from a complex or unknown distribution pV(v;θ)p_{\mathbf{V}}(\mathbf{v};\boldsymbol{\theta}) and a simple base distribution pZ(z;θZ)p_{\mathbf{Z}}(\mathbf{z};\boldsymbol{\theta}_{Z}). A NF, TT, maps V=T(Z)\mathbf{V}=T(\mathbf{Z}). Both V\mathbf{V} and Z\mathbf{Z} must have the same dimension, pp. Under these conditions, the density of V\mathbf{V} is defined by the change-of-variable formula,

pV(v;θ)=pZ(z;θZ)∣det⁡JT(z)∣−1,(18)p_{\mathbf{V}}(\mathbf{v};\boldsymbol{\theta})=p_{\mathbf{Z}}(\mathbf{z};\boldsymbol{\theta}_{Z})\lvert\det J_T(\mathbf{z})\rvert^{-1}, \tag*{(18)}

with the p×pp\times p Jacobian,

JT(z)=(∂T1∂z1⋯∂Tp∂z1⋮⋱⋮∂Tp∂z1⋯∂Tp∂zp).(19)J_T(\mathbf{z})= \begin{pmatrix} \frac{\partial T_1}{\partial z_1} & \cdots& \frac{\partial T_p}{\partial z_1}\\ \vdots& \ddots& \vdots\\ \frac{\partial T_p}{\partial z_1} & \cdots& \frac{\partial T_p}{\partial z_p} \end{pmatrix}. \tag*{(19)}

In practice, TT is constructed with a neural network and may be composed of KK transformations:

T=TK∘TK−1∘⋯∘T1,(20)T=T_K\circ T_{K-1}\circ\cdots\circ T_1, \tag*{(20)}

and the parameters of TT are estimated by minimizing the penalized loss function L\mathcal{L},

T^=arg min⁡TL=arg min⁡TLKL+λLpen,(21)\hat{T}=\underset{T}{\operatorname{arg\,min}}\mathcal{L}=\underset{T}{\operatorname{arg\,min}}\mathcal{L}_{KL}+\lambda\mathcal{L}_{\mathrm{pen}}, \tag*{(21)}

where,

LKL(θ,θZ)=DKL[pV∗(v)∥pV(v;θ)]∝−EpV∗(v)[log⁡pV(v;θ)]∝−EpV∗(v)[log⁡pZ(T−1(v;θ);θZ)+log⁡∣det⁡JT−1(v;θ)∣](22)\begin{aligned} \mathcal{L}_{KL}(\boldsymbol{\theta},\boldsymbol{\theta}_Z)&=D_{KL}[p_{\mathbf{V}}^*(\mathbf{v})\|p_{\mathbf{V}}(\mathbf{v};\boldsymbol{\theta})]\\ &\propto-\mathbb{E}_{p_{\mathbf{V}}^*(\mathbf{v})}[\log p_{\mathbf{V}}(\mathbf{v};\boldsymbol{\theta})]\\ &\propto-\mathbb{E}_{p_{\mathbf{V}}^*(\mathbf{v})}\left[\log p_{\mathbf{Z}}(T^{-1}(\mathbf{v};\boldsymbol{\theta});\boldsymbol{\theta}_Z)+\log\lvert\det J_{T^{-1}}(\mathbf{v};\boldsymbol{\theta})\rvert\right] \tag*{(22)} \end{aligned}

and

Lpen=E[log⁡2∣det⁡JT−1(v)∣].(23)\mathcal{L}_{\mathrm{pen}}=\mathbb{E}[\log^2\lvert\det J_{T^{-1}}(\mathbf{v})\rvert]. \tag*{(23)}

For the transformation to be useful for inference, it must provide a robust and stable change of measure. Jones and Campbell [ [9] examine the stability of NF transformations with respect to random initialization, sampling variability, and network architecture, providing empirical support for their use as a reliable inferential transformation when the mapped distribution satisfies the required goodness-of-fit conditions. Following Ryzhikov et al. [ [14], Jones and Campbell [ [9] use a penalty (parameterized by λ>0\lambda>0) on the distortion on the volume, calculated by the square of the determinant of the Jacobian matrix, done by the NF to restrict the movement away from the original data. Building on the stability analysis done by Jones and Campbell [ [9], the framework is extended in two ways. First, a more flexible Gaussian-mixture base distribution is developed, together with an appropriate testing procedure to assess whether the transformed data are adequately calibrated to the chosen mixture. Second, a conditional NF is introduced, allowing observed contextual information to influence the transformation.

Mixture of Gaussians base distribution

Let V∼pV(v)\mathbf{V} \sim p_{\mathbf{V}}(v) denote either the SHAP vectors or the residual vectors. The goal is to apply a transformation so that the inversely mapped variables ⟨V⟩Z\langle\mathbf{V}\rangle_{\mathbf{Z}} follow a Gaussian mixture of the form

⟨V⟩Z∼∑k=1KwkNp(μk,Σk),∑k=1Kwk=1,(24)\langle\mathbf{V}\rangle_{\mathbf{Z}} \sim\sum_{k=1}^{K} w_k \mathcal{N}_p(\boldsymbol{\mu}_k,\boldsymbol{\Sigma}_k), \qquad\sum_{k=1}^{K} w_k = 1, \tag*{(24)}

providing a more versatile reference distribution. To verify that the transformation is correctly specified, a goodness-of-fit test is developed for the base mixture model.

Mixture-Gaussian Calibration by Mode Assignment and Whitening

It is necessary to verify that the normalizing flow mapping adequately matches the base distribution based on goodness-of-fit-tests. The component means μk\boldsymbol{\mu}_k and covariances Σk\boldsymbol{\Sigma}_k are chosen so that the modes of the mixture are well separated, ensuring that for each observation, ∃k∗∈{1,…,K}\exists k^* \in\{1,\ldots,K\} such that wk∗≈1w_{k^*} \approx1 and wℓ≠k∗≈0w_{\ell\ne k^*} \approx0, reducing the mixture to vi∼˙Np(μk∗,Σk∗)\mathbf{v}_i \mathrel{\dot\sim} \mathcal{N}_p(\boldsymbol{\mu}_{k^*},\boldsymbol{\Sigma}_{k^*}).

Conditional on the assigned component, each observation is whitened using the corresponding component mean and covariance matrix. For diagonal covariance matrices, this reduces to the coordinatewise transformation

rij=Vij−μk∗,jσk∗,j,j=1,…,p.(25)r_{ij} = \frac{V_{ij} - \mu_{k^*,j}}{\sigma_{k^*,j}}, \qquad j=1,\ldots,p. \tag*{(25)}

If the transformed data are correctly calibrated to the target mixture distribution and the component assignment is reliable, then within each assigned mode the whitened residuals should satisfy

ri∣ki=ki∗∼˙Np(0,Ip).(26)\mathbf{r}_i \mid k_i = k_i^* \mathrel{\dot\sim} \mathcal{N}_p(\mathbf{0},\mathbf{I}_p). \tag*{(26)}

This condition is evaluated using mode-level normality tests. In the univariate case, p=1p=1, the Jarque-Bera test is used within the assigned mode. When p≥2p \ge2, the Henze-Zirkler test for multivariate normality. This gives one mode-level pp-value, denoted pℓp_\ell, for each mixture component with sufficient assigned observations.

Because the mode-level tests assess local calibration of each component, they are reported individually. To summarize the aggregate evidence across components, Stouffer’s combined statistic is also calculated,

ZSt=1k∗∑ℓ=1k∗ΦF−1(1−pℓ),(27)Z_{\mathrm{St}} = \frac{1}{\sqrt{k^*}}\sum_{\ell=1}^{k^*}\Phi_F^{-1}(1-p_\ell), \tag*{(27)}

where k∗k^* is the number of components for which a mode-level normality test is computed and ΦF\Phi_F is standard normal cumulative distribution function. The corresponding combined pp-value is

pSt=1−ΦF(ZSt).(28)p_{\mathrm{St}} = 1-\Phi_F(Z_{\mathrm{St}}). \tag*{(28)}

The pp-value pStp_{\mathrm{St}} acts as an aggregate diagnostic of mode-level normality rather than as a replacement for the individual component tests. This is important because a combined pp-value can mask a localized failure in one component. Therefore, the individual mode-level pp-values and the Stouffer combined pp-value are interpreted jointly.

The combined whitened residuals

Qi=ri′ri=∑j=1prij2,(29)Q_i = \mathbf{r}_i^{\prime}\mathbf{r}_i = \sum_{j=1}^{p} r_{ij}^{2}, \tag*{(29)}

under correct calibration and reliable component assignment has distribution

Qi∼χp2.(30)Q_i \sim\chi_p^2. \tag*{(30)}

This pooled chi-square approximation is tested using goodness-of-fit tests such as the Kolmogorov-Smirnov test and the Cramér-von Mises test. This diagnostic is complementary to the mode-level normality tests: the mode-level tests assess whether each assigned component has the correct Gaussian shape, while the pooled chi-square test assesses whether the overall squared-distance scale is calibrated.

The penalty parameter λ\lambda is selected using the goodness-of-fit tests as diagnostics rather than by relying on a single combined test. For each candidate regularization strength λ\lambda, compute the mode-level normality pp-values, the Stouffer combined pp-value, the assignment-certainty diagnostics, and the pooled chi-square goodness-of-fit pp-value. A candidate transformation is considered acceptable only if no component shows severe lack of normality, the aggregate mode-level normality diagnostic is adequate, and the pooled chi-square statistic is not significantly non chi-square.

Conditional normalizing flows

In settings where the distribution of the SHAP values or residuals is expected to vary systematically across an observed contextual variable, the normalizing-flow transformation is extended to a conditional NF. Let CiC_i denote the observed context for observation ii. Rather than estimating a single marginal transformation T−1(Vi)T^{-1}(\mathbf{V}_i), the conditional flow estimates

Zi=T−1(Vi∣Ci),(31)\mathbf{Z}_i = T^{-1}(\mathbf{V}_i \mid\mathbf{C}_i), \tag*{(31)}

where Vi\mathbf{V}_i denotes either the SHAP vector or the residual and Ci\mathbf{C}_i is treated as fixed conditioning information rather than as a variable to be transformed. For each fixed value of Ci\mathbf{C}_i, the map remains invertible with respect to Vi\mathbf{V}_i.

The conditional transformation is implemented using a Neural Spline Flow (NSF) [5]. In an autoregressive rational-quadratic spline layer, the conditioning network that produces the spline widths, heights, and derivatives receives both the transformed variables available under the autoregressive mask and the context Ci\mathbf{C}_i. Consequently, the spline transformation can vary with the observed context while sharing a common set of neural-network parameters across all observations. The context therefore modifies the transformation but is not itself included in the flow Jacobian. The change-of-variables density is

pV(vi∣Ci)=pZ(T−1(vi∣Ci))∣det⁡(∂T−1(vi∣Ci)∂vi)∣.(32)p_V(\mathbf{v}_i \mid\mathbf{C}_i) = p_Z\left(T^{-1}(\mathbf{v}_i \mid\mathbf{C}_i)\right) \left\lvert\det\left(\frac{\partial T^{-1}(\mathbf{v}_i \mid\mathbf{C}_i)}{\partial\mathbf{v}_i}\right) \right\rvert. \tag*{(32)}

Importantly, the latent base distribution is kept common across contexts. Thus, conditioning affects the transport map but not the Gaussian or Gaussian-mixture reference distribution. This allows observations from different contexts to be mapped to the same calibrated latent distribution while defining outlyingness relative to the distribution expected within the observed context. When no contextual variable is supplied, the method reduces to the unconditional normalizing-flow formulation described above. Without loss of generality, assume that the NF ⟨⋅⟩Z\langle\cdot\rangle_Z may be given a contextual variable if available ⟨⋅⟩Z∣C\langle\cdot\rangle_{Z|\mathbf{C}}.

Mixed Effects Influential Outlier Metric with a Mixture Gaussian Base Distribution

The IOM is extended to the case where the base distribution is a mixture of Gaussians with fixed weights, means, and covariance matrices. Following the single Gaussian base case, the Mahalanobis distance of the mixture of Gaussians is of interest,

Q=∑k=1Kwk(⟨V⟩Z−μk)TΣk−1(⟨V⟩Z−μk),(33)Q = \sum_{k=1}^{K} w_k \left(\langle\mathbf{V} \rangle_Z - \boldsymbol{\mu}_k\right)^{\mathsf{T}} \boldsymbol{\Sigma}_k^{-1} \left(\langle\mathbf{V} \rangle_Z - \boldsymbol{\mu}_k\right), \tag*{(33)}

where ⟨V⟩Z∼∑k=1KwkNp(μk,Σk)\langle\mathbf{V} \rangle_Z \sim\sum_{k=1}^{K} w_k \mathcal{N}_p(\boldsymbol{\mu}_k, \boldsymbol{\Sigma}_k). In general, this weighted sum of squared Mahalanobis distances follows a weighted mixture of non-central chi-square distributions, which can be complex to work with analytically. However, given well-separated modes verified in § 4.1.1, QQ can be approximated by a single χp2\chi_p^2.

In what follows, each observation is assigned to the mixture component k∗k^* with the highest posterior probability, and all distances are computed with respect to the parameters of that component.

Level-1 MEIOM

Beginning with the transformation of the level-1 SHAP values (12), compute the squared Mahalanobis distance

Di2=(⟨Φ(i)⟩Zi−μΦk∗(i))′ΣΦk∗(i)−1(⟨Φ(i)⟩Zi−μΦk∗(i)),(34)D_i^2 = \left(\langle\Phi^{(i)}\rangle_{Z_i} - \mu_{\Phi_{k^*}^{(i)}}\right)^{\prime}\Sigma_{\Phi_{k^*}^{(i)}}^{-1}\left(\langle\Phi^{(i)}\rangle_{Z_i} - \mu_{\Phi_{k^*}^{(i)}}\right), \tag*{(34)}

where Di2∼χp2D_i^2 \sim\chi_p^2.

Similarly, apply the mixture of Gaussian base distribution to the level-1 conditional residuals (13) and take the transformed residual

Ei=⟨ε^⟩Zi−με^k∗σε^k∗.(35)E_i = \frac{\langle\hat{\varepsilon}\rangle_{Z_i} - \mu_{\hat{\varepsilon}_{k^*}}}{\sigma_{\hat{\varepsilon}_{k^*}}}. \tag*{(35)}

If the modes are well separated, the approximation Ei2∼χ12E_i^2 \sim\chi_1^2 is valid; otherwise, Ei2E_i^2 is a mixture of non-central χ2\chi^2 distributions.

The level-1 influential outlier metric combines the Mahalanobis distance with the normalized conditional residual:

MEIOM⁡iZ=Di2⋅Ei2.(36)\operatorname{MEIOM}_i^{Z} = D_i^2 \cdot E_i^2. \tag*{(36)}

Level-2 MEIOM

Analogously, for the level-2 SHAP values (12) compute

Dj2=(⟨Φ(j)⟩Zi−μΦk∗(j))′ΣΦk∗(j)−1(⟨Φ(j)⟩Zi−μΦk∗(j)),(37)D_j^2 = \left(\langle\Phi^{(j)}\rangle_{Z_i} - \mu_{\Phi_{k^*}^{(j)}}\right)^{\prime}\Sigma_{\Phi_{k^*}^{(j)}}^{-1}\left(\langle\Phi^{(j)}\rangle_{Z_i} - \mu_{\Phi_{k^*}^{(j)}}\right), \tag*{(37)}

where Dj2∼χr2D_j^2 \sim\chi_r^2, and take the transformed level-2 estimated random intercept residual

Ej=⟨b^⟩Zj−μb^k∗σb^k∗.(38)E_j = \frac{\langle\hat{b}\rangle_{Z_j} - \mu_{\hat{b}_{k^*}}}{\sigma_{\hat{b}_{k^*}}}. \tag*{(38)}

where, again, Ej2∼χ12E_j^2 \sim\chi_1^2 provided the modes are well separated.

The level-2 influential outlier metric is then

MEIOM⁡jZ=Dj2⋅Ej2.(39)\operatorname{MEIOM}_j^{Z} = D_j^2 \cdot E_j^2. \tag*{(39)}

At both levels, since Di2∼χp2D_i^2 \sim\chi_p^2, Dj2∼χr2D_j^2 \sim\chi_r^2, and Eℓ2∼χ12E_\ell^2 \sim\chi_1^2 for ℓ∈{i,j}\ell\in\{i,j\}, critical values can be obtained from the product of independent χ2\chi^2 distributions, as in the single Gaussian case.

Summary of Steps:

  1. Choose means and diagonal covariance matrices such that mixture modes are well separated. With V∼Np(μ,Σ)V \sim\mathcal{N}_p(\boldsymbol{\mu}, \boldsymbol{\Sigma}), modes separated by

Δk,ℓ=∑j=1p(μkj−μℓjσj)2≥5(40)\Delta_{k,\ell} = \sqrt{\sum_{j=1}^{p}\left(\frac{\mu_{kj}-\mu_{\ell j}}{\sigma_j}\right)^2} \ge5 \tag*{(40)}

heuristically work well.

  1. Compute posterior probabilities γ^ℓk\hat{\gamma}_{\ell k}, ℓ∈{i,j}\ell\in\{i,j\} for each individual or school.

  1. Assign each observation to the component k∗k^* with the highest γ^ℓk\hat{\gamma}_{\ell k}, ℓ∈{i,j}\ell\in\{i,j\}.

  1. Compute Dℓ2D_\ell^2, and Eℓ2E_\ell^2 for level ℓ∈{i,j}\ell\in\{i,j\} with respect to the assigned k∗k^*.

  1. Construct the level-1 and level-2 metrics as MEIOM⁡ℓZ=Dℓ2⋅Eℓ2\operatorname{MEIOM}_{\ell}^{Z} = D_\ell^2 \cdot E_\ell^2, ℓ∈{i,j}\ell\in\{i,j\}.

  1. Use critical values from the product of independent χ2\chi^2 distributions to identify influential outliers at each level.

Latent Structure Identification via the Normalizing Flow Information Criterion

The flexibility of the mixture base distribution creates a model-selection problem: additional components may improve fit but can also introduce unnecessary latent complexity. Therefore select among candidate base distributions using the NFIC, counting only the free parameters of the mixture base (component means, diagonal scales, and mixture weights), while excluding the flow parameters. The flow parameters are optimized separately and screened by the preceding goodness-of-fit tests. Beyond model selection, the NFIC can also serve as a diagnostic tool. In particular, a residual distribution that strongly favours a multimodal base may indicate latent heterogeneity, omitted structure, or model misspecification that is not captured by the fitted model.

Let {vi}i=1nv\{\mathbf{v}_i\}_{i=1}^{n_v} denote the validation sample of either SHAP values or residuals, and for candidate flow mm let zim=T^m−1(vi)\mathbf{z}_{im}=\widehat{T}_m^{-1}(\mathbf{v}_i) be the corresponding latent representations under the fitted inverse map T^m−1\widehat{T}_m^{-1}. We introduce the Normalizing Flow Information Criterion (NFIC), a transport-based criterion derived from a generalized Bayesian (Gibbs) evidence argument. The derivation proceeds in three steps: a Gibbs-style generalized evidence built from the transport loss; a Laplace approximation; and extraction of the leading sample-size-dependent terms to obtain the BIC-style penalty.

Gibbs Evidence Motivation

To derive a principled penalty for model complexity, consider the empirical transport loss Mm(θm)M_m(\boldsymbol{\theta}_m) with parameter vector θm\boldsymbol{\theta}_m,

Mm(θm)=1nv∑i=1nvli(θm),(41)M_m(\boldsymbol{\theta}_m)=\frac{1}{n_v}\sum_{i=1}^{n_v}l_i(\boldsymbol{\theta}_m), \tag*{(41)}

where li(θm)l_i(\boldsymbol{\theta}_m) is the transport cost for validation observation ii. A Gibbs likelihood based on this loss is LG(θm)=exp⁡{−nvMm(θm)/(2τ2)}L_G(\boldsymbol{\theta}_m)=\exp\{-n_vM_m(\boldsymbol{\theta}_m)/(2\tau^2)\}, with scale parameter τ2>0\tau^2>0, and the corresponding generalized evidence is

Gm=∫exp⁡{−nv2τ2Mm(θm)}p(θm∣m) dθm,(42)G_m=\int\exp\left\{-\frac{n_v}{2\tau^2}M_m(\boldsymbol{\theta}_m)\right\}p(\boldsymbol{\theta}_m\mid m)\,\mathrm{d}\boldsymbol{\theta}_m, \tag*{(42)}

where p(θm∣m)p(\boldsymbol{\theta}_m\mid m) denotes the prior density on θm\boldsymbol{\theta}_m under model mm. By analogy with classical Bayesian model selection, −2log⁡Gm-2\log G_m will play the role of an information criterion; the NFIC arises by approximating this quantity in the large-nvn_v regime.

Choice of the temperature parameter. The parameter τ2\tau^2 acts as a temperature in the Gibbs likelihood, controlling concentration around θ^m\widehat{\boldsymbol{\theta}}_m without changing the transport-loss minimizer. To simplify (42), set τ2=1\tau^2=1 because a common positive scaling does not affect model rankings. This choice yields the standard BIC-like penalty log⁡nv/nv\log n_v/n_v. τ2\tau^2 only temporarily written to show its role in the Laplace approximation.

Laplace Approximation

To extract a tractable expression for GmG_m, apply a Laplace approximation around the transport-loss minimizer θ^m=arg⁡min⁡θmMm(θm)\widehat{\boldsymbol{\theta}}_m=\arg\min_{\boldsymbol{\theta}_m}M_m(\boldsymbol{\theta}_m), and let Am=∇2Mm(θ^m)A_m=\nabla^2M_m(\widehat{\boldsymbol{\theta}}_m) denote the Hessian at the minimum. A second-order Taylor expansion gives

Mm(θm)≈Mm(θ^m)+12(θm−θ^m)′Am(θm−θ^m),(43)M_m(\boldsymbol{\theta}_m)\approx M_m(\widehat{\boldsymbol{\theta}}_m)+\frac{1}{2}(\boldsymbol{\theta}_m-\widehat{\boldsymbol{\theta}}_m)^\prime A_m(\boldsymbol{\theta}_m-\widehat{\boldsymbol{\theta}}_m), \tag*{(43)}

which isolates the optimized transport loss Mm(θ^m)M_m(\widehat{\boldsymbol{\theta}}_m): the term that will survive as the data-fit component of the NFIC. Substituting into the generalized evidence yields

Gm≈∫exp⁡{−nv2τ2[Mm(θ^m)+12(θm−θ^m)′Am(θm−θ^m)]}p(θm∣m) dθm.(44)G_m\approx\int\exp\left\{-\frac{n_v}{2\tau^2}\left[M_m(\widehat{\boldsymbol{\theta}}_m)+\frac{1}{2}(\boldsymbol{\theta}_m-\widehat{\boldsymbol{\theta}}_m)^\prime A_m(\boldsymbol{\theta}_m-\widehat{\boldsymbol{\theta}}_m)\right]\right\}p(\boldsymbol{\theta}_m\mid m)\,\mathrm{d}\boldsymbol{\theta}_m. \tag*{(44)}

Assuming p(θm∣m)p(\boldsymbol{\theta}_m\mid m) is smooth and positive in a neighborhood of θ^m\widehat{\boldsymbol{\theta}}_m, approximate p(θm∣m)≈p(θ^m∣m)p(\boldsymbol{\theta}_m\mid m)\approx p(\widehat{\boldsymbol{\theta}}_m\mid m) and pull the prior outside the integral, so that

Gm≈exp⁡{−nv2τ2Mm(θ^m)}p(θ^m∣m)∫exp⁡{−nv4τ2(θm−θ^m)′Am(θm−θ^m)} dθm.(45)G_m\approx\exp\left\{-\frac{n_v}{2\tau^2}M_m(\widehat{\boldsymbol{\theta}}_m)\right\}p(\widehat{\boldsymbol{\theta}}_m\mid m)\int\exp\left\{-\frac{n_v}{4\tau^2}(\boldsymbol{\theta}_m-\widehat{\boldsymbol{\theta}}_m)^\prime A_m(\boldsymbol{\theta}_m-\widehat{\boldsymbol{\theta}}_m)\right\}\,\mathrm{d}\boldsymbol{\theta}_m. \tag*{(45)}

The remaining integral is Gaussian in θm\theta_m and captures the local curvature of the transport loss around θ^m\hat{\theta}_m. Here, the number of mixture parameters, KmK_m, enters because the integral is taken over a KmK_m-dimensional parameter space. For any positive-definite Km×KmK_m \times K_m matrix BmB_m,

∫exp⁡{−12u′Bmu} du=(2π)Km/2∣Bm∣−1/2.(46)\int\exp\left\{-\frac{1}{2}\mathbf{u}^{\prime}B_m\mathbf{u}\right\}\,\mathrm{d}\mathbf{u}=(2\pi)^{K_m/2}\lvert B_m\rvert^{-1/2}. \tag*{(46)}

In the Laplace approximation, the precision matrix is

Bm=nv2τ2Am,(47)B_m=\frac{n_v}{2\tau^2}A_m, \tag*{(47)}

where AmA_m is the Hessian of the transport loss at θ^m\hat{\theta}_m. Therefore,

∫exp⁡{−nv4τ2(θm−θ^m)′Am(θm−θ^m)} dθm=(2π)Km/2∣nv2τ2Am∣−1/2(48)\int\exp\left\{-\frac{n_v}{4\tau^2}(\theta_m-\hat{\theta}_m)^{\prime}A_m(\theta_m-\hat{\theta}_m)\right\}\,\mathrm{d}\theta_m=(2\pi)^{K_m/2}\left\lvert\frac{n_v}{2\tau^2}A_m\right\rvert^{-1/2} \tag*{(48)}
=(2π)Km/2(nv2τ2)−Km/2∣Am∣−1/2,(49)=(2\pi)^{K_m/2}\left(\frac{n_v}{2\tau^2}\right)^{-K_m/2}\lvert A_m\rvert^{-1/2}, \tag*{(49)}

which leaves us with,

Gm≈exp⁡{−nv2τ2Mm(θ^m)}p(θ^m∣m)(2π)Km/2(nv2τ2)−Km/2∣Am∣−1/2.(50)G_m\approx\exp\left\{-\frac{n_v}{2\tau^2}M_m(\hat{\theta}_m)\right\}p(\hat{\theta}_m\mid m)(2\pi)^{K_m/2}\left(\frac{n_v}{2\tau^2}\right)^{-K_m/2}\lvert A_m\rvert^{-1/2}. \tag*{(50)}

Asymptotic Form

To isolate the NFIC penalty, extract the leading terms in nvn_v. Taking logarithms gives

log⁡Gm≈−nv2τ2Mm(θ^m)+log⁡p(θ^m∣m)+Km2log⁡(2π)−Km2log⁡(nv2τ2)−12log⁡∣Am∣.(51)\log G_m\approx-\frac{n_v}{2\tau^2}M_m(\hat{\theta}_m)+\log p(\hat{\theta}_m\mid m)+\frac{K_m}{2}\log(2\pi)-\frac{K_m}{2}\log\left(\frac{n_v}{2\tau^2}\right)-\frac{1}{2}\log\lvert A_m\rvert. \tag*{(51)}

The first term scales linearly in nvn_v and the fourth scales as Kmlog⁡nvK_m\log n_v; the remaining terms are bounded as nv→∞n_v\to\infty. Retaining only sample-size-dependent terms yields

−2log⁡Gm≈nvτ2Mm(θ^m)+Kmlog⁡nv+O(1),(52)-2\log G_m\approx\frac{n_v}{\tau^2}M_m(\hat{\theta}_m)+K_m\log n_v+O(1), \tag*{(52)}

which already exhibits the BIC-like trade-off between fit and complexity that underpins the NFIC. Dividing by nvn_v produces the per-observation form

−2τ2nvlog⁡Gm≈Mm(θ^m)+τ2Kmlog⁡nvnv+O(1nv).(53)-\frac{2\tau^2}{n_v}\log G_m\approx M_m(\hat{\theta}_m)+\tau^2\frac{K_m\log n_v}{n_v}+O\left(\frac{1}{n_v}\right). \tag*{(53)}

At this point the role of τ2\tau^2 is fully transparent: it multiplies the penalty term but does not interact with the parameter dimension KmK_m, the sample size nvn_v, or the optimized transport loss Mm(θ^m)M_m(\hat{\theta}_m). Setting τ2=1\tau^2=1, as motivated above, yields,

−2nvlog⁡Gm≈Mm(θ^m)+Kmlog⁡nvnv+O(1nv),(54)-\frac{2}{n_v}\log G_m\approx M_m(\hat{\theta}_m)+\frac{K_m\log n_v}{n_v}+O\left(\frac{1}{n_v}\right), \tag*{(54)}

in which the data-fit term and the penalty Kmlog⁡nv/nvK_m\log n_v/n_v stand on equal footing, exactly the structure carried forward into the NFIC.

The NFIC Criterion

Dropping the asymptotically negligible O(1/nv)O(1/n_v) remainder, the unit-temperature per-observation expression above defines the criterion

NFICm=Mm+ρKm,ρ=log⁡nvnv.(55)\mathrm{NFIC}_m=M_m+\rho K_m,\qquad\rho=\frac{\log n_v}{n_v}. \tag*{(55)}

Thus the NFIC inherits its goodness-of-fit term directly from the optimized transport loss in the Gibbs evidence, while its penalty ρKm\rho K_m arises from the Laplace-approximation determinant factor evaluated at unit temperature.

Distribution of $X$ with complex data topology

Figure 1. Distribution of XX with complex data topology

It remains to specialize KmK_m to the present model class. For a diagonal Gaussian mixture base with PmP_m components in pp dimensions, the number of free base-distribution parameters is

Km=Pmp⏟means+Pmp⏟scales+(Pm−1)⏟free weights=2Pmp+(Pm−1).(56)K_m = \underbrace{P_m p}_{\text{means}} + \underbrace{P_m p}_{\text{scales}} + \underbrace{(P_m - 1)}_{\text{free weights}} = 2P_m p + (P_m - 1). \tag*{(56)}

Combining this parameter count with the empirical squared-error transport distance Mm=nv−1∑i=1nv∥vi−zim∥22M_m = n_v^{-1} \sum_{i=1}^{n_v} \lVert\mathbf{v}_i - \mathbf{z}_{im} \rVert_2^2 gives the final operational form of the criterion,

NFIC⁡m=1nv∑i=1nv∥vi−zim∥22+log⁡nvnv{2Pmp+(Pm−1)},(57)\operatorname{NFIC}_m = \frac{1}{n_v}\sum_{i=1}^{n_v}\lVert\mathbf{v}_i - \mathbf{z}_{im}\rVert_2^2 + \frac{\log n_v}{n_v}\left\{2P_m p + (P_m - 1)\right\}, \tag*{(57)}

which is evaluated for each candidate model that survived the goodness-of-fit tests; the model attaining the smallest NFIC⁡m\operatorname{NFIC}_m is selected.

Demonstrations of Flexible Normalizing Flow Base Distributions

Jones and Campbell [ [9] demonstrate that the NF transformation used in the original IOM is appropriately stable with respect to random initialization, sampling variability, and network architecture, supporting its use as a robust change-of-measure technique for inference. Building on these results, we examine whether additional flexibility in the latent base distribution can improve the transformation when the underlying data topology is more complex. In particular, we show that for certain multimodal structures, a bimodal Gaussian base distribution provides a better representation than a unimodal alternative, as determined by the NFIC.

Consider a random sample, X1,…,X1000X_1, \ldots, X_{1000}, drawn from the following distribution,

Xi=Zi+0.500sin⁡(1.40Zi)+0.150sin⁡(3Zi)(58)X_i = Z_i + 0.500\sin(1.40Z_i) + 0.150\sin(3Z_i) \tag*{(58)}

where

Zi∼0.600 N(−3.20,0.5502)+0.400 N(2.80,1.252).(59)Z_i \sim0.600\,\mathcal{N}(-3.20, 0.550^2) + 0.400\,\mathcal{N}(2.80, 1.25^2). \tag*{(59)}

The NF was fitted using Neural Spline Flow (NSF) [5] with three different Gaussian mixtures: unimodal (Figure 2), bimodal (Figure 3) and trimodal (Figure 4). Across all mixtures the learning rate (0.000300), the number of epochs (1000), the validation split (80/20), the tail bound (8) and ability to train base parameters (True) are kept constant. The confidence level for the Jarque-Bera tests was set to be 0.01, the Stouffer test to be 0.05 and the final Cramér-von Mises (CvM) test to be 0.05. The data is centered to have a zero mean but not scaled to be of unit variance. This means that the tail bound parameter and number of bins parameter need to be adjusted to account for the non-unit variance and the wigglyness of the mixtures. They are chosen so that the data does not reject the distribution checks and are regularized by the λ\lambda parameter. The parameter specification and test results are shown in Table 1.

UnimodalBimodalTrimodal
μi\mu_i0.0353{−2.99,3.08}\{-2.99, 3.08\}{−5.71,−0.0263,5.92}\{-5.71, -0.0263, 5.92\}
σi\sigma_i1.03{0.938,1.13}\{0.938, 1.13\}{1.11,0.953,0.933}\{1.11, 0.953, 0.933\}
wkw_k1{0.597,0.403}\{0.597, 0.403\}{0.241,0.385,0.374}\{0.241, 0.385, 0.374\}
Transformations1068
Hidden units1068
Hidden layers222
Number of bins201432
λ\lambda0.006700.01310.0256
p^JB\hat{p}_{\mathrm{JB}}0.0833{0.998,0.0162}\{0.998, 0.0162\}{0.0972,0.963,0.291}\{0.0972, 0.963, 0.291\}
p^St\hat{p}_{\mathrm{St}}0.08330.6910.486
p^CvM\hat{p}_{\mathrm{CvM}}0.8800.7100.338
NFIC4.782.608.73

Table 1. Parameter values, pp-values and NFIC for the three mixture distributions.

Unimodal base after inverse transformationTransformed $\chi^2$ distributionQQ plot of transformed $\chi^2$ distribution

Figure 2. Unimodal base distribution

Bimodal base after inverse transformationTransformed $\chi^2$ distributionQQ plot of transformed $\chi^2$ distribution

Figure 3. (a) Bimodal base after inverse transformation (b) Transformed χ2\chi^2 distribution (c) QQ plot of transformed χ2\chi^2 distribution. Figure 3: Bimodal base distribution

Trimodal base after inverse transformationTransformed $\chi^2$ distributionQQ plot of transformed $\chi^2$ distribution

Figure 4. (a) Trimodal base after inverse transformation (b) Transformed χ2\chi^2 distribution (c) QQ plot of transformed χ2\chi^2 distribution. Figure 4: Trimodal base distribution

Table 1, Figure 2 through 4, as well as the Stouffer pp-value show that the modes are well separated and there is no reason to reject normality for each mode. The final CvM test and QQ plot do not reject the χ12\chi^2_1 fit. The NFIC strongly favours the bimodal specification: The bimodal model has the lowest NFIC value, 2.60, compared with 4.78 for the unimodal model and 8.73 for the trimodal model. Since lower NFIC values indicate a more favourable balance of transport simplicity and base-distribution parsimony among likelihood-competitive models, the bimodal specification is selected by the proposed criterion.

Example

This example demonstrates the MEIOM in a controlled hierarchical setting where influential observations are introduced at both the student and school levels. A mixed-effects data-generating process is constructed with known student- and school-level outliers and a bimodal residual distribution, allowing us to evaluate both the hierarchical extension of the IOM and the more flexible NF base distributions developed above. First one can compare the identified influential observations with classical fixed- and random-effects Cook’s distance and then apply the MEIOM using both a linear MEM and a Mixed Effects Random Forest (MERF).

Data Generation

A hierarchical dataset is generated with nsch=100n_{\mathrm{sch}} = 100 schools and nstu=30n_{\mathrm{stu}} = 30 students per school, for a total of n=nsch×nstun = n_{\mathrm{sch}} \times n_{\mathrm{stu}} observations. Each student ii belongs to a school j∈{1,…,100}j \in\{1, \ldots, 100\}.

Predictors. Each student has two predictors. The first predictor xijx_{ij} is drawn from a Gaussian distribution:

xi∼N(0,1);(60)x_i \sim\mathcal{N}(0,1); \tag*{(60)}

the school level predictor is constructed similarly:

wj∼N(0,1).(61)w_j \sim\mathcal{N}(0,1). \tag*{(61)}

Random intercepts. Schools are assigned random intercepts:

bj∼N(0,1).(62)b_j \sim\mathcal{N}(0,1). \tag*{(62)}

Bimodal residual distribution. Idiosyncratic errors εij\varepsilon_{ij} are drawn from a two-component Gaussian mixture:

εij∼0.600N(3,1.202)+0.400N(−3,1.202).(63)\varepsilon_{ij} \sim0.600\mathcal{N}(3,1.20^2) + 0.400\mathcal{N}(-3,1.20^2). \tag*{(63)}

Outcome model. The outcome is generated using a linear mixed-effects structure:

yij=2+1.50xij+0.750wj+bj+εij.(64)y_{ij} = 2 + 1.50x_{ij} + 0.750w_j + b_j + \varepsilon_{ij}. \tag*{(64)}

School-level outliers. Designate nsch,out=5n_{\mathrm{sch,out}} = 5 schools as outlier schools, selected randomly without replacement. For each outlier school s∈Souts \in S_{\mathrm{out}}, the random intercept is augmented with with the addition of the following vector

bj=[2, 4, 6, 8, 10]′for each s∈Sout respectively.(65)b_j = [2,\,4,\,6,\,8,\,10]^{\prime} \quad\text{for each } s \in S_{\mathrm{out}} \text{ respectively}. \tag*{(65)}

Given the standard normal distribution of bjb_j we expect that bj=2b_j = 2 will not be identified by the MEIOM whereas bj=4b_j = 4 may be identified and bj=6,8,10b_j = 6, 8, 10 should be identified. The school-level variable ww is also set at the following

wj=4for all s∈Sout.(66)w_j = 4 \quad\text{for all } s \in S_{\mathrm{out}}. \tag*{(66)}

Student-level outliers. Introduce nstu,out=3n_{\mathrm{stu,out}} = 3 student-level outliers, sampled only from non-outlier schools. For each selected student r∈Ioutr \in\mathcal{I}_{\mathrm{out}}, overwrite both predictor and outcome values:

xij=4,yij=16,for all r∈Iout.(67)x_{ij} = 4,\quad y_{ij} = 16,\quad\text{for all } r \in\mathcal{I}_{\mathrm{out}}. \tag*{(67)}

Final output. This design produces a challenging DGP with cluster-level contamination, observation-level contamination, and a bimodal residual distribution. Figure 5 plots the distribution of the outcome variable.

Distribution of the outcome variable with and outliers, and bimodal residuals.

Figure 5. Distribution of the outcome variable with and outliers, and bimodal residuals.

Cook’s distance

As a comparison, the linear mixed effects model (7) is fitted to the data generated in § 8.1. The labeled outlier students are Iout={1028,1602,451}\mathcal{I}_{\mathrm{out}} = \{1028, 1602, 451\} whereas the labeled outlier schools are Sout={90,18,60,94,67}\mathcal{S}_{\mathrm{out}} = \{90, 18, 60, 94, 67\}.

Employing the rule-of-thumb cutoff for Cook’s distance [2] of 4/nstu4/n_{\mathrm{stu}} as well as 4/nsch4/n_{\mathrm{sch}} for determining if a observation is influential due to the fact that the χ2\chi^2 reference distributions are too conservative. From Figure 6a, the three student outliers are flagged by the fixed-effects Cook’s distance. However, many other students are flagged as well (28 in total), indicating that a more conservative cutoff could be used [10]; however for consistency we choose the same cutoff for all metrics. From Figure 6b three schools of the five are correctly identified for fixed-effects Cook’s distance. This is expected due to some outlier schools are not as extreme as others. For the random-effects Cook’s distance (Figure 7a) no student outliers are identified due to the fact that the students shouldn’t have much of an effect on σb2\sigma_b^2 and it may be difficult to have an effect on σ2\sigma^2. Similarly, only one school is identified for random-effects Cook’s distance (Figure 7b).

Influential students and schools based on fixed-effects Cook’s distance

Figure 6. (a) Influential students based on fixed-effects Cook’s distance with green line as the rule-of-thumb cutoff. (b) Influential schools based on fixed-effects Cook’s distance with green line as the rule-of-thumb cutoff.

Influential students based on random-effects Cook’s distance

(a) Influential students based on random-effects Cook’s distance with green line as the rule-of-thumb cutoff.

Influential schools based on random-effects Cook’s distance

(b) Influential schools based on random-effects Cook’s distance with green line as the rule-of-thumb cutoff.

Figure 7. Cook’s distance based on random effects

Linear MEIOM

The Linear MEIOM for both the student-level and school-level hierarchies is computed with confidence levels for the Jarque-Bera tests set to 0.01, the Stouffer test set to 0.05 and the final Cramér-von Mises (CvM) test set to 0.05. The lower confidence levels for the Jarque-Bera test are used so that it is harder to reject per mode normality while overall, the normality and χ2\chi^2 tests are easier to reject. These values will be used throughout the paper.

Student level

Figure 8 plots the SHAP values and residuals for the student-level covariate and the student-level residuals. The SHAP values appear more unimodal compared with the more bimodal appearance from the residuals. Table 2 presents the parameters and results for the SHAP values and residuals. The regularization parameter λ\lambda is selected so that there is no reason to reject the goodness-of-fit tests. The NFIC selects the unimodal mixture for the SHAP values (0.897) and the bimodal mixture for the residuals (2.23). From Figure 9 the three student outliers are identified; however, note that a more conservative cutoff should also be used because 41 outliers are also identified at the α=0.01\alpha= 0.01 confidence level.

Student-level SHAP values

(a) Student-level SHAP values

Student-level residuals

(b) Student-level residuals

Figure 8. Distributions of linear student-level SHAP values and residuals.

SHAP UnimodalSHAP BimodalResidual UnimodalResidual Bimodal
μi\mu_i0.0789{−2.97,2.97}\{-2.97,2.97\}-0.000800{−3.29,3.36}\{-3.29,3.36\}
σi\sigma_i1.05{1.02,1.02}\{1.02,1.02\}1.03{1.14,1.14}\{1.14,1.14\}
wkw_k1{0.478,0.522}\{0.478,0.522\}1{0.418,0.582}\{0.418,0.582\}
Transformations66124
Hidden units66124
Hidden layers2222
Epochs50050010001000
Tail bound771010
Number of bins814816
λ\lambda0.09700.04980.025614.4
p^JB\hat{p}_{\mathrm{JB}}0.840{0.0366,0.233}\{0.0366,0.233\}0.875{0.347,0.0271}\{0.347,0.0271\}
p^St\hat{p}_{\mathrm{St}}0.8400.03740.8750.0506
p^CvM\hat{p}_{\mathrm{CvM}}0.2690.9260.7790.714
NFIC0.8974.824.972.23

Table 2. Parameter values, pp-values and NFIC for the linear unimodal and bimodal SHAP values and residuals.

Linear student-level MEIOM plot

Figure 9. Linear student-level MEIOM where green and red lines represent the α=0.05\alpha= 0.05 and α=0.01\alpha= 0.01 cut-offs.

School level

Fit the school-level linear MEIOM. Figure 10 plots the SHAP values and residuals for the school-level covariate and the school-level residuals. Table 3 presents the parameters and results for the SHAP values and residuals. The regularization parameter λ\lambda is selected so that there is no reason to reject the goodness-of-fit tests. Note that the bimodal mixture was not considered due to the small sample size which results in the movement to a single mode. From Figure 15, three of the 5 outliers are identified at the α=0.01\alpha= 0.01 confidence level (ξ1,0.01=13.0\xi_{1,0.01} = 13.0) with the more egregious ones having a higher MEIOM score.

Distributions of linear school-level SHAP values and residuals

Figure 10. Distributions of linear school-level SHAP values and residuals.

SHAP UnimodalResidual Unimodal
μi\mu_i0.03180.0680
σi\sigma_i1.081.10
wkw_k11
Transformations66
Hidden units66
Hidden layers22
Epochs500500
Tail bound67
Number of bins1210
λ\lambda1.4076.2
p^JB\hat{p}_{\mathrm{JB}}0.3250.0663
p^St\hat{p}_{\mathrm{St}}0.3250.0663
p^CvM\hat{p}_{\mathrm{CvM}}0.1340.553

Table 3. Parameter values and pp-values for the linear unimodal SHAP values and residuals.

MERF school-level MEIOM

Figure 15. MERF school-level MEIOM where green and red lines represent the α=0.05\alpha= 0.05 and α=0.01\alpha= 0.01 cut-offs.

Mixed Effect Random Forest MEIOM

In this section, MERF MEIOM is calculated for both the student-level and school-level hierarchies using the same dataset from the generated example.

Student level

Figure 12 plots the SHAP values and residuals for the student-level covariate and the student-level residuals. Clearly, the SHAP values appear more unimodal compared with the more bimodal appearance from the residuals. Table 4 presents the parameters and results for the SHAP values and residuals. The regularization parameter λ\lambda is selected so that there is no reason to reject the goodness-of-fit tests. The NFIC selects the unimodal mixture for the SHAP values (0.896) and the bimodal mixture for the residuals (3.43). From Figure 13 the three student outliers are identified; however, a more conservative cutoff could also be used because 28 plus 9 additional outliers are also identified at the α=0.01\alpha= 0.01 confidence level. There also appears to be two extra outliers with high MEIOM which is different from the linear fit: the higher one corresponding to a outlier that has a large transformed residual and the other one has both a high transformed SHAP value and large transformed residual.

Student-level SHAP values and residual distributions

Figure 12. Distributions of MERF student-level SHAP values and residuals.

SHAP UnimodalSHAP BimodalResidual UnimodalResidual Bimodal
μi\mu_i0.00740{−2.95,2.95}\{-2.95, 2.95\}0.00980{−3.97,3.98}\{-3.97, 3.98\}
σi\sigma_i1.01{0.998,0.997}\{0.998, 0.997\}1.01{1.08,1.10}\{1.08, 1.10\}
wkw_k1{0.504,0.496}\{0.504, 0.496\}1{0.419,0.581}\{0.419, 0.581\}
Transformations66126
Hidden units66126
Hidden layers4422
Epochs500100010001000
Tail bound461313
Number of bins24323232
λ\lambda0.09700.02560.000.717
p^JB\hat{p}_{\mathrm{JB}}0.119{0.467,0.354}\{0.467, 0.354\}0.143{0.466,0.169}\{0.466, 0.169\}
p^St\hat{p}_{\mathrm{St}}0.1190.3730.1430.230
p^CvM\hat{p}_{\mathrm{CvM}}0.1890.1320.9920.122
NFIC0.8965.265.213.43

Table 4. Parameter values, pp-values and NFIC for the MERF unimodal and bimodal SHAP values and residuals.

MERF student-level MEIOM

Figure 13. MERF student-level MEIOM where green and red lines represent the α=0.05\alpha= 0.05 and α=0.01\alpha= 0.01 cut-offs.

Linear school-level MEIOM plot

Figure 11. Linear school-level MEIOM where green and red lines represent the α=0.05\alpha= 0.05 and α=0.01\alpha= 0.01 cut-offs.

School level

Figure 14 plots the SHAP values and residuals for the school-level covariate and the school-level residuals. Table 5 presents the parameters and results for the SHAP values and residuals. The regularization parameter λ\lambda is selected so that there is no reason to reject the goodness-of-fit tests. Note that the bimodal mixture was not considered due to the low sample size. From Figure 15, four of the 5 outliers are identified at α=0.01\alpha= 0.01 confidence level (ξ1,0.01=13.0\xi_{1,0.01} = 13.0) the with the more egregious ones having a higher MEIOM score. Note that outlier 18 is identified in this model and is not in the linear fit. Also, one extra outlier gets marginally identified at the 0.01 level due to both a moderately high transformed SHAP value and transformed residual.

School-level SHAP values

(a) School-level SHAP values

School-level residuals

(b) School-level residuals

Figure 14. Distributions of MERF school-level SHAP values and residuals.

SHAP UnimodalResidual Unimodal
μi\mu_i0.05340.133
σi\sigma_i1.041.13
wkw_k11
Transformations44
Hidden units44
Hidden layers22
Epochs500500
Tail bound96
Number of bins328
λ\lambda0.0970403
p^JB\hat{p}_{\mathrm{JB}}0.1410.326
p^St\hat{p}_{\mathrm{St}}0.1410.326
p^CvM\hat{p}_{\mathrm{CvM}}0.9870.642

Table 5. Parameter values and pp-values for the MERF unimodal school SHAP values and residuals.

Application

The Programme for International Student Assessment2 is a large-scale international assessment conducted by the OECD to evaluate the skills of approximately 15-year-old students across participating countries and economies. PISA focuses primarily on mathematics, reading, and science literacy, empha-

AbbreviationFull text
PHLPhilippines
SGPSingapore
ESCSIndex of economic, social and cultural status
PV1MATHMathematics score
MATHPERSEffort and persistence in mathematics
MATHEFFMathematics self-efficacy: formal and applied mathematics
PROPMATHProportion of mathematics teachers at school

caption: Abbreviations for PISA data

:::

sizing students’ ability to apply knowledge to real-world problems rather than simply recall curriculum content. The 2022 data set is used.

The PISA data have a hierarchical structure, with students nested within schools, making them particularly suitable for multilevel and mixed-effects analyses. In addition to achievement measures, PISA includes extensive student- and school-level background information, such as socioeconomic characteristics, attitudes toward learning, school resources, and educational practices. For this paper, consider data from Singapore (6559 students and 164 schools) and the Philippines (7167 students 188 schools). We use several abbreviations to name variables and covariates (Table 6).

Small model

The small model does not explicitly account for the country effects or school-level covariates; we assume that school-level effects will adequately describe the two countries. This omission implies that country level variability is already accounted for by the school level effects. If we are incorrect, then the bimodal MEIOM may be indicated for use. There are a total of 13726 students in 352 schools. We regress,

PV1MATHij=f(ESCSij;θsmall)+bj+εij,(68)\mathrm{PV1MATH}_{ij} = f(\mathrm{ESCS}_{ij}; \theta_{\mathrm{small}}) + b_j + \varepsilon_{ij}, \tag*{(68)}

where bjb_j is the random intercept for school jj. A MEGB model [12] is fitted using an 80/20 stratified 3-fold testing split to tune hyperparameters (32 iterations). The root mean squared error (RMSE) is 71.3 on the test set.

Student level

At the student level, there is no clear separation of the countries (Figure 16b). For the student-level SHAP values (Figure 16a), we use 13 transformations, 13 hidden units, 2 layers, a tail bound of 3, 10 bins, 1000 epochs, a unimodal base distribution with mean 0.0740, standard deviation 0.851 and tune λ=3.06×10−7\lambda= 3.06 \times10^{-7}. For the student-level residuals we use 4 transformations, 4 hidden units, 2 layers, a tail bound of 3, 8 bins, 500 epochs, a unimodal base distribution with mean −0.0952-0.0952, standard deviation 1.05 and tune λ=0.0131\lambda= 0.0131. We do not reject any of the hypothesis tests for the NF. 137 outliers are reported at the α=0.01\alpha= 0.01 (ξ1,0.01=13.0\xi_{1,0.01} = 13.0) level along with the top 5 outliers (Table 7). The transformed residuals play an important role in the identification of the first outlier while the other top four are more of a combination of the transformed SHAP value and the transformed residual.

Two histograms showing standardized SHAP values and standardized residuals

Figure 16. (a) SHAP values (standardized). (b) Residuals (standardized). Distributions of MEGB student-level SHAP values and residuals for the small model.

CountryPV1MATHESCSIOMSHAP (as a χ12\chi_1^2)Residuals (as a χ12\chi_1^2)
SGP3641.0987.46.1614.2
SGP4541.3662.97.987.88
SGP3861.3545.17.985.65
PHL524-0.89044.95.538.13
PHL498-0.73044.36.466.86

Table 7. Top 5 outlier students determined by the MEGB IOM.

School level

First, a unimodal base distribution is fit with mean 0.102, standard deviation 87.7, 2 transformations, 2 hidden units, 2 layers, a tail bound of 250, 16 bins, 500 epochs, and tune λ=0.0970\lambda= 0.0970. Next a bimodal base distribution is fit with means {−99.8,100.0}\{-99.8, 100.0\}, standard deviations {44.8,51.7}\{44.8, 51.7\}, weights {0.502,0.498}\{0.502, 0.498\}, 2 transformations, 2 hidden units, 2 layers, a tail bound of 250, 16 bins, 500 epochs, and tune λ=0.189\lambda= 0.189. The same set of previous hypothesis tests are not rejected. The unimodal NFIC is 880 whereas the bimodal NFIC is 155, clearly selecting the bimodal specification and provides evidence for a model that has latent variable structure. There is a clear separation of the countries (Figure 17). Due to the absence of school-level covariates, only the random intercept residual is used and when transformed, becomes a χ12\chi_1^2 random variable. Therefore, the cutoff is χ12(0.99)=6.63\chi_1^2(0.99) = 6.63. The two labeled outliers for the school-level are from Singapore and have very large transformed random intercepts.

Overlapping histograms of estimated random intercepts for PHL and SGP

Figure 17. Estimated random intercepts for Singapore and the Philippines.

CountryResidualsResiduals (as a χ12\chi_1^2)
SGP2528.81
SGP2407.48

Table 8. Outlier school exceeding the χ12(0.99)\chi_1^2(0.99) quantile.

Full model

The full model explicitly accounts for the country effects as both a fixed effect and as context for the NF. There are a total of 12955 students in 352 schools. The chosen covariates are described in the relation,

PV1MATHijk=f(ESCSijk,MATHPERSijk,MATHEFFijk,PROPMATHjk,Ck;θfull)+bjk+εijk,(69)\mathrm{PV1MATH}_{ijk} = f(\mathrm{ESCS}_{ijk}, \mathrm{MATHPERS}_{ijk}, \mathrm{MATHEFF}_{ijk}, \mathrm{PROPMATH}_{jk}, C_k; \theta_{\mathrm{full}}) + b_{jk} + \varepsilon_{ijk}, \tag*{(69)}

where CkC_k denotes country as a categorical fixed-effect covariate. A MEGB model is fitted and using an 80/20 stratified 3-fold testing split to tune hyperparameters (32 iterations), with 64.1 RMSE on the test set.

Student level

At the student level, the SHAP values show strong multimodality in Figure 19a but bell-shaped residuals in Figure 19b. Due to the many modes and the higher dimensionality, unimodal IOM is used on the SHAP values. In particular, we use 12 transformations, 12 hidden units, 2 layers, a tail bound of 4, 13 bins, 1000 epochs, a unimodal base distribution with mean vector [−0.0342, 0.00270, −0.0577]′[-0.0342,\ 0.00270,\ -0.0577]^{\prime}, diagonal covariance matrix diag⁡(0.9062, 0.8642, 0.8922)\operatorname{diag}(0.906^2,\ 0.864^2,\ 0.892^2) and tune λ=0.00674\lambda= 0.00674. For the student-level residuals we use 12 transformations, 12 hidden units, 3 layers, a tail bound of 5.10, 8 bins, 500 epochs, a unimodal base distribution with mean 0.00670, standard deviation 1.0335 and tune λ=3.059×10−7\lambda= 3.059 \times10^{-7}. None of the hypothesis tests for the NF are rejected. A total of 132 outliers are identified at the α=0.01\alpha= 0.01 (ξ3,0.01=28.7\xi_{3,0.01} = 28.7) with the top 5 outliers shown in Table 7. The transformed residual portion dominates the first and fifth labeled outlier whereas the transformed SHAP values play a bigger role in the second and fourth labeled outlier. The other top five outliers have a combination of transformed SHAP and residual outlying behaviour.

Distributions of MEGB school-level SHAP values and residuals

Figure 19. Distributions of MEGB school-level (marginal and standardized) SHAP values and residuals for the full model.

School level

At the school level for the full model Figure 19b does not showcase bimodality. However, some outliers reside in the tail of the distribution. The unimodal NF is used for both the school-level SHAP values and residuals. For the SHAP values (Figure 19a), we use 2 transformations, 2 hidden units, 2 layers, a tail bound of 3, 8 bins, 500 epochs, a unimodal base distribution with mean 0.000100, standard deviation 1.018 and tune λ=1010\lambda= 10^{10}3. For the student-level residuals we use 4 transformations, 4 hidden units, 2 layers, a tail bound of 5.2, 14 bins, 500 epochs, a unimodal base distribution with mean 0.133, standard deviation 1.1347 and tune λ=0.0131\lambda= 0.0131. No hypothesis tests are rejected for the NF. There are 5 outliers at the α=0.01\alpha= 0.01 confidence level (ξ1,0.01=13.0\xi_{1,0.01} = 13.0) (Table 10). At the school level, the transformed SHAP values play a large role in the outlying behaviour for the 1st and 3rd outlier schools. The second outlier school is labeled due to a larger transformed residual. The other outliers are a combination of both the transformed SHAP and residual.

CountryPROPMATHPV1MATHIOMSHAP (as a χ12\chi_1^2)Residuals (as a χ12\chi_1^2)
SGP0.13972852.110.54.98
SGP0.19639136.34.987.29
SGP0.13869926.610.72.49
SGP0.21374323.03.496.60
SGP0.19741918.74.514.14

Table 10. Outlier schools determined by the MEGB IOM full model.

Distributions of MEGB student-level SHAP values and residuals

Figure 18. Distributions of MEGB student-level (marginal and standardized) SHAP values and residuals for the full model.

CountryPV1MATHESCSMEIOMSHAP (as a χ32\chi_3^2)Residuals (as a χ12\chi_1^2)
SGP9431.111279.1713.8
SGP7221.2510922.94.74
PHL263-0.11498.212.18.12
SGP7470.90391.514.56.29
PHL201-3.1887.08.5410.2

Table 9. Top 5 outlier students determined by the MEGB IOM full model.

Conclusion

This paper extends the IOM to hierarchical data and further expands its applicability through more generalized NF transformations. The MEIOM considers clustered data by subdividing the framework into individual and group-level observations. The result combines hierarchical residual information with

level-specific SHAP values, allowing influence to be assessed at multiple levels of the data hierarchy while remaining applicable to both traditional MEMs and mixed-effects machine-learning models. This contribution facilitates identification influential individuals and also influential groups, clusters, and higher-level units that may unduly impact prediction accuracy or inference.

The restriction that the NF must map the SHAP values and residuals to a single Gaussian base distribution is relaxed. Allowing a Gaussian-mixture base distribution accommodates multimodal structures that would otherwise require a more complicated transformation to map to a unimodal reference distribution. We further introduce the Normalizing Flow Information Criterion (NFIC) to balance the complexity of the base distribution against the amount of transport required by the NF while providing a diagnostic for potential model fit challenges. In addition, conditional NFs allow available contextual information to influence the transformation while retaining a common calibrated reference distribution.

The PISA application demonstrates how the MEIOM framework can reveal model misspecification and lead to improved model understanding. When country was omitted from the smaller model, the school-level random effects displayed clear separation between Singapore and the Philippines, and the NFIC strongly favoured a bimodal rather than unimodal representation. Country was then added to the model as a fixed effect and as context within the NF, resulting in a more accurate model in terms of RMSE while also illustrating how the distributions of both student- and school-level SHAP values and residuals changed.

Although the MEIOM is developed here for random intercept MEM, the MEIOM framework should generalize beyond the two-level random-intercept setting considered here to accommodate random slopes, crossed or nested random effects, and deeper hierarchical structures. Full exploration thereof is left for future work. Additional directions for future work build on the NF extensions. First, the Gaussian-mixture formulation currently relies on sufficiently well-separated components so that observations can be assigned to a single mode and the resulting within-component Mahalanobis distances can be approximated by chi-square distributions. Future work could relax this assumption and develop inference for settings in which mixture components overlap substantially or mode assignment is uncertain. More general base distributions, including Gaussian mixtures with full covariance matrices and potentially non-Gaussian mixture components, could also be investigated. Finally, the NFIC could be extended to account for additional sources of complexity, including alternative definitions of transport cost.

References

  1. [1]Charu C. Aggarwal. An Introduction to Outlier Analysis, pages 1–34. Springer International Publishing, Cham, 2017. ISBN 978-3-319-47578-3. doi: 10.1007/978-3-319-47578-3_1. URL https://doi.org/10.1007/978-3-319-47578-3_1.
  2. [2]Galen Bollinger, David A. Belsley, Edwin Kuh, and Roy E. Welsch. Regression diagnostics: Identifying influential data and sources of collinearity. Journal of Marketing Research, 18, 1981. ISSN 00222437. doi: 10.2307/3150985.DOI
  3. [3]Ronald Christensen, Larry M Pearson, and Wesley Johnson. Case-deletion diagnostics for mixed models. Technometrics, 34(1):38–45, 1992.DOI
  4. [4]R. Dennis Cook. Detection of influential observation in linear regression. Technometrics, 19, 1977. ISSN 15372723. doi: 10.1080/00401706.1977.10489493.DOI
  5. [5]Conor Durkan, Artur Bekasov, Iain Murray, and George Papamakarios. Neural spline flows. volume 32, 2019.
  6. [6]Ahlem Hajjem, François Bellavance, and Denis Larocque. Mixed-effects random forest for clustered data. Journal of Statistical Computation and Simulation, 84(6):1313–1328, 2014.
  7. [7]James Andrew Hilden-Minton. Multilevel diagnostics for mixed and hierarchical linear models. University of California, Los Angeles, 1995.
  8. [8]Anwar H Joarder and M Hafidz Omar. On statistical characteristics of the product of two correlated chi-square variables. Journal of Applied Statistical Science, 19(4):89–101, 2011.
  9. [9]Colin C. Jones and David A. Campbell. Model-agnostic influential outlier metric. Stat, 15(3):e70163, 2026. doi: https://doi.org/10.1002/sta4.70163. URL https://onlinelibrary.wiley.com/doi/abs/10.1002/sta4.70163. e70163 sta4.70163.
  10. [10]Adam Loy and Heike Hofmann. Hlmdiag: A suite of diagnostics for hierarchical linear models in r. Journal of Statistical Software, 56:1–28, 2014.DOI
  11. [11]Scott M. Lundberg and Su In Lee. A unified approach to interpreting model predictions. volume 2017-December, 2017.arxiv.org/abs/1705.07874
  12. [12]Oyebayo Ridwan Olaniran, Saidat Fehintola Olaniran, Jeza Allohibi, Abdulmajeed Atiah Alharbi, and Nada MohammedSaeed Alharbi. Mixed effect gradient boosting for high-dimensional longitudinal data. Scientific Reports, 15(1):30927, 2025.DOI
  13. [13]George Papamakarios, Eric Nalisnick, Danilo Jimenez Rezende, Shakir Mohamed, and Balaji Lakshminarayanan. Normalizing flows for probabilistic modeling and inference. Journal of Machine Learning Research, 22, 2021. ISSN 15337928.
  14. [14]Artem Ryzhikov, Maxim Borisyak, Andrey Ustyuzhanin, and Denis Derkach. Nfad: fixing anomaly detection using normalizing flows. PeerJ Computer Science, 7:e757, 2021.DOI

Paper details

vlnc:W_srqrh5sq
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Mathematics

Not recorded for this paper

View statement
Looking for related papers…
Contents