R/mginv.R

Defines functions mginv

mginv <-
function(X, tol = sqrt(.Machine$double.eps)) { 
dnx <- dimnames(X) 
if(is.null(dnx)) dnx <- vector("list", 2) 
s <- svd(X) 
nz <- s$d > tol * s$d[1] 
structure( 
if(any(nz)) s$v[, nz] %*% (t(s$u[, nz])/s$d[nz]) else X, 
dimnames = dnx[2:1]) 
}

Try the SSN package in your browser

Any scripts or data that you put into this service are public.

SSN documentation built on March 7, 2023, 5:30 p.m.