Derivatives of the DeCovarT generative model under simplex transforms

DeCovarT maximises a Gaussian-convolution log-likelihood for cellular ratios p ∈ ΔJ − 1. This vignette derives the analytic first- and second-order derivatives used by the frequentist solvers, first with respect to unconstrained ambient proportions p, then after the isometric log-ratio (ILR) map that enforces the simplex. It closes with the expected Fisher information and the ILR delta-method covariance that feed vcov.decovart_fit() and confint.decovart_fit(). Package entry points are gradient_loglik_unconstrained(), hessian_loglik_unconstrained(), gradient_loglik_constrained(), hessian_loglik_constrained(), expected_fisher_unconstrained() and vcov_ilr_delta(). Sec. 3 compares the softmax, additive, centred and isometric log-ratio charts and explains why the solvers use ILR.

Note 1: Notation

  • Indices: gene g; cell types j, ℓ ∈ {1, …, J}; one bulk sample is fixed, so the sample index i is dropped; a, b index ILR coordinates.
  • μ ∈ ℝG × J: mean signature.
  • Σj ∈ SPD(G): cell-type covariance; Σ(p) = ∑jpj2Σj and Ω(p) = Σ(p)−1.
  • p: proportions on the open simplex (ambient score equations treat them as free coordinates in (0, 1)J).
  • ρ ∈ ℝJ − 1: unconstrained log-ratio coordinates (ILR / Helmert chart V); p = softmax (Vρ). The manuscript DAG uses the same letter for the ALR chart; here ρ denotes the ILR coordinates used by the solvers, and ρalr the ALR coordinates (Sec. 3.1).

Matrix calculus reminders

The score and Hessian of the convolution log-likelihood follow from a handful of matrix-derivative identities. The statements below mirror the matrix-calculus remarks in the manuscript Methods appendix.

Remark 1 (First-order matrix calculus). Let A = A(p) and B = B(p) be invertible matrix-valued functions of a scalar p, and let U, V be constant matrices of compatible size. Then

$$ \begin{aligned} \frac{\partial\det(\boldsymbol{A})}{\partial p} &= \det(\boldsymbol{A})\, \mathrm{tr}\!\left( \boldsymbol{A}^{-1} \frac{\partial\boldsymbol{A}}{\partial p} \right), \\ \frac{\partial(\boldsymbol{U}\boldsymbol{A}\boldsymbol{V})}{\partial p} &= \boldsymbol{U} \frac{\partial\boldsymbol{A}}{\partial p} \boldsymbol{V}, \\ \frac{\partial\boldsymbol{A}^{-1}}{\partial p} &= - \boldsymbol{A}^{-1} \frac{\partial\boldsymbol{A}}{\partial p} \boldsymbol{A}^{-1}. \end{aligned} \qquad(1)$$

The chain rule on log det  yields

$$ \frac{\partial\log\det(\boldsymbol{A})}{\partial p} = \mathrm{tr}\!\left( \boldsymbol{A}^{-1} \frac{\partial\boldsymbol{A}}{\partial p} \right), \qquad \frac{\partial\log\det(\boldsymbol{A}^{-1})}{\partial p} = - \mathrm{tr}\!\left( \boldsymbol{A}^{-1} \frac{\partial\boldsymbol{A}}{\partial p} \right). \qquad(2)$$

For a residual quadratic form with symmetric precision Ω and mean map linear in p,

$$ \frac{\partial}{\partial p} \bigl( (\boldsymbol{y}-\boldsymbol{x}p)^{\top} \boldsymbol{\Omega} (\boldsymbol{y}-\boldsymbol{x}p) \bigr) = -2\, \boldsymbol{x}^{\top} \boldsymbol{\Omega} (\boldsymbol{y}-\boldsymbol{x}p). \qquad(3)$$

Remark 2 (Second-order matrix calculus). Differentiating the inverse once more gives

$$ \frac{\partial^{2}\boldsymbol{A}^{-1}}{\partial p_{j}\partial p_{\ell}} = \boldsymbol{A}^{-1} \Biggl( \frac{\partial\boldsymbol{A}}{\partial p_{j}} \boldsymbol{A}^{-1} \frac{\partial\boldsymbol{A}}{\partial p_{\ell}} - \frac{\partial^{2}\boldsymbol{A}}{\partial p_{j}\partial p_{\ell}} + \frac{\partial\boldsymbol{A}}{\partial p_{\ell}} \boldsymbol{A}^{-1} \frac{\partial\boldsymbol{A}}{\partial p_{j}} \Biggr) \boldsymbol{A}^{-1}, \qquad(4)$$

and the trace is linear, ∂tr(A)/∂pj = tr(∂A/∂pj). Combining Eq. 1 with that linearity yields

$$ \frac{\partial^{2}\log\det(\boldsymbol{A}^{-1})}{\partial p_{j}\partial p_{\ell}} = - \mathrm{tr}\!\left[ \boldsymbol{A}^{-1} \frac{\partial^{2}\boldsymbol{A}}{\partial p_{j}\partial p_{\ell}} \right] + \mathrm{tr}\!\left[ \left( \boldsymbol{A}^{-1} \frac{\partial\boldsymbol{A}}{\partial p_{j}} \right) \left( \boldsymbol{A}^{-1} \frac{\partial\boldsymbol{A}}{\partial p_{\ell}} \right) \right]. \qquad(5)$$

Tip 2: Inner products in the score

Several terms are Ω-inner products of signature columns, μ⋅j⊤Ωμ⋅ℓ. Package helper .inner_product() evaluates that bilinear form; see also the squared Mahalanobis distance helper in the same family.

Unconstrained score and Hessian

Conditional on the reference moments ζ = (μ, {Σj}), the bulk follows y ∣ ζ, p ∼ 𝒩G(μp, Σ(p)). Up to an additive constant independent of p,

$$ \ell_{\boldsymbol{y}\mid\boldsymbol{\zeta}}(\boldsymbol{p}) = \tfrac{1}{2}\log\det\boldsymbol{\Omega}(\boldsymbol{p}) - \tfrac{1}{2} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega}(\boldsymbol{p}) (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p}). \qquad(6)$$

Important 3: The determinant term carries a factor $\tfrac{1}{2}$

Both terms of Eq. 6 are halved, because log det Ω = −log det Σ enters the Gaussian log-density as $-\tfrac{1}{2}\log\det\boldsymbol{\Sigma}(\boldsymbol{p})$. DeCovarT releases before 2.3.0 implemented −log det Σ(p), which doubled the determinant contribution. The objective was then not the stated Gaussian model, and it disagreed with the expected Fisher information of Sec. 4, which had always been the one implied by the correct density. With the factor restored, loglik_multivariate() matches mvtnorm::dmvnorm(..., log = TRUE) up to the constant $\tfrac{G}{2}\log(2\pi)$, and 𝔼[−H] = I(p) holds exactly (see Note 8). Point estimates move only slightly, because the two terms trade off differently, but likelihood values, AIC, likelihood-ratio statistics, and any curvature-based standard error do change.

Warning 4: What “unconstrained” means here

Sec. 2 treats each pj as an ambient coordinate in (0, 1) and ignores ∑jpj = 1. The resulting gradient and Hessian are the building blocks of the ILR chain rule in Sec. 3. They are not the coordinates used by Marquardt–Levenberg or Newton–Raphson in the package (those optimise in ρ-space). The box-constrained L-BFGS-B path is the exception: it works directly in p with [0, 1]J boxes and does not enforce the simplex exactly.

Applying Eq. 2 and Eq. 3 with ∂Σ/∂pj = 2pjΣj gives the ambient score.

Theorem 1 (Unconstrained gradient)

$$ \begin{aligned} \frac{\partial\ell}{\partial p_{j}} &= \underbrace{-p_{j}\,\mathrm{tr}\bigl( \boldsymbol{\Omega}\boldsymbol{\Sigma}_{j} \bigr)}_{\text{purple}} + \underbrace{ (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega} \boldsymbol{\mu}_{\cdot j} }_{\text{blue}} \\ &\quad+ \underbrace{ p_{j}\, (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega} \boldsymbol{\Sigma}_{j} \boldsymbol{\Omega} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p}) }_{\text{orange}}. \end{aligned} \qquad(7)$$

Differentiating Eq. 7 once more yields the ambient Hessian H ∈ ℳJ × J. Diagonal and off-diagonal blocks keep the same colour pairing.

Theorem 2 (Unconstrained Hessian)

For j ∈ {1, …, J},

