I have a symmetric but sparse matrix of 0's and 1's representing whether or not there is an edge or link between two objects --- an adjacency matrix. I am attempting to work with the command PAM in the cluster package in R, which requires either a dissimilarity-matrix (and in particular the upper-triangular of this matrix) or a distance.
Below find a representative matrix (although my matrix has many more edges and nodes and unlike this matrix is in fact sparse).
0 1 0 0
1 0 0 0
0 0 0 1
0 0 1 0
I require an upper-triangular version of my matrix which means that I need to obtain this matrix. my problem is that is that my matrix at least is singular so Matrix commands such as a regular LU decomposition or Choleski decomposition do not work with it.
here is the error message that I got when I tried my 64 * 64 sparse matrix:
Warning message:
In .local(x, ...) :
Exact singularity detected during LU decomposition: U[i,i]=0, i=20.
I have read over several posts here on sparse matrices including "Large Sparse Matrix to Triangular Matrix R"
but they do not seem to do exactly what I want.
I am wondering if anyone has advice on what R commands I should try to obtain my desired matrix. If necessary, I can attempt to program up my own function but I would rather not do so.