Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Cholesky factorisation of a covariance or correlation matrix into its lower triangular factor

chol(A) = L

Maps a symmetric positive definite n by n matrix A, usually the covariance matrix of parameters estimated together, to the lower triangular matrix L with positive diagonal entries for which A equals L times L transposed, or stops at the first zero or negative pivot when no such factor exists. The two-parameter factor and draw x = mu + L z are live as HE-FM-PSA-001 and a whole PSA run on them is HE-CF-PSA-001, so neither is restated here. The upper triangular orientation error is HE-ER-PSA-001 and the cost of drawing jointly estimated parameters as if independent is HE-ER-PSA-002. The logit link that turns a sampled linear predictor into a probability takes the form of HE-FM-BINOM-007, and approximate limits on that predictor take the form of HE-FM-AN-001. This package adds what first appears at three parameters, namely the column algorithm with its cross-product term and the pivot test with a valid range for a correlation matrix assembled pair by pair. It also adds the spherical form that keeps a sampled correlation matrix valid in evidence synthesis, and the transform Neine and Curran use to carry correlated normal draws into beta and gamma inputs. Notation follows the Cholesky Decomposition article.

  • Three-parameter Cholesky factor from covariance entries by the column algorithm

    l_11 = sqrt(a_11); l_21 = a_21 / l_11; l_31 = a_31 / l_11; l_22 = sqrt(a_22 - l_21^2); l_32 = (a_32 - l_31 * l_21) / l_22; l_33 = sqrt(a_33 - l_31^2 - l_32^2)

    Factorises the covariance matrix of three parameters estimated together, one column at a time, each entry found from entries already computed. Each diagonal entry is the square root of what remains of that parameter's variance after the earlier columns, and each entry below it is the remaining covariance divided by that diagonal entry. The third row's l_32 subtracts l_31 times l_21 before dividing, a step with no counterpart at two parameters, where the same algorithm returns the entries of HE-FM-PSA-001 (0 mismatches on a grid of 28,125 input sets, checked here). Positive definiteness guarantees a positive argument under every square root, and HE-FM-CHOD-002 tests a matrix for which that may not hold. HE-CF-CHOD-001 gives the factor for any number of parameters with the draws.

  • Pivot test and valid range for a pairwise-assembled three-parameter correlation matrix

    p_2 = 1 - r_21^2; q_31 = 1 - r_31^2; c_32 = r_32 - r_31 * r_21; p_3 = q_31 - c_32^2 / p_2; det_R = p_2 * p_3; r_L = r_31 * r_21 - sqrt(p_2 * q_31); r_U = r_31 * r_21 + sqrt(p_2 * q_31); valid = (p_2 > 0) and (p_3 > 0)

    Tests whether three correlations chosen pair by pair can form a valid correlation matrix, by running the column algorithm of HE-FM-CHOD-001 on a unit diagonal without taking the square roots. p_2 and p_3 are the arguments of the second and third square roots, since l_32 squared equals c_32 squared over p_2, and Higham's test declares a matrix positive definite when the algorithm completes with no zero or negative pivot. Their product det_R is the determinant of the matrix (derived, 0 mismatches against numerical determinants on a grid of 59,319 triples). r_L and r_U bound the values of r_32 that keep the matrix valid given the other two (derived), and valid is 1 exactly when r_32 lies strictly inside them (same grid, 0 mismatches). The test cannot fail at two parameters, where any rho above minus 1 and below 1 is valid (HE-AS-PSA-002), so the constraint first appears here.

  • Spherical Cholesky factor giving a valid three-outcome correlation matrix from free angles

    s_22 = sqrt(1 - c_22^2); s_32 = sqrt(1 - c_32^2); s_33 = sqrt(1 - c_33^2); l_32 = s_32 * c_33; l_33 = s_32 * s_33; r_32 = c_32 * c_22 + l_32 * s_22; u_3 = c_32^2 + l_32^2 + l_33^2

    Builds the Cholesky factor of a three-outcome correlation matrix from three free angles, so that every choice of angles gives a valid matrix. TSD 20 Appendix C.1 sets L_11 to 1, the second row to cos phi_22 and sin phi_22, and the third row to cos phi_32, sin phi_32 cos phi_33 and sin phi_32 sin phi_33, the three-outcome case of its equations 26 to 30, with each angle above 0 and below pi. The calculator has no trigonometric functions, so it takes the cosines c_22, c_32 and c_33, and the sines follow as positive square roots because the sine is positive on that interval. The correlations r_21 and r_31 are c_22 and c_32 themselves, and r_32 is the inner product of the second and third rows. HE-FM-CHOD-002 returns valid = 1 for every such matrix, and r_32 stays strictly inside the r_L and r_U of that record as c_33 moves (derived, 0 mismatches against numerical Cholesky factors on a grid of 12,167 cosine triples).

  • Neine and Curran transform of correlated normal draws into a beta and a gamma PSA input

    x_2 = rho * z_1 + sqrt(1 - rho^2) * z_2; y_1 = 1 - (1 - Phi_1)^(1 / b_1); y_2 = -theta_2 * log(1 - Phi_2)

    Carries correlated standard normal values into non-normal PSA inputs by Neine and Curran's algorithm. The correlated value x_2 is HE-FM-PSA-001 at means of 0 and standard deviations of 1, each normal value becomes a probability through the normal cumulative distribution function, and that probability passes through the inverse cumulative distribution function of the target distribution. The calculator has no normal distribution function, so Phi_1 and Phi_2 are entered as named inputs from NORM.S.DIST(z_1, TRUE) and NORM.S.DIST(x_2, TRUE), the convention of HE-FM-COPAS-001. It has no beta or gamma quantile either, so the line uses the two shapes with closed forms (derived), a beta with first shape 1 and a gamma with shape 1, the second being the exponential quantile form in HE-CF-ANTV-001. Any other shape runs in HE-IM-CHOD-004 and HE-CF-CHOD-002, and each input keeps its target marginal distribution whatever the value of rho (derived).

This set of formulae is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Author: Dr Darrin Baines · Publisher: Intelligent Parameters Ltd · Identifier: https://healtheconomics.wiki/concept/cholesky-decomposition/formulae