There is a software called Brandmap which can return a biplot from a matrix. I am trying to run the same result in R but the coordinates are not the same.
First I input a simple matrix into the software.
x1 x2 x3
a 6 3 7
b 8 6 7
c 9 4 2
There were several options of data centering and I chose to center the data by subtracting every number in the matrix from its (row mean*column mean/grand mean).
x1 x2 x3
a -1.076923 -1.00 2.0769231
b -1.288462 0.75 0.5384615
c 2.365385 0.25 -2.6153846
Then I chose column factorization to create a biplot. I guess it means a covariance biplot which the singular values are totally assigned to the right singular vectors.
It showed the coordinates:
dim1 dim2
x1 -2.81 -0.73
x2 -0.55 1.15
x3 3.36 -0.42
a 1.58 -1.78
b 0.75 2.26
c -2.33 -0.48
I tried to calculate the same results in R.
> P = matrix(c(6,8,9,3,6,4,7,7,2),nrow=3)
> row.names(P)=c("a","b","c")
> colnames(P)=c("x1","x2","x3")
> P
x1 x2 x3
a 6 3 7
b 8 6 7
c 9 4 2
> r1 = matrix(rep(1,3)) #row sum
> c1 = matrix(rep(1,3)) #column sum
> r = P%*%r1
> c = t(P)%*%c1
> L = P - r%*%t(c)/sum(P) #subtract row mean*column mean/grand mean
> L
x1 x2 x3
a -1.076923 -1.00 2.0769231
b -1.288462 0.75 0.5384615
c 2.365385 0.25 -2.6153846
> S = svd(L)
> S$v%*%diag(S$d)
[,1] [,2] [,3]
[1,] 2.8077724 0.7289408 -8.10596e-17
[2,] 0.5487104 -1.1506159 -8.10596e-17
[3,] -3.3564829 0.4216750 -8.10596e-17
> S$u
[,1] [,2] [,3]
[1,] -0.5420705 0.6105950 0.5773503
[2,] -0.2577555 -0.7747443 0.5773503
[3,] 0.7998260 0.1641494 0.5773503
I found that the values in the right vector are the same but with negative sign and all the values in the left vector are multiplied by -2.918.
I am not sure if there is any weighting in the calculation of that software. What kind of adjustment I can try so that I can run the same results in R?