I am conducting a Principal Components Analysis (ACP) in R to summarize the monthly correlation patterns found in 30 sampled regions. To do this, I am using as input an array of 10 (months) x 30 (regions) -download here -.
At first I was working with the function psych::principal
, but when entering the matrix I get the following error:
pc <- principal(dat,nfactors = 2, residuals = FALSE, rotate="varimax", n.obs=NA, covar=TRUE,scores=TRUE, missing=FALSE, impute="median", oblique.scores=TRUE, method="regression")
Warning messages: 1: In cor.smooth (r): Matrix was not positive definite, smoothing was done 2: Main (dat): The matrix is not positive semi-definite, scores found from Structure loadings
The function is executed, the problem is that pc $ weights is the same as pc $ loadings. When the matrix is square, or the number of columns is less than that of the rows, the weights are obtained without problem, however, it is not the case of my data.
The function principal
, using the sample data of the function, allows me to directly extract the loadings
, scores
and weights
. It is important to extract the weights
of the main components because I need to express the scores
in the same correlation unit as the input variable.
I have tried the function stats::prcomp
with my data and it does not alert me of any error, but it does not return at a glance the weights as they are defined in principal
.
I thank you in advance for any help provided. Thank you.