Author-reviewedEvidence: highv1.0.0

Matrix Algebra

Matrix algebra provides a compact way to represent and manipulate related quantities arranged in rows and columns.

Status
Published, version 1.0.0
Last reviewed
25 Sep 2026, by Dr Darrin Baines
Report a problem
Tell us if something is wrong or out of date

Concept Architecture

Why matrix algebra matters in health economics

In health economics, it is especially useful when a model must track several health states, patient groups, treatments, time periods or regression parameters at once. This page explains the main matrix operations, shows how they support economic models and statistical estimation, and identifies the checks needed to prevent mathematically valid calculations from producing misleading results.

A matrix is not a model by itself. It is a mathematical structure that makes a model's assumptions and calculations easier to express, reproduce and implement.

How vectors and matrices organise information

A vector is an ordered list of values, while a matrix is a rectangular array of values. The position of each value carries meaning, so rows and columns must be labelled consistently before any calculation is performed. Changing the order of health states or patient groups without making the same change everywhere can silently invalidate a model.

An (m \times n) matrix (A) has (m) rows and (n) columns:

A=[a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮am1am2⋯amn]A = \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix}

The element (a_{ij}) is the value in row (i) and column (j). A column vector has one column, and a row vector has one row.

StructureTypical health-economic interpretationExample
Column vectorA population distribution or parameter setNumbers of patients in each health state
Row vectorA set of values applied across categoriesCosts assigned to each health state
Square matrixRelationships between the same ordered categoriesTransition probabilities between health states
Rectangular matrixRelationships between different sets of variablesPatient characteristics used to estimate regression coefficients
Diagonal matrixCategory-specific values without cross-category interactionDiscount factors or variances
Identity matrixA transformation that leaves a vector unchangedThe matrix (I) in linear systems

The operations that models use most often

Matrix operations combine or transform organised quantities according to precise dimensional rules. Addition and subtraction require matrices of the same dimensions, while multiplication requires the number of columns in the first matrix to equal the number of rows in the second. A dimension check should therefore be treated as a model-integrity check rather than a formatting detail.

For matrices (A) and (B) with the same dimensions, addition is element by element:

(A+B)ij=aij+bij(A+B)_{ij}=a_{ij}+b_{ij}

Multiplying an (m \times n) matrix (A) by an (n \times p) matrix (B) produces an (m \times p) matrix (C):

C=AB,cij=∑k=1naikbkjC=AB, \qquad c_{ij}=\sum_{k=1}^{n}a_{ik}b_{kj}

Matrix multiplication is generally not commutative, so (AB) does not usually equal (BA). The order of multiplication encodes the direction of the transformation and must match the model's interpretation.

Other commonly used operations include:

  • Scalar multiplication multiplies every element of a matrix by the same number.
  • Transposition exchanges rows and columns, so the transpose of (A) is written (A^{\mathsf T}).
  • Inversion finds (A^{-1}), when it exists, such that (AA^{-1}=I).
  • Element-wise multiplication multiplies corresponding elements and is different from ordinary matrix multiplication.
  • Matrix powers apply a square matrix repeatedly, as in (P^t) for a transition matrix over (t) cycles.

How transition matrices move a cohort through health states

In a cohort state-transition model, a state vector records the proportion or number of patients in each health state at a particular cycle. A transition matrix records the probability of moving from each current state to each next state. Their multiplication updates the cohort distribution while preserving the relationship between state order and transition probabilities.

Using the row-vector convention, the cohort evolves as:

st+1=stPs_{t+1}=s_tP

and after (t) cycles:

st=s0Pts_t=s_0P^t

where (s_0) is the initial state distribution and (P) is the transition-probability matrix. Under this convention, each row of (P) represents the probabilities of leaving one current state and should sum to one.

The row-vector and column-vector conventions are both valid, but they cannot be mixed. With a column-vector convention, the equivalent update is (s_{t+1}=Ps_t), and the orientation of the transition matrix changes accordingly.

A worked cohort-model example

Consider a three-state model with the states Stable, Progressed and Dead. At the start, all patients are Stable, and the transition matrix describes one cycle of movement between the states. The calculation below shows how matrix multiplication converts those transition assumptions into the next-cycle state distribution.

Let:

s0=[100]s_0= \begin{bmatrix} 1 & 0 & 0 \end{bmatrix}

and:

P=[0.700.250.050.000.800.200.000.001.00]P= \begin{bmatrix} 0.70 & 0.25 & 0.05 \\ 0.00 & 0.80 & 0.20 \\ 0.00 & 0.00 & 1.00 \end{bmatrix}

The next-cycle distribution is:

s1=s0P=[0.700.250.05]s_1=s_0P= \begin{bmatrix} 0.70 & 0.25 & 0.05 \end{bmatrix}

The second-cycle distribution is:

s2=s1P=[0.490.3750.135]s_2=s_1P= \begin{bmatrix} 0.49 & 0.375 & 0.135 \end{bmatrix}

After two cycles, 49.0% of the original cohort remains Stable, 37.5% is Progressed and 13.5% is Dead. The example assumes time-homogeneous transitions because the same matrix is used in every cycle; if risks change over time, the model must use cycle-specific matrices.

