pinv: Moore-Penrose pseudo-inverse of a matrix

View source: R/pinv.R

pinvR Documentation

Moore-Penrose pseudo-inverse of a matrix

Description

Calculation of the Moore-Penrose (MP) pseudo-inverse of a matrix X.

Usage


pinv(X, tol = sqrt(.Machine$double.eps))

Arguments

X

A n x p matrix or data frame.

tol

A relative tolerance to detect zero singular values.

Value

A list of outputs, such as:

Xplus

The MP pseudo-inverse.

Examples


n <- 10
p <- 6
set.seed(1)
X <- matrix(rnorm(n * p, mean = 10), ncol = p, byrow = TRUE)
y <- rnorm(n)
set.seed(NULL)

pinv(X)

tcrossprod(pinv(X)$Xplus, t(y))
lm(y ~ X - 1)


mlesnoff/rnirs documentation built on April 24, 2023, 4:17 a.m.