I’ve been trying to use a routine in R called Jackstraw. The essence of the routine is using a synthetic null for evaluating the statistical significance of cluster assignments.
Overall, I have discrete survey data (5 variables on 1-3 scale), so I’ve been trying to use partitioning around medoids (PAM) instead of k-means type clustering.
However, when using the ‘jackstraw_pam’ function, I get the following error code:
– ‘Error in solve.default(t(mod) %*% mod) :
Lapack routine dgesv: system is exactly singular: U[2,2] = 0’
I wondered if someone could help me overcome this problem. I wondered if the input data matrix needs transposed, or something?
As it stands, I’ve tried ‘jakcstraw_kmeans’ and this works. But not the desired ‘jackstraw_pam’ function, unfortunately.
I’ve attached some code below. Would love if anyone could help overcome the error.
install.packages("jackstraw")
library(cluster)
library(ggplot2)
library(jackstraw)
library(tibble)
#TOY DATA
X1 <- rep(1:3, times = 100)
X1 <- sample(X1)
X2 <- rep(1:3, times = 100)
X2 <- sample(X2)
X3 <- rep(1:3, times = 100)
X3 <- sample(X3)
X4 <- rep(1:3, times = 100)
X4 <- sample(X4)
X5 <- rep(1:3, times = 100)
X5 <- sample(X5)
Dat <- data.frame(X1, X2, X3, X4, X5)
Dat <- data.frame(lapply(Dat, function(x) as.numeric(as.character(x))))
#PAM CLUSTERING
pam <- pam(Dat, 3, metric = "manhattan")
#JACKSTRAW
DATMAT <- as.matrix(Dat)
JS <- jackstraw_pam(Dat, pam, s = 3, B =1000)
Resources used are:
https://cbml.science/post/test-of-cluster-memberships/;
https://rdrr.io/cran/jackstraw/man/jackstraw_pam.html