# [R] How Can SVD Reconstruct a Matrix

Thu Aug 14 08:57:47 CEST 2014

```Hi All,

I've inherited some R code that I can't work out what they've done.  It
appears to work and give sort of reasonable answers, I'm just trying to
work out why they've done what they have.  I suspect that this is a
simple vector identity that I've just been staring at too long and have
forgotten...

The code:

GGt <- M0 - M1 %*% M0inv %*% t(M1)
svdGG <- svd(GGt)
Gmat <- svdGG\$u %*% diag(sqrt(svdGG\$d))

It is supposed to solve:

G*G^T = M0 - M1*M0^-1*M1^T

for G, where G^T is the transpose of G.  It is designed to reproduce a
numerical method described in two papers:

Srikanthan and Pegram, Journal of Hydrology, 371 (2009) 142-153,
Equation A13, who suggest the SVD method but don't describe the
specifics, eg: "...G is found by singular value decomposition..."

Alternatively, Matalas (1967) Water Resources Research 3 (4) 937-945,
Equation 17, say that the above can be solved using Principle Component
Analysis (PCA).

I use PCA (specifically POD) and SVD to look at the components after
decomposition, so I'm a bit lost as to how the original matrix G can be
constructed in this case from only the singular values and the left
singular vectors.  Like I said earlier, I suspect that this is a simple
array identity that I've forgotten.  My Google Fu is letting me down at
this point.

My questions:
1) What is the proof, or where can I better find it to satisfy myself,
that the above works?

2) Alternatively, can anyone suggest how I could apply PCA in R to
compute the same?