$$ \begin{aligned} \mathbf{H}_{jj} &= \frac{\partial^{2}\ell}{\partial p_{j}^{2}} = \underbrace{ -\,\mathrm{tr}(\boldsymbol{\Omega}\boldsymbol{\Sigma}_{j}) + 2p_{j}^{2}\,\mathrm{tr}\bigl( (\boldsymbol{\Omega}\boldsymbol{\Sigma}_{j})^{2} \bigr) }_{\text{purple}} \\ &\quad \underbrace{ -2p_{j} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega} \boldsymbol{\Sigma}_{j} \boldsymbol{\Omega} \boldsymbol{\mu}_{\cdot j} - \boldsymbol{\mu}_{\cdot j}^{\top} \boldsymbol{\Omega} \boldsymbol{\mu}_{\cdot j} }_{\text{blue}} \\ &\quad \underbrace{ -2p_{j} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega} \boldsymbol{\Sigma}_{j} \boldsymbol{\Omega} \boldsymbol{\mu}_{\cdot j} - (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega} \bigl( 4p_{j}^{2}\boldsymbol{\Sigma}_{j}\boldsymbol{\Omega}\boldsymbol{\Sigma}_{j} - \boldsymbol{\Sigma}_{j} \bigr) \boldsymbol{\Omega} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p}) }_{\text{orange}}, \end{aligned} \qquad(8)$$

and for j ≠ ℓ,

$$ \begin{aligned} \mathbf{H}_{j\ell} &= \frac{\partial^{2}\ell}{\partial p_{j}\partial p_{\ell}} = \underbrace{ 2p_{j}p_{\ell}\, \mathrm{tr}\bigl( \boldsymbol{\Omega}\boldsymbol{\Sigma}_{\ell} \boldsymbol{\Omega}\boldsymbol{\Sigma}_{j} \bigr) }_{\text{purple}} \\ &\quad \underbrace{ -2p_{j} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega} \boldsymbol{\Sigma}_{j} \boldsymbol{\Omega} \boldsymbol{\mu}_{\cdot \ell} - \boldsymbol{\mu}_{\cdot j}^{\top} \boldsymbol{\Omega} \boldsymbol{\mu}_{\cdot \ell} }_{\text{blue}} \\ &\quad \underbrace{ -2p_{\ell} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega} \boldsymbol{\Sigma}_{\ell} \boldsymbol{\Omega} \boldsymbol{\mu}_{\cdot j} - 4p_{j}p_{\ell} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p})^{\top} \boldsymbol{\Omega} \boldsymbol{\Sigma}_{j} \boldsymbol{\Omega} \boldsymbol{\Sigma}_{\ell} \boldsymbol{\Omega} (\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p}) }_{\text{orange}}. \end{aligned} \qquad(9)$$

The stationary equation ∇ℓ(p) = 0 has no closed root, so DeCovarT uses iterative solvers. Analytic gradients and Hessians are checked against Richardson extrapolation in numDeriv (Gilbert and Varadhan 2019).

Constrained optimisation on the simplex

The cellular ratios satisfy pj ≥ 0 and ∑jpj = 1, the compositional or unit-simplex constraint. An optimiser can handle it in three ways: eliminate it with a reparametrisation, enforce it softly with penalties or barriers, or enforce it exactly with projections and Karush–Kuhn–Tucker (KKT) conditions. DeCovarT uses the first route: a C2 diffeomorphism from free Euclidean coordinates onto the open simplex, so every Newton step stays feasible by construction. Four such charts are common: the softmax, the additive log-ratio (ALR), the centred log-ratio (CLR) and the isometric log-ratio (ILR). This section defines the notation they share (Sec. 3.1), presents each chart (Sec. 3.2–Sec. 3.5), explains why DeCovarT uses ILR (Sec. 3.6) and compares the four side by side (Sec. 3.7). The derivatives of the ILR chart (Sec. 3.8, Sec. 3.9), their link to the Lagrangian (Sec. 3.10) and perspectives on Bayesian charts and exact zeros (Sec. 3.11) follow.

The compositional background is chapter 4 of Modelling and Analysis of Compositional Data (Pawlowsky-Glahn et al. 2015), cited below by page.

Notation for compositions and charts

Table 1: Notation for compositions and their charts.
Symbol Meaning
ΔJ − 1 = {p ∈ ℝJ : pj ≥ 0, 1JTp = 1} closed unit simplex of J cell types; its interior Δ̊J − 1 has pj > 0 for all j
1J, IJ vector of ones, identity matrix
$\mathbf{H}_{J}=\mathbf{I}_{J}-\tfrac{1}{J}\mathbf{1}_{J}\mathbf{1}_{J}^{\mathsf{T}}$ centring matrix: orthogonal projector onto 1J⟂ = {w : 1JTw = 0}
𝒞(x) = x/(1JTx) closure of a positive vector x ∈ (0, ∞)J
log p, exp z applied component by component
g(p) = (∏jpj)1/J geometric mean
softmax (z) = 𝒞(exp z) closure of exponentiated scores z ∈ ℝJ
ψ a chart: a smooth bijection from free coordinates onto Δ̊J − 1
z ∈ ℝJ, ρalr ∈ ℝJ − 1, ξ ∈ 1J⟂, ρ ∈ ℝJ − 1 softmax scores, ALR coordinates (reference J unless a superscript names it), CLR and ILR coordinates
V ∈ ℝJ × (J − 1) Helmert basis of the ILR chart (Sec. 3.5.1)
Dr ∈ ℝ(J − 1) × J ALR contrast with reference r: rows ejT − erT, j ≠ r
S(p) = diag (p) − ppT Jacobian of the softmax at p

The closure operator. 𝒞 rescales any positive vector to unit sum. It discards the total and keeps the relative sizes: 𝒞(cx) = 𝒞(x) for every c > 0. A composition is therefore an equivalence class of proportional positive vectors, and 𝒞 picks its representative on the simplex (Pawlowsky-Glahn et al. 2015, 33–35). Two consequences matter here.

  • Only scale-free functions of p are meaningful, and the log-ratios log (pj/pℓ) are the simplest. A constant added to log p does not change the composition, so every log-ratio chart must cancel the direction 1J.
  • Closure creates dependence. Library-size normalisation of counts is a closure, and it induces negative covariances between parts that need not exist in the absolute abundances.

Closure also gives the simplex a Euclidean vector-space structure, the Aitchison geometry: perturbation x ⊕ y = 𝒞(x ∘ y) plays the role of addition, powering α ⊙ x = 𝒞(xα) the role of scalar multiplication, and the inner product is ⟨x, y⟩a = clr (x)Tclr (y) (Pawlowsky-Glahn et al. 2015, Property 4.2, p. 35). The log-ratio charts below are linear maps for this structure; they differ in whether they also preserve its inner product.

Softmax and log-sum-exp

The softmax of scores z ∈ ℝJ is evaluated through the log-sum-exp (LSE) to avoid overflow,

$$ s_{j} = \frac{e^{z_{j}}}{\sum_{\ell}e^{z_{\ell}}} = e^{z_{j}-\operatorname{LSE}(\boldsymbol{z})}, \qquad \operatorname{LSE}(\boldsymbol{z}) = z_{\max}+\log\sum_{\ell}e^{z_{\ell}-z_{\max}}, \quad z_{\max}=\max_{\ell}z_{\ell}. \qquad(10)$$

Its Jacobian is Jsoftmax = S(s) = diag (s) − ssT, which is also ∇2LSE (z). The second derivative is the third-order tensor

Hjℓm = sj[(δjℓ − sℓ)(δjm − sm) − sℓ(δℓm − sm)].   (11)

The softmax with J free scores is over-parametrised: softmax (z + c1J) = softmax (z), because closure removes the common factor ec. Accordingly S(s)1J = 0, the Jacobian has rank J − 1, and the Hessian of ℓ(softmax (z)) has a zero eigenvalue along 1J: a Newton system in z is singular. The three log-ratio charts are three ways to remove this redundant direction. Each writes p = softmax (Bθ) with θ ∈ ℝJ − 1 and a matrix B ∈ ℝJ × (J − 1) whose columns, together with 1J, span ℝJ. ALR pins one score to zero, CLR constrains the scores to sum to zero, and ILR spans 1J⟂ with an orthonormal basis.

Additive log-ratio chart

Pin a reference cell type r, by default the last one (r = J). The ALR coordinates and their inverse, the additive logistic transform, are (Aitchison 1982)

$$ \rho^{\mathrm{alr}}_{j} = \log\!\left(\frac{p_{j}}{p_{J}}\right), \qquad p_{j} = \frac{e^{\rho^{\mathrm{alr}}_{j}}}{1+\sum_{\ell<J}e^{\rho^{\mathrm{alr}}_{\ell}}}\ (j<J), \qquad p_{J} = \frac{1}{1+\sum_{\ell<J}e^{\rho^{\mathrm{alr}}_{\ell}}}. \qquad(12)$$

Equivalently p = softmax (ρ1alr, …, ρJ − 1alr, 0) and ρalr = DJlog p. The “1” in the denominator is the reference part; the word additive refers to the sum of exponentials in that denominator, not to the Aitchison perturbation (Pawlowsky-Glahn et al. 2015, 47). Package helpers additive_logistic() and additive_log_ratio() implement Eq. 12 and match compositions::alrInv() / alr() with the last part as reference (van den Boogaart et al. 2025). The Jacobian is the softmax Jacobian with the reference column dropped, ∂pj/∂ρaalr = pj(δja − pa) for a = 1, …, J − 1 (jacobian_additive_logistic(); hessian_additive_logistic()).

