inv
is a S3
generic that calculates the inverse of the cross
product of a design matrix, also referred to as the “unscaled
covariance matrix”.
pinv
calculates \(M^{+} = (M^T M)^{-1} M^T\) for full (column) rank
matrices. However, it does not verify the matrix's rank.
inv(x, ...)# S3 method for matrix
inv(x, y = NULL, transpose = FALSE, ...)
# S3 method for array
inv(x, y = NULL, transpose = FALSE, ...)
# S3 method for qr
inv(x, p = x$rank, ...)
# S3 method for list
inv(x, p = x[[1L]]$rank, r = length(x),
vnames = dimnames(x[[1L]]$qr)[[2L]], nms = names(x), ...)
pinv(x)
A numeric matrix or array
pinv
returns the input matrix's pseudoinverse
A numeric matrix or array, a qr
object, or a list of
qr
objects
Unused
A numeric matrix or vector (for the matrix
and array
methods). If supplied, this will be multiplied by x
before the
inverse is calculated. Default: NULL
Logical. If FALSE
(the default), take the cross
product of the arguments. If TRUE
, use tcrossprod
The rank of the original matrix
The number of design matrices; i.e., the length of the input list
Character vector of the design matrix's variable names
The region names; i.e., the names of the input list
If x
is a matrix, the Cholesky decomposition of the cross product is
calculated (or using tcrossprod
if transpose=TRUE
), and
the inverse is calculated from that result. That is,
$$inv(X) = (X^T X)^{-1}$$
$$inv(X, transpose=TRUE) = (X X^T)^{-1}$$
$$inv(X, y) = (X^T y)^{-1}$$
If x
is a 3-dimensional array, then the inverse will be calculated for
each matrix along the 3rd dimension, with the same input arguments for each.
Finally, there is a method for objects with class qr
, and lists of QR
decomposition objects.