Why is it impossible to do a PCA in R using principal
from psych
package without warnings with a matrix, which has more columns than rows (dim(t)=6x2404
)? If I use prcomp
, everything is fine.
The difference between both methods is that principal
computes a correlation or covariance matrix while prcomp
uses SVD.
This warnings occur:
The determinant of the smoothed correlation was zero.
This means the objective function is not defined.
Chi square is based upon observed residuals.
The determinant of the smoothed correlation was zero.
This means the objective function is not defined for the null model either.
The Chi square is thus based upon observed correlations.
In factor.stats, the correlation matrix is singular, an approximation is used
Warning messages:
1: In cor.smooth(r) : Matrix was not positive definite, smoothing was done
2: In fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
In factor.stats, the correlation matrix is singular, and we could not calculate the beta weights for factor score estimates
3: In psych::principal(transposed_matrix, nfactors = 3) :
The matrix is not positive semi-definite, scores found from Structure loadings
Basically, I'm doing this:
I have a matrix with 2404 temperature samples over time as variables/columns and 6 measurement locations as observations/rows (this is called "T-Mode PCA" by Richman,1986). However, the matrix contains no missing values and is a transposed from a matrix, where the samples are rows and the stations are columns. The original matrix has no problems, whether with psych::principal
(a.k.a. Eigendecomposition) nor prcomp
(SVD). And I'm interested, why the transposed matrix has such problems with psych::principal
.
Here is a MWE, which throws the warnings as well:
original_matrix = data.frame(replicate(6,sample(250:300,2404,rep=TRUE)))
transposed_matrix = t(original_matrix)
pca_temper = psych::principal(transposed_matrix, nfactors = 3)