Common quadratic forms
xTAx(x, A)xAxT(x, A)
xTAx_solve(x, A, ...)
xTAx_qrsolve(x, A, tol = 1e-07, ...)
sandwich_solve(A, B, ...)
xTAx_eigen(x, A, tol = sqrt(.Machine$double.eps), ...)
a vector
a square matrix
additional arguments to subroutines
tolerance argument passed to the relevant subroutine
a square matrix
xTAx()
: Evaluate \(x'Ax\) for vector \(x\) and square
matrix \(A\).
xAxT()
: Evaluate \(xAx'\) for vector \(x\) and square
matrix \(A\).
xTAx_solve()
: Evaluate \(x'A^{-1}x\) for vector \(x\) and
invertible matrix \(A\) using solve()
.
xTAx_qrsolve()
: Evaluate \(x'A^{-1}x\) for vector \(x\) and
matrix \(A\) using QR decomposition and confirming that \(x\)
is in the span of \(A\) if \(A\) is singular; returns rank
and nullity
as attributes just in case subsequent calculations
(e.g., hypothesis test degrees of freedom) are affected.
sandwich_solve()
: Evaluate \(A^{-1}B(A')^{-1}\) for \(B\) a
square matrix and \(A\) invertible.
xTAx_eigen()
: Evaluate \(x' A^{-1} x\) for vector \(x\) and
matrix \(A\) (symmetric, nonnegative-definite) via
eigendecomposition; returns rank
and nullity
as attributes
just in case subsequent calculations (e.g., hypothesis test
degrees of freedom) are affected.
Decompose \(A = P L P'\) for \(L\) diagonal matrix of eigenvalues and \(P\) orthogonal. Then \(A^{-1} = P L^{-1} P'\).
Substituting, $$x' A^{-1} x = x' P L^{-1} P' x = h' L^{-1} h$$ for \(h = P' x\).
These are somewhat inspired by emulator::quad.form.inv() and others.