View source: R/utility_functions.R
extract_cc | R Documentation |
Given two vectors, generates the coefficient of congruence between them. This is equivalent to the cosine of the angle between both vectors.
extract_cc(vector1, vector2)
vector1 |
First numerical vector for the calculation. |
vector2 |
Second numerical vector for the calculation. |
The congurence coefficient is calculated as:
CC_{x,y} = sum(x_{i} X y_{i}) / sqrt(sum(x_{i}^2) X sum(y{i})^2)
Where x_{i} and y_{i} are the loadings of the variable i on the component or factor x and y respectively. CC is equivalent to the cosine of the angle between two vectors (the cosine similarity metric) and has a numerical range from -1 to 1. The sign of a component is arbitrary and can be flipped without affecting its interpretation. Here we consider the absolute value of CC (0 to 1). The closer the CC is to 1, the more similar the two components are.
Returns the coefficent of congruence (CC) between vector1 and vector2.
Abel Torres Espin
Burt C. The Factorial Study of Temperamental Traits. Br J Stat Psychol. 1948;1(3):178–203.
Tucker, L. R. A method for synthesis of factor analysis studies. Personnel Research Section Report No.984. Washington D.C.: Department of the Army.; 1951.
data(mtcars) pca_mtcars_1<-prcomp(mtcars, center = TRUE, scale = TRUE) #Second pca with a subsetted mtcars as an example of comparing loading patterns #from two proximal datasets pca_mtcars_2<-prcomp(mtcars[1:20,], center = TRUE, scale = TRUE) s.loadings_1<-stand_loadings(pca = pca_mtcars_1, pca_data = mtcars) s.loadings_2<-stand_loadings(pca = pca_mtcars_2, pca_data = mtcars[1:20,]) extract_cc(s.loadings_1[,1], s.loadings_2[,1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.