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

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.

Signature

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)
Inputs
InputsDefinitionUnit
a_11Variance of the first parameter, the square of its standard error, above zerosquared units of the first parameter
a_21Covariance of the second parameter with the firstunits of the first parameter times units of the second
a_31Covariance of the third parameter with the firstunits of the first parameter times units of the third
a_22Variance of the second parameter, above zerosquared units of the second parameter
a_32Covariance of the third parameter with the secondunits of the second parameter times units of the third
a_33Variance of the third parameter, above zerosquared units of the third parameter
Output
l_11Row 1, column 1 entry of L, the standard deviation of the first parameterunits of the first parameter
l_21Row 2, column 1 entry of Lunits of the second parameter
l_31Row 3, column 1 entry of Lunits of the third parameter
l_22Row 2, column 2 entry of Lunits of the second parameter
l_32Row 3, column 2 entry of L, after the cross-product of the first column is removedunits of the third parameter
l_33Row 3, column 3 entry of Lunits of the third parameter

Function

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

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.

Computational function

  • Computational function for the Cholesky factor of any size with a positive definiteness stop and correlated draws

    Runs the column algorithm on a covariance matrix of any size, stops at the first order that fails, and returns one correlated draw per row of a table of standard normal values. The factor is computed once and the same factor serves every iteration, as the article describes; Higham gives its cost as about n cubed over 3 flops. Each draw is the x = mu + L z of HE-FM-PSA-001 with more terms. The Math / Code line writes out three parameters; the R and Python versions take any size.

    Inputs and outputs: a_11 to a_33 are the lower triangle of the covariance matrix A, in squared parameter units; mu_1 to mu_3 are the point estimates; z_1 to z_3 are independent standard normal values. The outputs are the entries l_11 to l_33 of the factor and the draws x_1 to x_3 in parameter units. The R and Python versions take a whole matrix A, a vector mu and a table Z with one row per draw.

    Assumption: A is symmetric positive definite, a new row of Z is used in every iteration, and the rows of the factor follow the order of A. The illustrative inputs below are not estimates for any real technology.

    Worked example (Article's draw with an illustrative third coefficient): With the covariance matrix of HE-EX-CHOD-003, point estimates minus 2, 0.5 and 0.3, and standard normal values 1, minus 0.5 and 0.2, the first two draws are the article's minus 1.8 and 0.42 and the third is about 0.2878. a_11 = 0.04; a_21 = -0.0096; a_31 = -0.006; a_22 = 0.0064; a_32 = 0.0016; a_33 = 0.01; mu_1 = -2; mu_2 = 0.5; mu_3 = 0.3; z_1 = 1; z_2 = -0.5; z_3 = 0.2; l_11 = 0.2; l_21 = -0.048; l_31 = -0.03; l_22 = 0.064; l_32 = 0.0025; l_33 = 0.0953612; x_1 = -1.8; x_2 = 0.42; x_3 = 0.2878222

    Worked example (Neine and Curran's matrix): With means of zero, the matrix of HE-EX-CHOD-001 and standard normal values of 1, the draws are 1, about 1.3660 and about 1.6052, the second as in HE-EX-PSA-002. a_11 = 1; a_21 = 0.5; a_31 = 0.5; a_22 = 1; a_32 = 0.5; a_33 = 1; mu_1 = 0; mu_2 = 0; mu_3 = 0; z_1 = 1; z_2 = 1; z_3 = 1; l_11 = 1; l_21 = 0.5; l_31 = 0.5; l_22 = 0.8660254; l_32 = 0.2886751; l_33 = 0.8164966; x_1 = 1; x_2 = 1.3660254; x_3 = 1.6051717

    Excel: With frozen standard normal values in columns A, B and C (each =NORM.S.INV(RAND()) pasted as values), the named cells of HE-IM-CHOD-001 and point estimates in MeanFirst, MeanSecond and MeanThird, =MeanFirst+CholFirstFirst*A2, =MeanSecond+CholSecondFirst*A2+CholSecondSecond*B2 and =MeanThird+CholThirdFirst*A2+CholThirdSecond*B2+CholThirdThird*C2 filled down give the columns named DrawsFirst, DrawsSecond and DrawsThird. Classic Excel has no factorisation function, so a larger matrix needs one more helper formula per entry on the pattern of HE-IM-CHOD-001, or the VBA macro route Neine and Curran used.

    R: chol_draw <- function(A, mu, Z) { if (!isSymmetric(A)) stop("A must be symmetric"); L <- t(chol(A)); list(L = L, draws = sweep(Z %*% t(L), 2, mu, "+")) } Here Z is a matrix with one row per draw, so Z %*% t(L) is L z written by rows. With the first worked example chol_draw(A, c(-2, 0.5, 0.3), rbind(c(1, -0.5, 0.2))) returns draws of minus 1.8, 0.42 and 0.2878222. A matrix that is not positive definite stops with the error that the leading minor of order 3 is not positive for the article's 0.9, 0.9 and 0 matrix, a semidefinite matrix such as matrix(1, 2, 2) stops at order 2, a 1 by 1 matrix returns its square root, and an unsymmetric matrix stops at the first line.

    Python: def chol_draw(A, mu, Z): import numpy as np; A = np.asarray(A, float); Z = np.atleast_2d(Z); n = len(A); d = np.sqrt(np.where(np.diag(A) > 0, np.diag(A), 1)); C = A/np.outer(d, d); bad = [k+1 for k in range(n) if A[k, k] <= 0 or np.linalg.eigvalsh(C[:k+1, :k+1])[0] <= 1e-14]; L = None if bad or not np.allclose(A, A.T) else np.linalg.cholesky(A); return {"L": L, "draws": None if L is None else np.asarray(mu)+Z@L.T, "fail_order": bad[0] if bad else 0} This returns the same factor and draws. The smallest eigenvalue of each leading block of the correlation form gives fail_order, 3 for the article's 0.9, 0.9 and 0 matrix, 2 for a matrix of ones and 1 for a zero first variance, with L and draws returned as None. A block whose smallest eigenvalue is 1E-14 or less counts as failing, so a semidefinite matrix fails while a valid 20 by 20 matrix with all correlations 0.9 returns its factor. An unsymmetric matrix whose lower triangle passes returns None with fail_order 0, a 1 by 1 matrix returns its square root and a 0 by 0 array returns empty arrays.

    Test (Article's draw reproduced): With the first worked example and the standard normal values in the first row, the draws round to minus 1.8, 0.42 and 0.2878. Expected result TRUE. FALSE shows the upper factor used in place of the lower, which gives about minus 1.782, 0.4685 and 0.3191, or a draw cell doubled or halved. Excel check =AND(ROUND(INDEX(DrawsFirst,1),4)=-1.8,ROUND(INDEX(DrawsSecond,1),4)=0.42,ROUND(INDEX(DrawsThird,1),4)=0.2878)

    Test (Fixed table with exact moments): With the four frozen rows (1, 1, 1), (1, -1, -1), (-1, 1, -1) and (-1, -1, 1), whose columns have mean 0, population variance 1 and no covariance, the draws have exactly the target means and covariances. Expected result TRUE. FALSE shows the upper factor used in place of the lower, which gives a third variance of about 0.00909 against 0.01, or any column of draws doubled or halved. Excel check =AND(ABS(AVERAGE(DrawsThird)-MeanThird)<1E-9,ABS(VAR.P(DrawsThird)-VarThird)<1E-9,ABS(COVARIANCE.P(DrawsThird,DrawsSecond)-CovThirdSecond)<1E-9,ABS(COVARIANCE.P(DrawsThird,DrawsFirst)-CovThirdFirst)<1E-9)

    Common error (Row vector of draws multiplied by the lower factor): The mirror image of HE-ER-PSA-001. The product z transposed L has covariance L transposed L, which for the article's matrix gives a first variance of 0.042304, a second of 0.004096 and a covariance of minus 0.003072 against targets of 0.04, 0.0064 and minus 0.0096, the article's figures. A row vector of draws goes with the upper factor, the form Neine and Curran use, and no error appears either way.

    Source: Higham NJ. Cholesky factorization. MIMS EPrint 2008.116, Manchester Institute for Mathematical Sciences, University of Manchester; 2008 (the version read). Published as WIREs Computational Statistics. 2009;1(2):251-254 (not seen). Section Computation. Neine M, Curran D. An algorithm to generate correlated input-parameters to be used in probabilistic sensitivity analyses. Journal of Market Access & Health Policy. 2021;9(1):1857052. Methods, section Correlation of parameters, and Results. R Core Team, chol documentation (HE-SR-CHOD-004) and NumPy Developers, numpy.linalg.cholesky documentation (HE-SR-CHOD-005).

    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); x_1 = mu_1 + l_11 * z_1; x_2 = mu_2 + l_21 * z_1 + l_22 * z_2; x_3 = mu_3 + l_31 * z_1 + l_32 * z_2 + l_33 * z_3

Try this function

Implementations

  • Excel

    Three-parameter Cholesky factor from named covariance cells

    With variances in VarFirst, VarSecond and VarThird and covariances in CovSecondFirst, CovThirdFirst and CovThirdSecond, the six formulas in order return the cells named CholFirstFirst, CholSecondFirst, CholThirdFirst, CholSecondSecond, CholThirdSecond and CholThirdThird. A negative argument shows #NUM! in the SQRT of the failing diagonal and in the cells that depend on it. An argument of exactly zero returns 0 with no error, so a zero second diagonal entry shows #DIV/0! in CholThirdSecond, and a zero CholThirdThird leaves a semidefinite matrix with nothing to flag it, although rounding can show #NUM! or a tiny value there instead. CholThirdThird therefore needs checking to be above zero. A blank variance cell counts as 0, so a blank VarFirst gives #DIV/0! in the cells below it.

    =SQRT(VarFirst); =CovSecondFirst/CholFirstFirst; =CovThirdFirst/CholFirstFirst; =SQRT(VarSecond-CholSecondFirst^2); =(CovThirdSecond-CholThirdFirst*CholSecondFirst)/CholSecondSecond; =SQRT(VarThird-CholThirdFirst^2-CholThirdSecond^2)

Assumptions

  • Symmetric positive definite matrix for the three-parameter column algorithm

    The matrix is symmetric and positive definite, which Higham defines as the quadratic form x transposed A x being positive for every non-zero x, or equivalently all eigenvalues being positive. The factor with a positive diagonal then exists and is unique. A covariance matrix of model parameters meets this when no parameter is an exact linear combination of the others (reasoning, as in the article).

  • Estimation scale and parameter order fixed before the column algorithm runs

    The entries hold variances and covariances on the scale on which the parameters were estimated, the condition of HE-AS-PSA-001. The rows of L follow the order of the matrix, so a sampled value belongs to the parameter in the same position. Reordering the parameters changes L, and the product L times L transposed then returns the reordered matrix (derived).

  • Only one triangle of the covariance matrix is read by Cholesky routines

    The chain reads only the lower triangle and takes the upper to be its mirror image. The R documentation for chol says only the upper triangular part is used and that the code does not check for symmetry, and the NumPy documentation says no check is made and only one triangle is used. A matrix typed with unequal mirror entries therefore gives a factor with no warning, and the factor differs between the two tools.

Worked examples

  • Neine and Curran's three-variable correlation matrix as a lower triangular factor

    With unit variances and all correlations 0.5 the chain returns 1, 0.5, 0.5, about 0.8660, about 0.2887 and about 0.8165. Neine and Curran print these entries as the upper triangular matrix with rows (1, 0.5, 0.5), (0, 0.866, 0.2887) and (0, 0, 0.8165), written C = L transposed L, which is the transpose of the factor here.

    a_11 = 1; a_21 = 0.5; a_31 = 0.5; a_22 = 1; a_32 = 0.5; a_33 = 1; l_11 = 1; l_21 = 0.5; l_31 = 0.5; l_22 = 0.8660254; l_32 = 0.2886751; l_33 = 0.8164966
  • Article's two regression coefficients with an unrelated third parameter

    All numbers are illustrative. The article's intercept and coefficient have standard errors 0.20 and 0.08 and a correlation of minus 0.6, so a_11 is 0.04, a_22 is 0.0064 and a_21 is minus 0.0096. A third parameter with variance 0.01 and no covariance with either adds a row of 0, 0 and 0.1, and the first two rows are the article's factor, entries 0.2, minus 0.048 and 0.064, the same values HE-FM-PSA-001 gives at rho of minus 0.6.

    a_11 = 0.04; a_21 = -0.0096; a_31 = 0; a_22 = 0.0064; a_32 = 0; a_33 = 0.01; l_11 = 0.2; l_21 = -0.048; l_31 = 0; l_22 = 0.064; l_32 = 0; l_33 = 0.1
  • Illustrative third coefficient correlated with both article coefficients

    All numbers are illustrative. A third coefficient has standard error 0.10, a correlation of minus 0.3 with the intercept and 0.2 with the article's coefficient, so a_31 is minus 0.006 and a_32 is 0.0016. The first column already explains 0.00144 of a_32, because l_31 times l_21 is minus 0.03 times minus 0.048, which leaves 0.00016 and an l_32 of 0.0025.

    a_11 = 0.04; a_21 = -0.0096; a_31 = -0.006; a_22 = 0.0064; a_32 = 0.0016; a_33 = 0.01; l_11 = 0.2; l_21 = -0.048; l_31 = -0.03; l_22 = 0.064; l_32 = 0.0025; l_33 = 0.0953612

Common errors

  • Cross-product term left out of the third row of a Cholesky factor

    Writing l_32 as a_32 divided by l_22 extends the two-parameter pattern without removing what the first column explains. For Neine and Curran's matrix it gives 0.5774 instead of 0.2887, so the draws have a second and third covariance of 0.75 instead of 0.5 (derived). For the illustrative third coefficient it gives 0.025 instead of 0.0025, ten times the correct entry.

  • Standard errors typed on the diagonal in place of variances

    The diagonal of a covariance matrix holds variances. With 0.20 typed in place of 0.04 for the article's intercept, l_11 is about 0.4472, so the intercept is drawn with a standard deviation more than twice its standard error of 0.20 (derived). No error appears, and a comparison of sample and target covariances shows it.

  • Cholesky factor built in one parameter order and mapped back in another

    If the matrix is entered with the article's coefficient first and the intercept second, l_11 is 0.08. Reading the first sampled value as the intercept then draws the intercept with a standard deviation of 0.08 instead of 0.20 (derived). The factor is correct for the order in which it was built, so nothing fails, and the article warns that sampled values must be mapped back to the same parameters.

Sources

  • Higham on the column-by-column Cholesky algorithm

    Higham NJ. Cholesky factorization. MIMS EPrint 2008.116, Manchester Institute for Mathematical Sciences, University of Manchester; 2008 (the version read). Published as WIREs Computational Statistics. 2009;1(2):251-254 (not seen). Section Introduction defines a positive definite matrix and gives the factorisation A = R transposed R or A = L L transposed, with a positive diagonal, as unique. Section Computation equates the elements of A and R transposed R, gives the algorithm that yields R a column at a time, and states that positive definiteness guarantees a positive argument of the square root. It gives the cost as n cubed over 3 flops plus lower-order terms, with n square roots. The article writes the same algorithm for L = R transposed, and these records follow the article.

    View source →

  • Neine and Curran's printed three-variable Cholesky matrix

    Neine M, Curran D. An algorithm to generate correlated input-parameters to be used in probabilistic sensitivity analyses. Journal of Market Access & Health Policy. 2021;9(1):1857052. Methods, section Correlation of parameters, gives the correlation matrix with all correlations 0.5 for three variables and its Cholesky decomposition matrix with rows (1, 0.5, 0.5), (0, 0.866, 0.2887) and (0, 0, 0.8165), written C = L transposed L.

    View source →

  • Dutch guideline naming the Cholesky method for correlated survival parameters

    Zorginstituut Nederland. Guideline for economic evaluations in healthcare, 2024 version. Section 4.7.2.2, Probabilistic analysis, which states that correlation must be maintained for, for example, parameters of parametric distributions fitted to Kaplan-Meier curves, and that this can be done, for example, by using the Cholesky decomposition method.

    View source →

  • R documentation on the triangle chol reads and returns

    R Core Team. The Cholesky decomposition, chol, package base. R documentation, accessed 7 November 2026. Section Details states that only the upper triangular part of x is used, section Value that the function returns the upper triangular factor R such that R'R = x, and section Warning that the code does not check for symmetry.

    View source →

  • NumPy documentation on the triangle numpy.linalg.cholesky reads

    NumPy Developers. numpy.linalg.cholesky. NumPy manual, accessed 7 November 2026. States that no checking is performed to verify whether the input is Hermitian and that only the lower or upper triangular and diagonal elements are used.

    View source →

Canonical Identity

This formula 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/formula/three-parameter-cholesky-factor-from-covariance-entries-by-the-column-algorithm