Example 1 (ALR in both directions for p = (0.5, 0.3, 0.2))

Colours track each cell type: $\textcolor{#1d4e89}{p_{1}}$, $\textcolor{#c45c26}{p_{2}}$ and the reference $\textcolor{#7b3294}{p_{3}}$.

Forward. Each coordinate compares one cell type with the reference, so the reference enters both coordinates:

$$ \left\{ \begin{aligned} \rho^{\mathrm{alr}}_{1} &=\log\frac{\textcolor{#1d4e89}{p_{1}}}{\textcolor{#7b3294}{p_{3}}} =\log\frac{\textcolor{#1d4e89}{0.5}}{\textcolor{#7b3294}{0.2}} =\log 2.5\approx 0.916\\ \rho^{\mathrm{alr}}_{2} &=\log\frac{\textcolor{#c45c26}{p_{2}}}{\textcolor{#7b3294}{p_{3}}} =\log\frac{\textcolor{#c45c26}{0.3}}{\textcolor{#7b3294}{0.2}} =\log 1.5\approx 0.405 \end{aligned} \right. $$

Backward. Exponentiate each coordinate, give the reference the weight e0 = 1, then close; the common denominator is 1 + eρ1alr + eρ2alr = 1 + 2.5 + 1.5 = 5:

$$ \left\{ \begin{aligned} \textcolor{#1d4e89}{p_{1}} &=\frac{e^{\rho^{\mathrm{alr}}_{1}}}{1+e^{\rho^{\mathrm{alr}}_{1}}+e^{\rho^{\mathrm{alr}}_{2}}} =\frac{\textcolor{#1d4e89}{2.5}}{5} =\textcolor{#1d4e89}{0.5}\\ \textcolor{#c45c26}{p_{2}} &=\frac{e^{\rho^{\mathrm{alr}}_{2}}}{1+e^{\rho^{\mathrm{alr}}_{1}}+e^{\rho^{\mathrm{alr}}_{2}}} =\frac{\textcolor{#c45c26}{1.5}}{5} =\textcolor{#c45c26}{0.3}\\ \textcolor{#7b3294}{p_{3}} &=\frac{1}{1+e^{\rho^{\mathrm{alr}}_{1}}+e^{\rho^{\mathrm{alr}}_{2}}} =\frac{\textcolor{#7b3294}{1}}{5} =\textcolor{#7b3294}{0.2} \end{aligned} \right. $$

Changing the reference. With $\textcolor{#1d4e89}{p_{1}}$ as reference (superscript 1), $\rho^{\mathrm{alr},1}_{1}=\log(\textcolor{#c45c26}{p_{2}}/\textcolor{#1d4e89}{p_{1}})\approx-0.511$ and $\rho^{\mathrm{alr},1}_{2}=\log(\textcolor{#7b3294}{p_{3}}/\textcolor{#1d4e89}{p_{1}})\approx-0.916$, that is ρ1alr, 1 = ρ2alr − ρ1alr and ρ2alr, 1 = −ρ1alr. The two charts are related by the matrix $\bigl(\begin{smallmatrix}-1&1\\-1&0\end{smallmatrix}\bigr)$, which is invertible but not orthogonal: its singular values are 1.618 and 0.618, so it stretches some directions 2.6 times more than others.

What the reference changes, and what it does not. All ALR charts describe the same family of compositions; only the coordinates differ. Sec. 3.6 shows that the estimate $\hat{\boldsymbol{p}}$, the maximised log-likelihood and the delta-method covariance of $\hat{\boldsymbol{p}}$ do not depend on the reference. The numerical geometry does: ALR coordinates refer to an oblique, non-orthogonal basis of the simplex (Pawlowsky-Glahn et al. 2015, 47), so Euclidean lengths, angles and Hessian condition numbers in ρalr change with the reference.

Centred log-ratio coefficients

The CLR transform divides each part by the geometric mean (Aitchison 1982):

$$ \boldsymbol{\xi} = \operatorname{clr}(\boldsymbol{p}) = \log\frac{\boldsymbol{p}}{g(\boldsymbol{p})} = \mathbf{H}_{J}\log\boldsymbol{p}, \qquad \boldsymbol{p} = \mathcal{C}(\exp\boldsymbol{\xi}) = \operatorname{softmax}(\boldsymbol{\xi}). \qquad(13)$$

CLR treats every cell type symmetrically and preserves the Aitchison geometry: distances and inner products between compositions equal Euclidean ones between their CLR vectors (Pawlowsky-Glahn et al. 2015, Property 4.2, p. 35). Pairwise log-ratios are differences, log (pj/pℓ) = ξj − ξℓ. The price is a constraint on the coefficients: 1JTξ = 0. CLR gives J coefficients for J − 1 degrees of freedom, so they are not coordinates in a basis, a random CLR vector has a singular covariance matrix, and the coefficients change when a subcomposition is analysed (Pawlowsky-Glahn et al. 2015, 34–35). Optimising over a free ξ ∈ ℝJ is the over-parametrised softmax of Sec. 3.2 again.

CLR is nevertheless the hub between the other charts. Since Dr1J = 0 and VT1J = 0, both ALR and ILR are linear images of CLR: ρalr = Drξ and ρ = VTξ.

Isometric log-ratio chart

ILR expresses ξ in an orthonormal basis of the hyperplane 1J⟂ (Egozcue et al. 2003). Choose V ∈ ℝJ × (J − 1) with

VTV = IJ − 1,   VT1J = 0,   VVT = HJ.   (14)

ILR coordinates and their inverse are (Pawlowsky-Glahn and Buccianti 2011)

ρ = VTlog p = VTclr (p),   p = softmax (Vρ) = 𝒞{exp (Vρ)}.   (15)

In the book’s notation the contrast matrix is Ψ = VT, and Eq. 14 is its Eq. (4.5); Eq. 15 is Eqs. (4.7)–(4.8) (Pawlowsky-Glahn et al. 2015, 36–37). ILR keeps the strengths of both previous charts: like ALR it gives J − 1 unconstrained coordinates, and like CLR it preserves the Aitchison geometry, now with da(x, y) = ‖ilr (x) − ilr (y)‖ (Property 4.5, p. 37). No cell type is a reference. Package helpers helmert_basis(), isometric_logistic() and isometric_log_ratio() implement Eq. 14–Eq. 15 with a log-sum-exp softmax, matching the compositions::ilr() / ilrInv() convention on a Helmert basis (van den Boogaart et al. 2025).

The Helmert basis: definition, role and use

Definition. The ILR chart needs one orthonormal basis of 1J⟂; there are infinitely many. The Helmert basis is the one with a closed form. Column k = 1, …, J − 1 of helmert_basis() is

$$ \boldsymbol{v}_{k} = \frac{1}{\sqrt{k(k+1)}} \bigl(\underbrace{1,\ldots,1}_{k},\,-k,\,\underbrace{0,\ldots,0}_{J-k-1}\bigr)^{\mathsf{T}}. \qquad(16)$$

Each column sums to zero and has unit norm, and two columns are orthogonal because the later one is constant on the support of the earlier one. The basis is the Gram–Schmidt orthonormalisation of the generating system of the simplex (Egozcue et al. 2003), and its contrast matrix is a Helmert matrix without the constant row (Pawlowsky-Glahn et al. 2015, Example 4.6, p. 40). The book lists the same basis in reverse order, with the first coordinate contrasting the first J − 1 parts with the last one.

Role: every coordinate is a balance. Inserting Eq. 16 into Eq. 15 gives

$$ \rho_{k} = \boldsymbol{v}_{k}^{\mathsf{T}}\log\boldsymbol{p} = \sqrt{\frac{k}{k+1}}\, \log\frac{g(p_{1},\ldots,p_{k})}{p_{k+1}}, \qquad(17)$$

the normalised log-ratio between the geometric mean of the first k cell types and type k + 1. This is the balance of a sequential binary partition: level k splits {1, …, k + 1} into {1, …, k} (sign +) and {k + 1} (sign −) (Pawlowsky-Glahn et al. 2015, Eq. (4.9), pp. 38–39). For J = 4 the sign matrix is

Table 2: Sequential binary partition encoded by the Helmert basis for J = 4.
Level p1 p2 p3 p4
ρ1 + − 0 0
ρ2 + + − 0
ρ3 + + + −

The factor $\sqrt{k/(k+1)}$ makes balances comparable across levels. Balances are geometrically orthogonal, so each carries information the others do not; geometric orthogonality does not imply that their estimates are uncorrelated (Pawlowsky-Glahn et al. 2015, 41). The Helmert basis thus does three jobs at once:

  • it cancels the closure direction, because every column sums to zero: adding a constant to log p leaves ρ unchanged;
  • it removes the redundant softmax direction while keeping Euclidean geometry, because the columns are orthonormal;
  • it is explicit and sparse, so Vρ costs O(J) operations per column and needs no QR or Gram–Schmidt step at run time.

Use in practice. DeCovarT builds V once from J and proceeds as follows.

  1. Map a starting composition to coordinates with isometric_log_ratio(p), which computes VTlog p.
  2. Iterate on ρ ∈ ℝJ − 1 with the score and Hessian of Theorem 3; no step can leave the simplex.
  3. Map back with isometric_logistic(rho), a log-sum-exp softmax of Vρ.
  4. Push the covariance of $\hat{\boldsymbol{\rho}}$ to $\hat{\boldsymbol{p}}$ with the Jacobian S(p)V (Sec. 4.2).

The order of the cell types fixes which balances are reported, not the estimate. Both helpers accept another basis through their V argument: for instance, a partition that first contrasts immune with stromal types gives coordinates with a biological reading. Any such basis is VQ for an orthogonal Q (Proposition 2).

Figure 1: The ILR chart is an isometry from the simplex to Euclidean space. A (J = 2): the simplex is a segment and the ILR chart a line; equally spaced values of ρ (colour) map to compositions that crowd towards the vertices. B (J = 3): lines of constant ρ1 (solid) and ρ2 (dotted) on the ternary triangle, the composition (0.5, 0.3, 0.2) and two segments of Aitchison length 1, one near the barycentre (green) and one near the vertex p3 = 1 (gold). C: the same objects in ILR coordinates, where the grid is orthonormal and both segments have Euclidean length 1. D: in the plane orthogonal to 13, Gram–Schmidt applied to a1 = e1 − e2 and a2 = e2 − e3 normalises a1 into v1, removes from a2 its projection on v1 (orange), and normalises the residual into v2: the two Helmert columns of Eq. 16. Dashed lines are the CLR images of the canonical vectors. Script: scripts/auxiliary/generate_ilr_isometry_figure.R.

Figure 1 summarises the construction. Gram–Schmidt applied to the successive differences ek − ek + 1, which span 1J⟂, returns exactly the columns of Eq. 16 for every J (panel D); the resulting chart is isometric, so equal Aitchison lengths become equal Euclidean lengths (panels B–C).

Example 2 (ILR in both directions for p = (0.5, 0.3, 0.2))

For J = 3 the Helmert columns are $\boldsymbol{v}_{1}=(1,-1,0)^{\mathsf{T}}/\sqrt{2}$ and $\boldsymbol{v}_{2}=(1,1,-2)^{\mathsf{T}}/\sqrt{6}$. The entries of V are the weights each coordinate gives to each $\log\textcolor{#1d4e89}{p_{1}}$, $\log\textcolor{#c45c26}{p_{2}}$ and $\log\textcolor{#7b3294}{p_{3}}$; in each coordinate the weights sum to zero.

Forward, ρ = VTlog p:

$$ \left\{ \begin{aligned} \rho_{1} &=\tfrac{1}{\sqrt{2}}\log\textcolor{#1d4e89}{p_{1}} -\tfrac{1}{\sqrt{2}}\log\textcolor{#c45c26}{p_{2}} +0\cdot\log\textcolor{#7b3294}{p_{3}} =\tfrac{1}{\sqrt{2}}\log\frac{\textcolor{#1d4e89}{0.5}}{\textcolor{#c45c26}{0.3}} \approx 0.361\\ \rho_{2} &=\tfrac{1}{\sqrt{6}}\log\textcolor{#1d4e89}{p_{1}} +\tfrac{1}{\sqrt{6}}\log\textcolor{#c45c26}{p_{2}} -\tfrac{2}{\sqrt{6}}\log\textcolor{#7b3294}{p_{3}} =\sqrt{\tfrac{2}{3}}\log\frac{\sqrt{\textcolor{#1d4e89}{0.5}\times\textcolor{#c45c26}{0.3}}}{\textcolor{#7b3294}{0.2}} \approx 0.540 \end{aligned} \right. $$

ρ1 balances type 1 against type 2; ρ2 balances their geometric mean against type 3.

Backward, in two steps. First ξ = Vρ, read row by row, so row j of V rebuilds the CLR coefficient of cell type j:

$$ \left\{ \begin{aligned} \textcolor{#1d4e89}{\xi_{1}} &=\tfrac{1}{\sqrt{2}}\rho_{1}+\tfrac{1}{\sqrt{6}}\rho_{2} \approx 0.255+0.220=0.476\\ \textcolor{#c45c26}{\xi_{2}} &=-\tfrac{1}{\sqrt{2}}\rho_{1}+\tfrac{1}{\sqrt{6}}\rho_{2} \approx -0.255+0.220=-0.035\\ \textcolor{#7b3294}{\xi_{3}} &=0\cdot\rho_{1}-\tfrac{2}{\sqrt{6}}\rho_{2} \approx -0.441 \end{aligned} \right. $$

Then exponentiate and close; the common denominator is eξ1 + eξ2 + eξ3 ≈ 1.609 + 0.966 + 0.644 = 3.218:

$$ \left\{ \begin{aligned} \textcolor{#1d4e89}{p_{1}} &=\frac{e^{\xi_{1}}}{e^{\xi_{1}}+e^{\xi_{2}}+e^{\xi_{3}}} \approx\frac{\textcolor{#1d4e89}{1.609}}{3.218} =\textcolor{#1d4e89}{0.5}\\ \textcolor{#c45c26}{p_{2}} &=\frac{e^{\xi_{2}}}{e^{\xi_{1}}+e^{\xi_{2}}+e^{\xi_{3}}} \approx\frac{\textcolor{#c45c26}{0.966}}{3.218} =\textcolor{#c45c26}{0.3}\\ \textcolor{#7b3294}{p_{3}} &=\frac{e^{\xi_{3}}}{e^{\xi_{1}}+e^{\xi_{2}}+e^{\xi_{3}}} \approx\frac{\textcolor{#7b3294}{0.644}}{3.218} =\textcolor{#7b3294}{0.2} \end{aligned} \right. $$

The intermediate ξ is exactly clr (p).

Link with ALR. Since ρjalr = ξj − ξ3,

$$ \left\{ \begin{aligned} \rho^{\mathrm{alr}}_{1}&=\tfrac{1}{\sqrt{2}}\rho_{1}+\tfrac{3}{\sqrt{6}}\rho_{2}\approx 0.255+0.661=0.916\\ \rho^{\mathrm{alr}}_{2}&=-\tfrac{1}{\sqrt{2}}\rho_{1}+\tfrac{3}{\sqrt{6}}\rho_{2}\approx -0.255+0.661=0.405 \end{aligned} \right. $$

which recovers Example 1. The matrix A3 = D3V of this map has orthogonal columns of lengths 1 and $\sqrt{3}$: ALR keeps ρ1 at unit scale and stretches ρ2, the balance of the reference $\textcolor{#7b3294}{p_{3}}$ against the rest, by $\sqrt{3}$.

Proposition 1 (ILR is a C2 diffeomorphism)

ψ : ℝJ − 1 → Δ̊J − 1, ρ ↦ softmax (Vρ), is bijective and infinitely differentiable, with inverse VTlog p. Every critical point in ρ-space maps to a unique composition in the open simplex, and conversely.

Why DeCovarT uses the ILR chart

The question is which chart to optimise in, given that all of them describe the same model. Two kinds of invariance answer it: statistical invariance, which every chart has, and numerical invariance, which only ILR has under a change of convention.

Statistical invariance holds for every chart. Let θ′ = Aθ be any invertible linear change of coordinates, for instance between ILR and ALR (ρalr = Arρ with Ar = DrV) or between two ALR references. The likelihood is a function of p alone, so the maximiser is equivariant and $\hat{\boldsymbol{p}}$ and $\ell(\hat{\boldsymbol{p}})$ are the same in every chart. The delta method is invariant too: the Jacobian becomes JψA−1 and the information A−TℐA−1, so

(JψA−1)(A−TℐA−1)−1(JψA−1)T = Jψℐ−1JψT.   (18)

In this sense ALR is reference-invariant: whichever cell type is the denominator, a correct implementation returns the same $\hat{\boldsymbol{p}}$ and the same Wald covariance for $\hat{\boldsymbol{p}}$. A material change in $\hat{\boldsymbol{p}}$ when the reference is permuted signals a numerical or convergence problem, not a statistical dependence on the reference. Pure Newton steps share this invariance, because the Newton step is invariant under affine changes of coordinates (Boyd et al. 2004, sec. 9.5).

Numerical invariance differs. What changes with the chart is the Euclidean geometry the solver sees: gradient norms, damping, stopping rules and the condition number of the Hessian, which controls the floating-point accuracy of every linear solve and of ℐ−1.

Proposition 2 (Conditioning under a change of chart)

  1. ILR. Any two orthonormal bases of 1J⟂ satisfy V⋆ = VQ with QTQ = IJ − 1. Then ρ⋆ = QTρ, ∇ρ⋆ℓ = QT∇ρℓ and Hρ⋆ = QTHρQ. Gradient norms, Hessian eigenvalues and condition numbers are identical in every orthonormal basis.

  2. ALR. For every reference r, Ar = DrV has J − 2 singular values equal to 1 and one equal to $\sqrt{J}$, so $\kappa(\mathbf{A}_{r})=\sqrt{J}$. The stretched direction is VTer, the log-abundance of the reference against all other types. Since Hρalr = Ar−THρAr−1,

$$ \frac{\kappa(\mathbf{H}_{\boldsymbol{\rho}})}{J} \le \kappa(\mathbf{H}_{\boldsymbol{\rho}^{\mathrm{alr}}}) \le J\,\kappa(\mathbf{H}_{\boldsymbol{\rho}}), \qquad(19)$$

and the curvature along the reference’s own direction is divided by J.

Proof sketch. (i) is a similarity by an orthogonal matrix. For (ii), the rows of Dr are ej − er, so DrDrT = IJ − 1 + 1J − 11J − 1T, with eigenvalues 1 (multiplicity J − 2) and J. Because Dr1J = 0 and V is an orthonormal basis of 1J⟂, Ar has the same singular values as Dr. The right singular vector for $\sqrt{J}$ is proportional to VTDrT1J − 1 = VT(1J − Jer) = −J VTer. The bounds follow from κ(A−THA−1) ≤ κ(A)2κ(H) applied in both directions. ▫

The constant $\kappa(\mathbf{A}_{r})=\sqrt{J}$ does not depend on r, but the direction it distorts does, so the condition number of the ALR Hessian depends on the reference. Even a perfectly conditioned problem, Hρ = −I, has κ(Hρalr) = J in ALR coordinates. For an illustrative random negative-definite Hessian with J = 6 (not a DeCovarT fit), κ = 171 in every orthonormal basis, but between 164 and 420 across the six ALR references. A rare cell type, or one whose signature is nearly collinear with others, already has weak curvature along its own direction; choosing it as the ALR reference divides that curvature by J and makes the problem harder.

These differences affect the solver, not the target:

Table 3: Which parts of the optimisation depend on the chart convention.
Solver ingredient ILR basis change (Q orthogonal) ALR reference change (A oblique)
Maximiser $\hat{\boldsymbol{p}}$, $\ell(\hat{\boldsymbol{p}})$, delta-method $\operatorname{Var}(\hat{\boldsymbol{p}})$ invariant invariant
Pure Newton step invariant invariant
Gradient norm, steepest-ascent and BFGS steps from an identity start invariant changed
Spherical trust region, isotropic damping H − μI invariant changed
Hessian condition number, accuracy of ℐ−1 invariant changed by a factor up to J

The default solver is Newton–Raphson on ρ (deconvolute_ratios_Newton_Raphson()), a second-order ascent that uses the analytic ILR score and Hessian of Theorem 3. Its pure Newton direction is the same in every chart; its safeguards, a spherical trust region and Euclidean step-length tolerances in stats::nlminb(), are unchanged by a rotation of the ILR basis but not by a change of ALR reference.

Note 5: Decision: DeCovarT optimises in ILR coordinates

ILR is the only chart of the four that is minimal (J − 1 free coordinates), free of a privileged cell type and isometric for the Aitchison geometry. A change of its convention, the order of cell types or a different balance basis, is an orthogonal rotation, which leaves gradient norms and Hessian condition numbers unchanged. A change of ALR reference is an oblique map whose effect on conditioning depends on the reference. The solvers, vcov.decovart_fit() and the boundary diagnostics therefore work in ILR coordinates. ALR is kept for comparison with multinomial-logit models, which use a reference category.

Side-by-side comparison of the four charts

Table 4: Four charts for the unit-simplex constraint.
Property Softmax ALR CLR ILR
Coordinates z ∈ ℝJ ρalr = Drlog p ∈ ℝJ − 1 ξ = HJlog p, with 1Tξ = 0 ρ = VTlog p ∈ ℝJ − 1
Inverse map softmax (z) softmax (ρalr, 0) softmax (ξ) softmax (Vρ)
Feasible after inverse map yes yes yes yes
Free and minimal (J − 1 coordinates) no: one redundant direction yes no: J coordinates on a hyperplane yes
Jacobian of the inverse map rank J − 1 out of J full rank full rank on 1⟂ only full rank
Privileged cell type none the reference r none none (order fixes the balances)
Isometry with Aitchison geometry no no (oblique basis) yes yes
Change of convention not applicable oblique, $\kappa(\mathbf{A}_{r})=\sqrt{J}$ not applicable orthogonal rotation
Hessian conditioning across conventions singular depends on the reference singular invariant
Exact zeros at finite coordinates no no no no
Reading of a coordinate none (shift-invariant) log-ratio to the reference log-ratio to the geometric mean balance between groups
Typical use neural networks, mixture weights reference-category regression exploration, visualisation likelihood inference, optimisation

All four charts guarantee feasibility, and none reaches a face of the simplex at finite coordinates. For likelihood inference ILR is usually the best suited: it is the only chart that is at once minimal, symmetric in the cell types and isometric, which is why Egozcue et al. introduced it to avoid the drawbacks of both ALR and CLR (Egozcue et al. 2003; Pawlowsky-Glahn et al. 2015, 33). Its cost is interpretation: a balance is less direct than a ratio to one reference, and the Helmert balances depend on the order of cell types unless a partition with a biological meaning is chosen.

Efficient derivatives of ψ

Write S(p) = diag (p) − ppT. The Jacobian is

$$ \mathbf{J}_{\boldsymbol{\psi}}(\boldsymbol{\rho}) = \frac{\partial\boldsymbol{p}}{\partial\boldsymbol{\rho}^{\mathsf{T}}} = \mathbf{S}(\boldsymbol{p})\mathbf{V}. \qquad(20)$$

jacobian_isometric_logistic() returns this J × (J − 1) matrix. Let $\bar{\boldsymbol{v}}=\mathbf{V}^{\mathsf{T}}\boldsymbol{p}$, $\boldsymbol{h}_{j}=\mathbf{V}_{j\cdot}-\bar{\boldsymbol{v}}$ and CV = VTS(p)V. Slice j of the map Hessian is

Hψj = pj(hjhjT − CV).   (21)

hessian_isometric_logistic() stores the tensor of shape (J − 1) × (J − 1) × J.

Change of variables: ambient p to ILR ρ

Let ℓρ(ρ) = ℓy ∣ ζ(ψ(ρ)). The chain rule maps the unconstrained derivatives of Sec. 2 into free Euclidean coordinates.

Theorem 3 (Constrained score and Hessian)

∇ρℓ = JψT∇pℓ = VTS(p)∇pℓ,   (22)

$$ \mathbf{H}_{\boldsymbol{\rho}} = \mathbf{J}_{\boldsymbol{\psi}}^{\mathsf{T}} \mathbf{H}_{\boldsymbol{p}} \mathbf{J}_{\boldsymbol{\psi}} + \sum_{j=1}^{J} \frac{\partial\ell}{\partial p_{j}} \mathbf{H}_{\psi_{j}}. \qquad(23)$$

Important 6: Implementation map

Object Package function
Ambient score / Hessian gradient_loglik_unconstrained(), hessian_loglik_unconstrained()
Map Jacobian / Hessian jacobian_isometric_logistic(), hessian_isometric_logistic()
ILR score / Hessian gradient_loglik_constrained(), hessian_loglik_constrained()

Eq. 23 is the sum of a covariant pull-back of H and a contraction of the ambient score against the map Hessian. Omitting the second summand is a common bug when porting first-order code to Newton methods.

Lagrangian, KKT conditions and what the ILR chart removes

Without a chart, the estimation problem is

maxp ∈ ℝJ ℓ(p)  subject to  1JTp = 1,   p ≥ 0,

with Lagrangian

ℒ(p, λ, ν) = ℓ(p) − λ(1JTp − 1) + νTp.   (24)

The constraints are linear, so a constraint qualification holds and every local maximiser satisfies the KKT conditions (Boyd et al. 2004, sec. 5.5.3):

$$ \nabla_{\boldsymbol{p}}\ell(\hat{\boldsymbol{p}}) -\lambda\mathbf{1}_{J} +\boldsymbol{\nu} =\boldsymbol{0}, \qquad \mathbf{1}_{J}^{\mathsf{T}}\hat{\boldsymbol{p}}=1, \qquad \boldsymbol{\nu}\ge\boldsymbol{0}, \qquad \nu_{j}\hat{p}_{j}=0. \qquad(25)$$

  • Interior point (p̂j > 0 for all j): complementary slackness gives ν = 0, hence ∂ℓ/∂pj = λ for every j. Every cell type has the same marginal gain, so moving mass from one type to another does not change ℓ to first order. Multiplying by $\hat{\boldsymbol{p}}^{\mathsf{T}}$ gives the multiplier, $\lambda=\hat{\boldsymbol{p}}^{\mathsf{T}}\nabla_{\boldsymbol{p}}\ell(\hat{\boldsymbol{p}})$.
  • Boundary point (p̂j = 0): ∂ℓ/∂pj = λ − νj ≤ λ. Adding some of type j would not increase the likelihood.

The chart removes the multiplier. Because S(p)1J = p − p(1JTp) = 0, the ILR score of Eq. 22 ignores any multiple of 1J added to the ambient score:

∇ρℓ = VTS(p)(∇pℓ − c 1J)  for every c,   S(p)∇pℓ = diag (p)(∇pℓ − λ(p)1J),   (26)

with λ(p) = pT∇pℓ. The ILR score is therefore the KKT stationarity residual of Eq. 25, weighted by p, with the multiplier set to its current value. The vector S(p)∇pℓ lies in 1J⟂, on which VT is an isometry, so

∥∇ρℓ∥ = ∥S(p)∇pℓ∥,   ∇ρℓ = 0 ⇔ ∇pℓ = λ1J.

Stationary points in ρ are exactly the interior KKT points, the multiplier is recovered afterwards as $\hat{\lambda}=\hat{\boldsymbol{p}}^{\mathsf{T}}\nabla_{\boldsymbol{p}}\ell(\hat{\boldsymbol{p}})$, and the score norm that boundary_diagnostics() reports does not depend on the basis. Under ALR the same equivalence holds, but the score norm changes with the reference.

Second order: the Hessian of the Lagrangian. Since ∑jψj(ρ) = 1 for every ρ, ∑jHψj = 0, and the curvature term of Eq. 23 also ignores the multiplier:

$$ \sum_{j=1}^{J}\frac{\partial\ell}{\partial p_{j}}\mathbf{H}_{\psi_{j}} = \sum_{j=1}^{J}\Bigl(\frac{\partial\ell}{\partial p_{j}}-\lambda\Bigr) \mathbf{H}_{\psi_{j}}. $$

At an interior KKT point every bracket vanishes, so

Hρ = JψT∇pp2ℒ Jψ,   ∇pp2ℒ = Hp,   (27)

because linear constraints add no curvature to the Lagrangian. The columns of Jψ = S(p)V span 1J⟂, the directions d with 1JTd = 0 that keep the sum equal to one. Eq. 27 is thus the Hessian of the Lagrangian reduced to the tangent space of the constraint, and Hρ ≺ 0 is the classical second-order sufficient condition dTHpd < 0 for all d ≠ 0 with 1JTd = 0. Away from stationarity the curvature term must be kept: it is the price of a curved chart.

What the chart cannot do. For finite ρ every pj is strictly positive, so the inequality multipliers ν never become active. A maximiser on a face of the simplex lies at infinity in ρ: the iterates drift, ‖∇ρℓ‖ decays only through the factor diag (p) in Eq. 26, and the Hessian becomes singular. The boundary is handled separately (Sec. 3.11). The benchmark reports the projected-gradient residual $\lVert\Pi_{\Delta}(\hat{\boldsymbol{p}}+\nabla_{\boldsymbol{p}}\ell)-\hat{\boldsymbol{p}}\rVert$, which is zero exactly at a KKT point, interior or not.

Perspectives: Bayesian charts and the simplex boundary

Note 7: Going further: priors on log-ratio coordinates and estimates on a face

What DeCovarT does today. No chart above represents an exact zero at finite coordinates, because each contains a logarithm. For a true simplex face the package does not send log 0 through the chart: it fixes the inactive set, optimises ILR coordinates on the remaining active face (restricted_mle_decovart()), and checks the KKT inequalities ∂ℓ/∂pj ≤ λ of Sec. 3.10 for the zero coordinates (boundary_diagnostics(); see also the MLE-properties vignette).

Bayesian versions of the same charts. A log-ratio chart turns a prior on the simplex into a prior on Euclidean coordinates, and the Gaussian bulk likelihood then combines with standard tools (Pawlowsky-Glahn and Buccianti 2011).

  • Logistic-normal prior. A Gaussian prior ρ ∼ 𝒩J − 1(m, Λ) is a logistic-normal law on p. Its log-density adds a quadratic penalty to ℓ(ρ), so the posterior mode is a ridge-penalised Newton problem in the same coordinates.
  • Dirichlet prior. The density of p written in ILR coordinates gains the Jacobian factor $\lvert\det\partial(p_{1},\ldots,p_{J-1})/\partial\boldsymbol{\rho}\rvert =\sqrt{J}\prod_{j}p_{j}$. A Dirichlet(α) prior therefore becomes ∑jαjlog pj in ρ, a concave function that pushes the mode away from the boundary. Even the uniform prior (α = 1) is not flat in ρ, so a posterior mode depends on the chart in which it is computed; posterior means and intervals for p do not.
  • CLR or ILR regression. Covariates enter linearly on the log-ratio scale, ρi = Bzi + ui, which is the compositional analogue of a multinomial-logit model and gives the marginal effect of a covariate on the composition.
  • The experimental MAP CTS path (scripts/experimental/03_04_DeCovarT_estimate_CTS_MAP_Bayesian.R, derived in the perspectives vignette) is one starting point.

Estimates on the boundary. Several routes go beyond the active-set approach; none is implemented.

  • Projection methods work in p itself: a projected Newton or projected-gradient step onto ΔJ − 1 reaches a face in finitely many iterations, and its residual is the KKT residual the benchmark already reports.
  • Spike-and-slab or hurdle priors put positive mass on pj = 0, so the posterior probability that a cell type is absent becomes an output, alongside the boundary likelihood-ratio tests of the MLE-properties vignette.
  • Charts without a logarithm reach the boundary at finite coordinates, for instance the folded α-transformation (Tsagris and Stewart 2020) or nonparametric regressions that admit exact zeros (Tsagris et al. 2023). They are data-side constructions and lose the isometry of ILR.

Rounded zeros (detection limits) remain an imputation problem. True structural zeros belong on a face and should be fitted as an active-set or KKT problem, not by substituting a small positive constant into Eq. 15.

Expected Fisher information and Wald inference

Point estimation alone does not report uncertainty. Under a regular large-sample regime the MLE is asymptotically normal with covariance given by the inverse Fisher information. DeCovarT builds Wald standard errors from the expected Fisher information of the multivariate-normal convolution, then maps that information through the ILR chart.

Unconstrained expected Fisher information

For y ∼ 𝒩G(μp, Σ(p)) the expected Fisher information has entries

I(p)jℓ = μ⋅j⊤Ω(p)μ⋅ℓ + 2pjpℓ tr(Ω(p)ΣjΩ(p)Σℓ).   (28)

The first summand is the mean contribution (a Ω-inner product of signature columns); the second is the covariance contribution of the quadratic map p ↦ Σ(p). See the multivariate-normal formula on Wikipedia: Fisher information. expected_fisher_unconstrained() implements Eq. 28.

Note 8: Observed versus expected information

The analytic Hessian of Sec. 2 is the observed information (up to sign). Wald intervals in decovart_fit use the expected information Eq. 28, which does not depend on the residual y − μp and is positive definite under the usual full-rank assumptions on (μ, {Σj}).

The two are consistent by construction. Substituting 𝔼[r] = 0 and 𝔼[rr⊤] = Σ(p) into Eq. 8 and Eq. 9 cancels the determinant traces against the residual traces and returns Eq. 28 exactly, i.e. 𝔼[−H] = I(p). That identity only holds with the factor $\tfrac{1}{2}$ of Note 3 in place.

Constrained case: ILR delta method

Fisher information transforms as a covariant quadratic form under the ILR chart. With Jψ = S(p)V,

Iρ = JψTI(p)Jψ = VTS(p)I(p)S(p)V.   (29)

The mean/covariance split of Eq. 28 pulls back separately, Iρ = Iρ, mean + Iρ, cov. Under regularity, $\hat{\boldsymbol{\rho}} \overset{a}{\sim} \mathcal{N}(\boldsymbol{\rho}_{0},I_{\boldsymbol{\rho}}^{-1})$ (Vaart 2000). The first-order delta method (Oehlert 1992) then returns the simplex covariance used by vcov.decovart_fit(),

$$ \mathrm{Var}(\hat{\boldsymbol{p}}) \approx \mathbf{J}_{\boldsymbol{\psi}} I_{\boldsymbol{\rho}}^{-1} \mathbf{J}_{\boldsymbol{\psi}}^{\mathsf{T}}. \qquad(30)$$

Diagonal square roots are asymptotic standard errors; Wald intervals at level 1 − α are p̂j ± z1 − α/2 SEj with zq = Φ−1(q), as in confint.decovart_fit(). vcov_ilr_delta() implements Eq. 29–Eq. 30. Orthogonal rotations of V leave Eq. 30 unchanged. The construction is undefined on the simplex boundary (the log-ratio chart blows up); the helper then returns NA with a warning.

Warning 9: Wald is the cheapest, not the safest, interval

Eq. 30 linearises the ILR chart at $\hat{\boldsymbol{p}}$, so it is neither invariant to a non-orthogonal reparametrisation nor confined to [0, 1], and it degenerates entirely when a proportion reaches a simplex face. The companion vignette MLE properties and asymptotic inference derives the alternatives: profile likelihood-ratio intervals, the chi-bar-square calibration of Chernoff and of Self and Liang for nulls on the boundary, a parametric bootstrap, and a reference-sample bootstrap of donors or cells (or a Dirichlet composition sweep). It also shows why these limits need replicate samples that share one composition. Shuffling genes or cell-type names of an averaged signature is not a bootstrap: the maximised likelihood is equivariant under relabelling.

Numerical speed-ups and solver safeguards

The analytic maps above are only half of a usable optimiser. Practical bottlenecks that showed up on the hybrid scenario in Covariance-driven hybrid scenario live in R/03_03_DeCovarT_estimate_ratios_frequentist.R.


Cache a Cholesky factorisation of Σ(p)

Within one iteration, objective / gradient / Hessian callbacks hit the same trial p. The helper .sigma_p_factorisation() caches a single Cholesky factor R with Σ(p) = RTR and returns log det Σ(p) = 2∑glog Rgg together with the precision Ω(p) = R−1R−T (via chol2inv) without repeating an O(G3) factorisation.

loglik_multivariate() then evaluates the Mahalanobis term exactly as mvtnorm::dmvnorm (Genz et al. 2026): it solves RTz = y − μp by backsolve(..., transpose = TRUE) and takes ‖z‖2, rather than forming Ω(p) and a dense quadratic form. The two routes agree to machine precision; the backsolve path is the one used for the objective, while the cached inverse is retained for the analytic score and Hessian, which need Ω(p) in several trace and inner-product terms. A QR factorisation of the covariance itself would recover the same log-determinant and quadratic form at a larger O(G3) constant and is not used: Cholesky is the natural factorisation of a symmetric positive-definite matrix.

The implemented log-density omits the additive $-\tfrac{G}{2}\log(2\pi)$ of the full Gaussian, which does not depend on p and therefore cannot change the MLE, the score, or the Hessian. Tests check that subtracting that constant recovers dmvnorm(..., log = TRUE) exactly.


Guard the box-constrained L-BFGS-B path

deconvolute_ratios_L_BFGS_B() optimises in p with boxes [0, 1]J that do not enforce 1⊤p = 1. Near ∑jpj ≈ 0 (or on a failed chol()), safeguarded wrappers return a finite penalty and a zero gradient rather than aborting optim().


marqLevAlg Hessian sign under minimize = FALSE

The optional Marquardt–Levenberg solver (fit_decovart(method = "Marquardt-Levenberg")) calls marqLevAlg (Philipps et al. 2023), which implements Marquardt–Levenberg with the relative-distance-to-minimum (RDM) rule of Commenges et al. (Commenges et al. 2006). With minimize = FALSE, the package negates only fn and gr; the analytic hess is passed through unchanged while internal Cholesky routines assume a positive-definite matrix at the optimum. When maximising a log-likelihood, pass hess = function(...) -hessian_loglik_constrained(...). Reported upstream as VivianePhilipps/marqLevAlgParallel#3.

Model objects and S3 accessors

fit_decovart() returns a decovart_fit object with standard S3 methods for coefficients, fitted values, residuals, and (under regularity) a delta-method covariance. The chunk below mirrors the appendix equivariance setup:

library(DeCovarT)
genes <- paste0("g", 1:3)
cts <- paste0("ct", 1:2)
mu <- matrix(
  c(20, 40, 25, 35, 30, 22),
  nrow = 3,
  dimnames = list(genes, cts)
)
Sigma <- array(0, dim = c(3, 3, 2), dimnames = list(genes, genes, cts))
Sigma[, , 1] <- diag(c(1.0, 1.2, 0.8))
Sigma[, , 2] <- diag(c(1.5, 0.9, 1.1))
p_true <- c(0.65, 0.35)
y <- matrix(
  drop(mu %*% p_true + rnorm(3, sd = 0.05)),
  ncol = 1L,
  dimnames = list(genes, "s1")
)

fit <- fit_decovart(
  mu,
  y,
  Sigma = Sigma,
  itmax = 80
)
coef(fit)
nobs(fit)
c(
  n_genes = attr(nobs(fit), "n_genes"),
  n_celltypes = attr(nobs(fit), "n_celltypes")
)
fitted(fit)
residuals(fit)
vcov(fit)

formula() and predict() are not implemented: DeCovarT does not forecast bulk expression.

Numerical consistency of the likelihood and its derivatives

Analytic formulae can be differentiated correctly and still implement the wrong objective. The checks below separate those two questions. They are the same identities that tests/testthat/test-03_03_DeCovarT.R and tests/testthat/test-03_06_decovart_inference.R enforce on every package build; the chunks here are a readable, small-(G) illustration.

Density against mvtnorm

The first check is against an independent implementation of the multivariate Gaussian log-density, not against our own inverse. With the $\tfrac{1}{2}\log\det$ factor restored, DeCovarT and mvtnorm::dmvnorm (Genz et al. 2026) differ by exactly $\tfrac{G}{2}\log(2\pi)$ (DeCovarT omits the negative constant):

n_genes <- length(y_chk)
ours <- loglik_multivariate(p_chk, y_chk, mu_chk, Sigma_chk)
reference <- if (requireNamespace("mvtnorm", quietly = TRUE)) {
  as.numeric(mvtnorm::dmvnorm(
    y_chk,
    mean = drop(mu_chk %*% p_chk),
    sigma = cov_chk,
    log = TRUE
  ))
} else {
  residual <- y_chk - drop(mu_chk %*% p_chk)
  as.numeric(
    -0.5 * determinant(cov_chk, logarithm = TRUE)$modulus -
      0.5 * drop(crossprod(residual, solve(cov_chk, residual))) -
      0.5 * n_genes * log(2 * pi)
  )
}
c(
  loglik_multivariate = ours,
  dmvnorm = reference,
  difference = ours - 0.5 * n_genes * log(2 * pi) - reference
)

A finite-difference check of the same objective cannot detect a shared factor-of-two error in the log-likelihood and its derivatives. That is why this density comparison is independent of numDeriv.

Richardson extrapolation of the score and Hessian

Once the objective is the intended Gaussian, the analytic score and Hessian are checked against Richardson extrapolation in numDeriv (Gilbert and Varadhan 2019). Richardson’s tableau extrapolates central differences to cancel successive even powers of the step size, which is more accurate than a single two-point stencil at the same O(ε−1) cost in function evaluations.

if (!requireNamespace("numDeriv", quietly = TRUE)) {
  numderiv_report <- c(gradient_rel = NA_real_, hessian_rel = NA_real_)
} else {
  grad_n <- numDeriv::grad(
    loglik_multivariate,
    p_chk,
    method = "Richardson",
    method.args = list(eps = 1e-4, r = 6),
    y = y_chk,
    mean_signature_matrix = mu_chk,
    Sigma = Sigma_chk
  )
  hess_n <- numDeriv::hessian(
    loglik_multivariate,
    p_chk,
    method = "Richardson",
    method.args = list(eps = 1e-4, r = 4),
    y = y_chk,
    mean_signature_matrix = mu_chk,
    Sigma = Sigma_chk
  )
  grad_a <- gradient_loglik_unconstrained(
    p_chk, y_chk, mu_chk, Sigma_chk
  )
  hess_a <- hessian_loglik_unconstrained(
    p_chk, y_chk, mu_chk, Sigma_chk
  )
  numderiv_report <- c(
    gradient_rel = max(abs(grad_a - grad_n)) / max(abs(grad_n)),
    hessian_rel = max(abs(hess_a - hess_n)) / max(abs(hess_n))
  )
}
numderiv_report

Relative discrepancies of order (10^{-8}) are typical on this three-gene toy; that is the same tolerance used in the test suite.

Expected information versus Monte Carlo ([-])

Matching numDeriv shows that the derivatives belong to the implemented objective. Matching the expected Fisher information Eq. 28 to a Monte Carlo average of (-(; )) shows that the objective is the Gaussian whose information matrix we use for Wald intervals. Draw (^{(b)}_G(, ())) at the true () (the parametric bootstrap of bootstrap_decovart(), used here as a diagnostic rather than as an inferential procedure):

set.seed(2)
n_mc <- 40L
info <- expected_fisher_unconstrained(p_chk, mu_chk, Sigma_chk)
neg_hess <- array(NA_real_, c(3L, 3L, n_mc))
for (b in seq_len(n_mc)) {
  y_b <- MASS::mvrnorm(
    n = 1L,
    mu = drop(mu_chk %*% p_chk),
    Sigma = cov_chk
  )
  neg_hess[, , b] <- -hessian_loglik_unconstrained(
    p_chk, y_b, mu_chk, Sigma_chk
  )
}
mc_info <- apply(neg_hess, c(1L, 2L), mean)
c(
  rel_frobenius = sqrt(sum((mc_info - info)^2)) / sqrt(sum(info^2))
)

The same identity is what closed the factor-of-two inconsistency: with the old (-) objective, ([-]) could not equal (I()). A few dozen draws already bring the relative Frobenius gap below (10^{-2}) on this toy; the test suite uses a tighter Monte Carlo.

A related, weaker check compares the empirical covariance of parametric-bootstrap MLEs to the Cramér–Rao map vcov_ilr_delta(). That comparison is noisy at small replication (see MLE properties for why one bulk column is not an asymptotic sample) and is therefore left to the inference vignette and to bootstrap_decovart().

Structure-aware covariance backends

Every solver call factorises Σ(p) = ∑jpj2Σj. The dense Cholesky in .sigma_p_factorisation() is the universal default and the only method that needs no assumptions. When the covariance inherits structure from the underlying gene network, the same log-determinant and solves can be obtained far more cheaply. Exploiting band, sparse and diagonal-plus-low-rank structure in a Newton-type solver is standard practice (Boyd et al. 2004, sec. 9.7); the backends below make that structure explicit for DeCovarT.

new_decovart_covariance() wraps the covariance array with a declared structure, and the operators sigma_logdet(), sigma_solve(), sigma_quadform() and sigma_trace_precision_times() return exactly the quantities the objective, score and Hessian need. They expose operations, never a materialised dense precision: a sparse or Woodbury solve must not be silently undone by a dense chol2inv.

Decision tree

Structure is supplied explicitly, never inferred from floating-point near-zeros, so a numerical near-zero is never mistaken for an exact conditional independence. covariance_structure_from_graph_model() maps a network topology to the recommended backend. A sparse precision Ωj does not imply a sparse covariance Σj; only structure that survives in Σ(p) itself accelerates the likelihood.

Figure 2: Choosing a covariance backend; dense Cholesky is the default and structured backends are exact refinements.

Each refinement is exact, not approximate:

  • Block (disconnected gene modules, e.g. a stochastic block model with no between-block edges (Holland et al. 1983)). Σ(p) is block-diagonal, so the log-likelihood separates over blocks and one Cholesky per block replaces one dense Cholesky.
  • Band / AR. Only genes within bandwidth b covary; a banded Cholesky costs O(Gb2) (Golub and Van Loan 2013).
  • Sparse (Erdős–Rényi, scale-free (Barabási and Albert 1999), small-world (Watts and Strogatz 1998)). The fill-reducing ordering is a symbolic factorisation computed once and reused for every numeric refactor as p changes; only the numerical Cholesky repeats (Chen et al. 2008).
  • Diagonal + low rank. Genes interact through r ≪ G shared regulatory programs, Σj = Dj + UCjUT — the factor-analysis form Σ = WWT + Ψ. The Woodbury identity and the matrix-determinant lemma (Hager 1989) move the O(G3) cost to the low rank r. A few bridge / housekeeping hub genes give the arrow-matrix special case handled by the same Schur-complement algebra.
# Declare structure explicitly, then use the operator interface.
cov <- new_decovart_covariance(Sigma, structure = "diag_lowrank",
  diagonal = D, loadings = U, core = C)
ld <- sigma_logdet(cov, p)            # log det Sigma(p)
z  <- sigma_solve(cov, p, residual)   # Sigma(p)^{-1} r, no dense inverse
q  <- sigma_quadform(cov, p, residual)

Computational complexity

For a dense symmetric positive-definite G × G matrix the Cholesky factorisation costs about G3/3 flops before the cheaper triangular solves (Golub and Van Loan 2013). The structured backends reduce that leading term:

Table 5: Leading factorisation cost per backend. G genes, J cell types, B blocks of size Gb, bandwidth b, rank r ≪ G.
Structure When it applies Factorisation cost Backend argument
Dense universal default O(G3) (default)
Block disconnected modules (SBM) O(∑bGb3);  ≈ B2 saving for B equal blocks structure = "block"
Band / AR bandwidth b O(Gb2) structure = "band"
Sparse fixed sparse pattern pattern-dependent; symbolic ordering reused across p structure = "sparse"
Diagonal + low rank r shared programs O(Gr2) solve, O(r3) core structure = "diag_lowrank"

These are worst-case flop counts and only rough predictors of wall-clock time on cache-based hardware with tuned BLAS; the block and low-rank savings ( ≈ B2 and O(G2) → O(Gr2) respectively) are the most robust. The "band" and "sparse" backends use the imported Matrix package (supernodal sparse Cholesky in CHOLMOD, (Chen et al. 2008)). scripts/supp_S2_covariance_inversion.R verifies each backend against the dense path to machine precision. Approximate sparse Cholesky of otherwise dense kernel covariances is a separate research line (Schäfer et al. 2020); the "sparse" backend here is exact for a declared sparse pattern, not that approximation.

References

Aitchison, J. 1982. “The Statistical Analysis of Compositional Data.” Journal of the Royal Statistical Society: Series B (Methodological) 44 (2): 139–60. https://doi.org/10.1111/j.2517-6161.1982.tb01195.x.
Barabási, Albert-László, and Réka Albert. 1999. “Emergence of Scaling in Random Networks.” Science 286. https://doi.org/10.1126/science.286.5439.509.
Boyd, Stephen, Stephen P. Boyd, and Lieven Vandenberghe. 2004. Convex Optimization. 1st ed. Cambridge University Press; Cambridge University Press. https://doi.org/10.1017/cbo9780511804441.
Chen, Yanqing, Timothy A. Davis, William W. Hager, and Sivasankaran Rajamanickam. 2008. “Algorithm 887: CHOLMOD, Supernodal Sparse Cholesky Factorization and Update/Downdate.” ACM Transactions on Mathematical Software 35 (3): 22:1–14. https://doi.org/10.1145/1391989.1391995.
Commenges, Daniel, Helene Jacqmin-Gadda, Cecile Proust, and Jeremie Guedj. 2006. A Newton-Like Algorithm for Likelihood Maximization: The Robust-Variance Scoring Algorithm. arXiv. https://doi.org/10.48550/arxiv.math/0610402.
Egozcue, J. J., V. Pawlowsky-Glahn, G. Mateu-Figueras, and C. Barceló-Vidal. 2003. “Isometric Logratio Transformations for Compositional Data Analysis.” Mathematical Geology 35 (3): 279–300. https://doi.org/10.1023/a:1023818214614.
Genz, Alan, Frank Bretz, Tetsuhisa Miwa, Xuefei Mi, and Torsten Hothorn. 2026. Mvtnorm: Multivariate Normal and t Distributions. https://codeberg.org/thothorn/mvtnorm.
Gilbert, Paul, and Ravi Varadhan. 2019. numDeriv: Accurate Numerical Derivatives. http://optimizer.r-forge.r-project.org/.
Golub, Gene H., and Charles F. Van Loan. 2013. Matrix Computations. JHU Press.
Hager, William W. 1989. “Updating the Inverse of a Matrix.” SIAM Review 31 (2): 221–39. https://doi.org/10.1137/1031049.
Holland, Paul W., Kathryn Blackmond Laskey, and Samuel Leinhardt. 1983. “Stochastic Blockmodels: First Steps.” Social Networks 5. https://doi.org/10.1016/0378-8733(83)90021-7.
Oehlert, Gary W. 1992. “A Note on the Delta Method.” The American Statistician 46 (1): 27–29. https://doi.org/10.1080/00031305.1992.10475842.
Pawlowsky-Glahn, Vera, and Antonella Buccianti, eds. 2011. Compositional Data Analysis: Theory and Applications. Wiley.
Pawlowsky-Glahn, Vera, Juan Jose Egozcue, and Raimon Tolosana-Delgado. 2015. “Coordinate Representation.” In Modelling and Analysis of Compositional Data. John Wiley & Sons, Ltd. https://doi.org/10.1002/9781119003144.ch4.
Philipps, Viviane, Cecile Proust-Lima, Melanie Prague, Boris Hejblum, Daniel Commenges, and Amadou Diakite. 2023. marqLevAlg: A Parallelized General-Purpose Optimization Based on Marquardt-Levenberg Algorithm.
Schäfer, Florian, T. J. Sullivan, and Houman Owhadi. 2020. Compression, Inversion, and Approximate PCA of Dense Kernel Matrices at Near-Linear Computational Complexity. arXiv. https://doi.org/10.48550/arxiv.1706.02205.
Tsagris, Michail, Abdulaziz Alenazi, and Connie Stewart. 2023. “Flexible Non-Parametric Regression Models for Compositional Response Data with Zeros.” Statistics and Computing 33 (5): 106. https://doi.org/10.1007/s11222-023-10277-5.
Tsagris, Michail, and Connie Stewart. 2020. “A Folded Model for Compositional Data Analysis.” Australian & New Zealand Journal of Statistics 62 (2): 249–77. https://doi.org/10.1111/anzs.12289.
Vaart, A. W. van der. 2000. Asymptotic Statistics. Cambridge University Press.
van den Boogaart, K. Gerald, Raimon Tolosana-Delgado, and Matevz Bren. 2025. Compositions: Compositional Data Analysis. http://www.stat.boogaart.de/compositions/.
Watts, Duncan J., and Steven H. Strogatz. 1998. “Collective Dynamics of ‘Small-World’ Networks.” Nature 393 (6684): 440–42. https://doi.org/10.1038/30918.