How matrices convert state occupancy into costs and outcomes

Once the model has calculated the number or proportion of patients in each state, vectors can assign a cost and health outcome to those states. A dot product then converts the state distribution into an expected value for a cycle. Repeating and summing this calculation produces total model outcomes.

If (c) is a column vector of state costs and (u) is a column vector of state utilities, then expected cycle cost and expected cycle utility are:

Ct=stcC_t=s_tc Ut=stuU_t=s_tu

Discounted totals over (T) cycles may be written as:

Ctotal=∑t=0TdtCstcC_{\text{total}}=\sum_{t=0}^{T}d_t^{C}s_tc Qtotal=∑t=0TdtQstuΔtQ_{\text{total}}=\sum_{t=0}^{T}d_t^{Q}s_tu\Delta t

where (d_t^{C}) and (d_t^{Q}) are the applicable cost and health-outcome discount factors, and (\Delta t) is the cycle length expressed in years. Half-cycle correction or another within-cycle adjustment may also be required because state occupancy observed only at cycle boundaries can misrepresent when transitions occur.

How matrix algebra supports regression

Regression models use matrix notation to represent many observations and explanatory variables in one equation. This notation clarifies the connection between observed outcomes, model coefficients and residual error. It also underlies the computational methods used by statistical software.

The linear model can be written as:

y=Xβ+εy=X\beta+\varepsilon

where (y) is the outcome vector, (X) is the design matrix, (\beta) is the coefficient vector and (\varepsilon) is the error vector. Under the ordinary least-squares assumptions, the coefficient estimator is:

β^=(XTX)−1XTy\hat{\beta}=(X^{\mathsf T}X)^{-1}X^{\mathsf T}y

This expression is conceptually important, but software commonly uses numerically more stable decompositions instead of directly calculating the inverse. If the columns of (X) are linearly dependent, (X^{\mathsf T}X) is singular and the coefficients cannot be uniquely identified without changing the specification or applying an appropriate regularisation method.

Matrix properties that affect interpretation

Several matrix properties determine whether a calculation is possible and whether its result is stable. These properties are not merely technical: they can expose redundant variables, incoherent transition structures or uncertainty that is difficult to estimate. Analysts should investigate the cause of a problematic matrix instead of treating a software warning as an inconvenience.

  • A square matrix has the same number of rows and columns.
  • A symmetric matrix equals its transpose and commonly represents a variance-covariance structure.
  • A diagonal matrix has non-zero values only on its main diagonal.
  • A stochastic matrix contains non-negative transition probabilities whose relevant rows or columns sum to one.
  • A singular matrix has no inverse and often indicates exact linear dependence.
  • An ill-conditioned matrix is technically invertible but can produce unstable results when inputs change slightly.
  • An absorbing state has probability one of remaining in that state once entered.

Eigenvalues and eigenvectors describe directions that are scaled, rather than redirected, by a square matrix:

Av=λvAv=\lambda v

In transition modelling, they can help describe long-run behaviour and whether a distribution approaches a stable pattern. Long-run mathematical behaviour should still be interpreted against the model's time horizon, clinical plausibility and absorbing-state structure.

How uncertainty is represented with covariance matrices

A variance-covariance matrix records the variance of each parameter on its diagonal and the covariance between parameter pairs elsewhere. It allows an analysis to preserve correlation when jointly sampling parameters or propagating uncertainty. Ignoring meaningful covariance can generate implausible parameter combinations and distort decision uncertainty.

For a parameter vector (\theta), the variance-covariance matrix is:

Σ=[Var⁡(θ1)Cov⁡(θ1,θ2)⋯Cov⁡(θ2,θ1)Var⁡(θ2)⋯⋮⋮⋱]\Sigma= \begin{bmatrix} \operatorname{Var}(\theta_1) & \operatorname{Cov}(\theta_1,\theta_2) & \cdots \\ \operatorname{Cov}(\theta_2,\theta_1) & \operatorname{Var}(\theta_2) & \cdots \\ \vdots & \vdots & \ddots \end{bmatrix}

A valid covariance matrix must be symmetric and positive semidefinite. Rounding, inconsistent estimates or an invalid correlation specification can violate this requirement and prevent multivariate sampling.

Common implementation errors

Matrix-based calculations can fail visibly through a dimension error, but more dangerous errors may still return a plausible number. The strongest protection is to combine structural checks with independent calculations and clinically interpretable test cases. Every automated matrix operation should retain labels or explicit documentation of the ordering it assumes.

  • Mismatched ordering occurs when a state vector and transition matrix use different state sequences.
  • Wrong orientation occurs when a row-vector calculation is implemented as if it used column vectors, or vice versa.
  • Invalid transition rows occur when probabilities are negative, exceed one or do not sum to one within tolerance.
  • Confusing matrix and element-wise multiplication changes the mathematical operation while often preserving compatible dimensions.
  • Directly inverting a poorly conditioned matrix can amplify numerical error.
  • Treating an absorbing state as reversible can create clinically impossible movement after death or another terminal event.
  • Omitting time dependence can make a repeated transition matrix inconsistent with changing hazards, ageing or treatment effects.
  • Rounding too early can accumulate error over many cycles.

