pseudoinverse             package:GeneTS             R Documentation

_P_s_e_u_d_o_i_n_v_e_r_s_e _o_f _a _M_a_t_r_i_x

_D_e_s_c_r_i_p_t_i_o_n:

     The standard definition for the inverse of a matrix fails  if the
     matrix is not square or singular. However, one can generalize the
     inverse using singular value decomposition. Any rectangular real
     matrix M can be decomposed as

     M = U diag(D[i] V',

     where U and V are orthogonal, V' means V transposed, and  D is a
     diagonal matrix with the singular values (see 'svd'). The
     pseudoinverse (also known as MoorePenrose inverse) is then
     obtained as

     IM = V diag(1/D[i]) U' .

     If the matrix M is singular or ill-conditioned the inverse is
     approximated by setting 1/D[i] <- 0 for small singular values
     (D[i] <= tol*max(D)).   The pseudoinverse has the property that
     the sum of the squares of all the entries in (IM %*% M - I), where
     I is an appropriate identity matrix, is minimized. For
     non-singular matrices the pseudoinverse is equivalent to the
     standard inverse.

_U_s_a_g_e:

     pseudoinverse(m, tol = sqrt(.Machine$double.eps))

_A_r_g_u_m_e_n_t_s:

       m: matrix

     tol: tolerance - singular values larger than tol times the maximum
          singular value are considered non-zero

_V_a_l_u_e:

     A matrix (the pseudoinverse of m).

_A_u_t_h_o_r(_s):

     Korbinian Strimmer (<URL:
     http://www.stat.uni-muenchen.de/~strimmer/>).

_S_e_e _A_l_s_o:

     'svd', 'solve', 'ginv'.

_E_x_a_m_p_l_e_s:

     # load GeneTS library
     library(GeneTS)

     # a singular matrix
     m <- rbind(
     c(1,2),
     c(1,2)
     )

     # not possible to invert exactly
     try(solve(m))

     # pseudoinverse
     p <- pseudoinverse(m)
     p

     # characteristics of the pseudoinverse
     zapsmall( m %*% p %*% m )  ==  zapsmall( m )
     zapsmall( p %*% m %*% p )  ==  zapsmall( p )
     zapsmall( p %*% m )  ==  zapsmall( t(p %*% m ) )
     zapsmall( m %*% p )  ==  zapsmall( t(m %*% p ) )

     # example with an invertable matrix
     m2 <- rbind(
     c(1,1),
     c(1,0)
     )
     zapsmall( solve(m2) ) == zapsmall( pseudoinverse(m2) )

