mpinv: Moore-Penrose Pseudoinverse

Description Usage Arguments Details Value Note Author(s) References Examples

Description

Calculates the Moore-Penrose pseudoinverse of the input matrix using a truncated singular value decomposition.

Usage

1
mpinv(X, tol = NULL)

Arguments

X

Real-valued matrix.

tol

Stability tolerance for singular values.

Details

Basically returns Y$v %*% diag(1/Y$d) %*% t(Y$u) where Y = svd(X).

Value

Returns pseudoinverse of X.

Note

Default tolerance is tol = max(dim(X)) * .Machine$double.eps.

Author(s)

Nathaniel E. Helwig <helwig@umn.edu>

References

Moore, E. H. (1920). On the reciprocal of the general algebraic matrix. Bulletin of the American Mathematical Society 26, 394-395.

Penrose, R. (1950). A generalized inverse for matrices. Mathematical Proceedings of the Cambridge Philosophical Society 51, 406-413.

Examples

1
2
3
4
5
6
7
8
9
##########   EXAMPLE   ##########

set.seed(1)
X <- matrix(rnorm(2000),100,20)
Xi <- mpinv(X)
sum( ( X - X %*% Xi %*% X )^2 )
sum( ( Xi - Xi %*% X %*% Xi )^2 )
isSymmetric(X %*% Xi)
isSymmetric(Xi %*% X)

multiway documentation built on May 2, 2019, 6:47 a.m.