A practical validation sequence

Validation should begin with the meaning and ordering of the data before testing the arithmetic. Small transparent examples are especially valuable because their expected results can be calculated independently. The following sequence provides a reproducible minimum check for matrix-based health-economic calculations.

  1. Label every row and column and confirm that the ordering is identical across connected vectors and matrices.
  2. Check every dimension before addition, multiplication, transposition or inversion.
  3. Test required constraints, including probability bounds, row or column sums, symmetry and positive semidefiniteness where applicable.
  4. Recalculate a small example manually and compare every intermediate vector with the implementation.
  5. Test edge cases, such as zero transition risk, complete absorption and identical treatment arms.
  6. Vary one input at a time and confirm that the direction and magnitude of change are plausible.
  7. Inspect numerical stability when a matrix is singular, nearly singular or derived from highly correlated parameters.
  8. Reconcile aggregate outputs with cohort totals, expected costs, expected health outcomes and any independent implementation.

Matrix algebra improves transparency only when the meaning of each element remains traceable. The final validation question is therefore not just whether the software completed the calculation, but whether the resulting transformation correctly represents the clinical and economic process being modelled.

Library

Publications

2
  • Book

    A First Course in Graph Theory — Gary Chartrand & Ping Zhang, 1st Edition ed., 2012 (Dover Publications)

    An introductory treatment of graph-theoretic structures and methods, including paths, trees, connectivity and graph algorithms.

  • Book

    Accuracy and Stability of Numerical Algorithms — Nicholas J. Higham, 2nd Edition ed., 2002 (Society for Industrial and Applied Mathematics (SIAM))

    The standard reference on floating-point error, conditioning, stability and the numerical reliability of matrix, polynomial and linear-algebra algorithms.

Frequently Asked Questions (6)

  • What is matrix algebra?

    The branch of mathematics concerned with the representation and manipulation of matrices and the operations performed on them.

    Source: Golub GH, Van Loan CF. Matrix Computations. 4th ed. Johns Hopkins University Press; 2013.

  • What does matrix algebra deal with?

    Matrix algebra deals with the representation and manipulation of matrices and the operations performed on them, treating matrices as objects that can be combined and transformed by defined rules. It provides the framework in which matrices are added, multiplied and otherwise manipulated. This concern with matrices and their operations is what matrix algebra is about By giving consistent rules for combining and transforming matrices, the field lets large systems of relationships be written and solved compactly, which is why it underlies so much applied computation.

    Source: Golub GH, Van Loan CF. Matrix Computations. 4th ed. Johns Hopkins University Press; 2013.

  • What operations fall within matrix algebra?

    The operations that fall within matrix algebra are those performed on matrices, such as their addition, multiplication and other manipulations, since matrix algebra is the branch of mathematics concerned with representing and manipulating matrices. It defines how these operations behave and combine. Covering the operations performed on matrices is part of what matrix algebra encompasses By giving consistent rules for combining and transforming matrices, the field lets large systems of relationships be written and solved compactly, which is why it underlies so much applied computation.

    Source: Golub GH, Van Loan CF. Matrix Computations. 4th ed. Johns Hopkins University Press; 2013.

  • What kind of objects does matrix algebra study?

    Matrix algebra studies matrices, the rectangular arrays it represents and manipulates through defined operations. As the branch of mathematics concerned with matrices and the operations performed on them, it takes these arrays as its central objects. Focusing on matrices is what characterises matrix algebra as a field By giving consistent rules for combining and transforming matrices, the field lets large systems of relationships be written and solved compactly, which is why it underlies so much applied computation.

    Source: Golub GH, Van Loan CF. Matrix Computations. 4th ed. Johns Hopkins University Press; 2013.

  • Why is matrix algebra useful?

    Matrix algebra is useful because it provides consistent rules for representing and manipulating matrices and the operations performed on them, allowing systems of relationships to be handled compactly and systematically. Many problems across mathematics and its applications are expressed and solved in matrix terms. This organising power over matrices and their operations is why matrix algebra is valuable By giving consistent rules for combining and transforming matrices, the field lets large systems of relationships be written and solved compactly, which is why it underlies so much applied computation.

    Source: Golub GH, Van Loan CF. Matrix Computations. 4th ed. Johns Hopkins University Press; 2013.

  • How does matrix algebra relate to matrix multiplication?

    Matrix algebra is the branch of mathematics concerned with representing and manipulating matrices and the operations performed on them, while matrix multiplication is one such operation, combining two compatible matrices through the dot products of their rows and columns. Matrix multiplication is therefore an operation within matrix algebra. The two are connected as the general field and one of the operations it defines By giving consistent rules for combining and transforming matrices, the field lets large systems of relationships be written and solved compactly, which is why it underlies so much applied computation.

    Source: Golub GH, Van Loan CF. Matrix Computations. 4th ed. Johns Hopkins University Press; 2013.

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 25 Sep 2026

Content version: 1.0.0

Canonical Identity

Term code
CS-LA-MO-001

Stable URI · Machine-readable · Resolvable · CC BY 4.0