### Install Development Version of ClustOfVar Source: https://cran.r-project.org/web/packages/ClustOfVar/readme/README.html Install the latest development version of the ClustOfVar package from GitHub. This requires the devtools package to be installed first. ```r devtools::install_github("chavent/ClustOfVar") # This needs the devtools package to be installed : # install.packages("devtools") ``` -------------------------------- ### kmeansvar with Random Initialization Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Applies the kmeansvar function with a specified number of clusters and multiple random starts for initialization. This is useful when an initial partition is not known. ```R #a random set of variables is chosen as the initial cluster centers, nstart=10 times part1 <- kmeansvar(X.quanti=decathlon[,1:10],init=5,nstart=10) summary(part1) ``` -------------------------------- ### GET /plot/loadings Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Plots a dotchart with the loadings of the variables in each cluster. ```APIDOC ## GET /plot/loadings ### Description Plot dotchart with the loadings of the variables in each cluster. ### Method GET ### Endpoint /plot/loadings ### Parameters #### Query Parameters - **x** (clustvar) - Required - An object of class clustvar obtained with cutreevar or kmeansvar. ### Response #### Success Response (200) - **coord.quanti** (matrix) - Coordinates of quantitative variables belonging to cluster k. - **coord.levels** (matrix) - Coordinates of levels of categorical variables belonging to cluster k. ``` -------------------------------- ### Perform hierarchical clustering with hclustvar Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Usage examples for clustering quantitative, qualitative, and mixed variable datasets. ```R hclustvar(X.quanti = NULL, X.quali = NULL, init = NULL) ``` ```R #quantitative variables data(decathlon) tree <- hclustvar(X.quanti=decathlon[,1:10], init=NULL) plot(tree) #qualitative variables with missing values data(vnf) tree_NA <- hclustvar(X.quali=vnf) plot(tree_NA) vnf2<-na.omit(vnf) tree <- hclustvar(X.quali=vnf2) plot(tree) #mixture of quantitative and qualitative variables data(wine) X.quanti <- PCAmixdata::splitmix(wine)$X.quanti X.quali <- PCAmixdata::splitmix(wine)$X.quali tree <- hclustvar(X.quanti,X.quali) plot(tree) ``` -------------------------------- ### Perform hierarchical clustering with hclustvar2 Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Usage examples for clustering variables based on a covariance or correlation matrix. ```R hclustvar2(x, init = NULL) ``` ```R data(decathlon) x <- cor(decathlon[,1:10]) tree <- hclustvar2(x) plot(tree, hang = -1, xlab="", sub="") ``` -------------------------------- ### GET /plot/stability Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Plots the index of stability of variable partitions against the number of clusters. ```APIDOC ## GET /plot/stability ### Description Plot of the index of stability of the partitions against the number of clusters. ### Method GET ### Endpoint /plot/stability ### Parameters #### Query Parameters - **x** (clustab) - Required - An object of class clustab. - **nmin** (integer) - Optional - The minimum number of clusters in the plot. - **nmax** (integer) - Optional - The maximum number of clusters in the plot. ``` -------------------------------- ### GET /plot/dendrogram Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Generates a dendrogram of the hierarchy of variables or an aggregation levels plot. ```APIDOC ## GET /plot/dendrogram ### Description Dendrogram of the hierarchy of variables resulting from hclustvar and aggregation levels plot. ### Method GET ### Endpoint /plot/dendrogram ### Parameters #### Query Parameters - **x** (hclustvar) - Required - An object of class hclustvar. - **type** (string) - Optional - If type="tree" plot of the dendrogram and if type="index" aggregation levels plot. - **sub** (string) - Optional - A sub title for the plot. ``` -------------------------------- ### bootvar Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Draws a bootstrap sample from quantitative and categorical matrices. ```APIDOC ## bootvar ### Description Draw a bootstrap sample from X.quanti and a bootstrap sample from X.quali. ### Parameters #### Arguments - **X.quanti** (matrix) - Optional - A numeric matrix of data. - **X.quali** (matrix) - Optional - A categorical matrix of data. ``` -------------------------------- ### Load the vnf dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Loads the user satisfaction survey dataset containing 1232 observations and 14 qualitative variables. ```R data(vnf) ``` -------------------------------- ### Load the wine dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Loads the wine dataset containing 21 rows and 31 columns of sensory descriptors. ```R data(wine) ``` -------------------------------- ### Load Flower Dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Loads the flower dataset containing characteristics for 18 popular flowers. ```R data(flower) ``` -------------------------------- ### Summary Method for hclustvar Objects Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Provides a summary of an object of class 'hclustvar'. ```APIDOC ## Summary of a 'hclustvar' object ### Description This is a method for the function summary for objects of the class `hclustvar`. ### Usage ```R ## S3 method for class 'hclustvar' summary(object, ...) ``` ### Arguments - **object** (hclustvar) - An object of class `hclustvar`. - **...** - Further arguments passed to or from other methods. ``` -------------------------------- ### kmeansvar with Predefined Initial Partition Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Uses kmeansvar with an initial partition derived from hierarchical clustering. The 'matsim' argument is set to TRUE to calculate similarity matrices. ```R #the partition from the hierarchical clustering is chosen as initial partition part_init<-cutreevar(tree,5)$cluster part2<-kmeansvar(X.quanti=decathlon[,1:10],init=part_init,matsim=TRUE) summary(part2) part2$sim ``` -------------------------------- ### Summarize Variable Partition in R Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Provides a summary of a variable partition object. This includes statistics about the clusters and their homogeneity. ```r summary(part) ``` -------------------------------- ### Load Gironde Dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Loads the gironde dataset containing information about cities in the Gironde region. ```R data(gironde) ``` -------------------------------- ### Print Variable Partition in R Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Prints the details of a variable partition object created by cutreevar. This shows the cluster assignment for each variable. ```r print(part) ``` -------------------------------- ### Bootstrap variables Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Draws a bootstrap sample from quantitative and categorical matrices. ```R bootvar(X.quanti = NULL, X.quali = NULL) ``` -------------------------------- ### Evaluate partition stability Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Evaluates the stability of partitions from a hierarchy using a bootstrap approach. ```R stability(tree, B = 100, graph = TRUE) ``` ```R data(decathlon) tree <- hclustvar(X.quanti=decathlon[,1:10]) stab<-stability(tree,B=20) plot(stab,nmax=7) boxplot(stab$matCR[,1:7]) ``` -------------------------------- ### S3 method for class 'clustvar' Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Provides a summary of a 'clustvar' object, including squared loadings and convergence information. ```APIDOC ## S3 method for class 'clustvar' summary(object, ...) ### Arguments `object` | an object of class `clustvar`. `...` | further arguments passed to or from other methods. ### Value Returns a list of matrices of squared loadings i.e. for each cluster of variables, the squared loadings on first principal component of PCAmix. For quantitative variables (resp. qualitative), squared loadings are the squared correlations (resp. the correlation ratios) with the first PC (the cluster center). If the partition of variables has been obtained with `kmeansvar` the number of iteration until convergence is also indicated. ### See Also `kmeansvar`, `cutreevar` ### Examples ```R data(decathlon) part<-kmeansvar(X.quanti=decathlon[,1:10],init=5) summary(part) ``` ``` -------------------------------- ### User satisfaction survey dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Details about the 'vnf' dataset, representing a user satisfaction survey. ```APIDOC ## User satisfaction survey with 1232 individuals and 14 questions ### Description A user satisfaction survey of pleasure craft operators on the “Canal des Deux Mers”, located in South of France, was carried out by the public corporation “Voies Navigables de France” (VNF) responsible for managing and developing the largest network of navigable waterways in Europe ### Usage ```R data(vnf) ``` ### Format A data frame with 1232 observations and 14 qualitative variables. ### Source Josse, J., Chavent, M., Liquet, B. and Husson, F. (2012). Handling missing values with Regularized Iterative Multiple Correspondence Analysis. Journal of classification, Vol. 29, pp. 91-116. ``` -------------------------------- ### Print Method for hclustvar Objects Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Prints an object of class 'hclustvar', generated by the hclustvar function. ```APIDOC ## S3 method for class 'hclustvar' print(x, ...) ### Arguments - **x** (hclustvar) - An object of class `hclustvar` generated by the function `hclustvar`. - **...** - Further arguments to be passed to or from other methods. They are ignored in this function. ``` -------------------------------- ### Wine dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Information about the 'wine' dataset, containing data on 21 wines from Val de Loire. ```APIDOC ## Wine ### Description The data used here refer to 21 wines of Val de Loire. ### Usage ```R data(wine) ``` ### Format A data frame with 21 rows (the number of wines) and 31 columns: the first column corresponds to the label of origin, the second column corresponds to the soil, and the others correspond to sensory descriptors. ### Source Centre de recherche INRA d'Angers Le, S., Josse, J. & Husson, F. (2008). FactoMineR: An R Package for Multivariate Analysis. Journal of Statistical Software. 25(1). pp. 1-18. ``` -------------------------------- ### gironde Dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html A list of 4 datasets characterizing conditions of life of 542 cities in Gironde, related to employment, housing, services, and environment. ```APIDOC ## gironde ### Description A list of 4 datasets caracterizing conditions of life of 542 cities in Gironde. The four datasets correspond to four thematics relative to conditions of life. Each dataset contains a different number of variables (quantitative and/or qualitative). The first three datasets come from the 2009 population census realized in Gironde by INSEE (Institut National de la Statistique et des Etudes Economiques). The fourth come from an IGN (Institut National de l'Information Geographique et forestiere) database. ### Usage ``` data(gironde) ``` ### Format A list of 4 data frames. ### Value `gironde$employment` | This data frame contains the description of 542 cities by 9 quantitative variables. These variables are related to employment conditions like, for instance, the average income (income), the percentage of farmers (farmer). ---|--- `gironde$housing` | This data frame contains the description of 542 cities by 5 variables (2 qualitative variables and 3 quantitative variables). These variables are related to housing conditions like, for instance, the population density (density), the percentage of counsil housing within the cities (council). `gironde$services` | This data frame contains the description of 542 cities by 9 qualitative variables. These variables are related to the number of services within the cities, like, for instance, the number of bakeries (baker) or the number of post office (postoffice). `gironde$environment` | This data frame contains the description of 542 cities by 4 quantitative variables. These variables are related to the natural environment of the cities, like, for instance the percentage of agricultural land (agricul) or the percentage of buildings (building). ### Source www.INSEE.fr www.ign.fr http://siddt.grenoble.cemagref.fr/ Multivariate analysis of mixed data: The PCAmixdata R package, M. Chavent, V. Kuentz-Simonet, A. Labenne, J. Saracco, arXiv:1411.4911 [stat.CO] ``` -------------------------------- ### Flower Characteristics Dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Dataset containing 8 characteristics for 18 popular flowers. ```APIDOC ## Flower Characteristics ### Description 8 characteristics for 18 popular flowers. ### Usage ``` data(flower) ``` ### Format A data frame with 18 observations on 8 variables: [ , "V1"] | factor | winters ---|---|--- [ , "V2"] | factor | shadow [ , "V3"] | factor | tubers [ , "V4"] | factor | color [ , "V5"] | ordered | soil [ , "V6"] | ordered | preference [ , "V7"] | numeric | height [ , "V8"] | numeric | distance V1 winters, is binary and indicates whether the plant may be left in the garden when it freezes. V2 shadow, is binary and shows whether the plant needs to stand in the shadow. V3 tubers, is asymmetric binary and distinguishes between plants with tubers and plants that grow in any other way. V4 color, is nominal and specifies the flower's color (1 = white, 2 = yellow, 3 = pink, 4 = red, 5 = blue). V5 soil, is ordinal and indicates whether the plant grows in dry (1), normal (2), or wet (3) soil. V6 preference, is ordinal and gives someone's preference ranking going from 1 to 18. V7 height, is interval scaled, the plant's height in centimeters. V8 distance, is interval scaled, the distance in centimeters that should be left between the plants. ### Source The reference below. ### References Anja Struyf, Mia Hubert & Peter J. Rousseeuw (1996): Clustering in an Object-Oriented Environment. _Journal of Statistical Software_ , **1**. ``` -------------------------------- ### POST /kmeansvar Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Performs k-means type partitioning on a set of variables. ```APIDOC ## POST /kmeansvar ### Description Performs an iterative relocation algorithm of k-means type to partition a set of variables. The center of each cluster is the first principal component calculated by PCAmix. ### Method POST ### Parameters #### Request Body - **X.quanti** (matrix/data.frame) - Optional - A numeric matrix of data. - **X.quali** (matrix/data.frame) - Optional - A categorical matrix of data. - **init** (integer/vector) - Required - Either the number of clusters or an initial partition vector. - **iter.max** (integer) - Optional - The maximum number of iterations allowed (default: 150). - **nstart** (integer) - Optional - Number of random sets used if init is a number (default: 1). - **matsim** (boolean) - Optional - If TRUE, calculates matrices of similarities between variables in the same cluster. ### Response #### Success Response (200) - **var** (list) - Matrices of squared loadings for each cluster. - **sim** (list) - Matrices of similarities between variables (if matsim is TRUE). - **cluster** (vector) - Integers indicating the cluster allocation for each variable. - **wss** (vector) - Within-cluster sum of squares for each cluster. - **E** (numeric) - Percentage of homogeneity accounted for by the partition. - **size** (vector) - Number of variables in each cluster. - **scores** (matrix) - Numerical matrix containing the k cluster centers. - **coef** (list) - Coefficients of the linear combinations defining the synthetic variable of each cluster. ``` -------------------------------- ### Partition Stability Evaluation Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Evaluates the stability of partitions derived from a hierarchy of variables using a bootstrap approach. ```APIDOC ## Stability of partitions from a hierarchy of variables ### Description Evaluates the stability of partitions obtained from a hierarchy of `p` variables. This hierarchy is performed with `hclustvar` and the stability of the partitions of 2 to p-1 clusters is evaluated with a bootstrap approach. The boostrap approch is the following: `hclustvar` is applied to `B` boostrap samples of the `n` rows. The partitions of 2 to p-1 clusters obtained from the B bootstrap hierarchies are compared with the partitions from the initial hierarchy . The mean of the corrected Rand indices is plotted according to the number of clusters. This graphical representation helps in the determination of a suitable numbers of clusters. ### Usage ```R stability(tree, B = 100, graph = TRUE) ``` ### Arguments - **tree** (hclustvar) - An object of class `hclustvar`. - **B** (numeric) - The number of bootstrap samples. Defaults to 100. - **graph** (boolean) - If TRUE, a graph is displayed. Defaults to TRUE. ### Value - **matCR** (matrix) - Matrix of corrected Rand indices. - **meanCR** (vector) - Vector of mean corrected Rand indices. ### See Also `plot.clustab`, `hclustvar` ### Examples ```R data(decathlon) tree <- hclustvar(X.quanti=decathlon[,1:10]) stab<-stability(tree,B=20) plot(stab,nmax=7) boxplot(stab$matCR[,1:7]) ``` ``` -------------------------------- ### Plot Loadings in Each Cluster Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Visualizes the 'loadings' of variables within each cluster using a dotchart. For quantitative variables, it shows the correlation with the cluster's synthetic variable. For categorical variables, it displays the mean synthetic variable value for each level. ```r res.plot <- plot(tree.cut) ``` ```r res.plot$coord.quanti ``` ```r res.plot$coord.levels ``` -------------------------------- ### Load Decathlon Dataset in R Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Loads the decathlon dataset, which contains athlete performance data. This dataset is often used for demonstrating multivariate analysis techniques. ```r data(decathlon) ``` -------------------------------- ### Print hclustvar object Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Method for printing objects of class hclustvar. ```R ## S3 method for class 'hclustvar' print(x, ...) ``` -------------------------------- ### Summary of clustab object Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Method for summarizing objects of class clustab. ```R ## S3 method for class 'clustab' summary(object, ...) ``` -------------------------------- ### Protein Data Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Dataset containing protein consumption for nine food groups across 25 European countries. ```APIDOC ### Description The data measure the amount of protein consumed for nine food groups in 25 European countries. The nine food groups are red meat (RedMeat), white meat (WhiteMeat), eggs (Eggs), milk (Milk), fish (Fish), cereal (Cereal), starch (Starch), nuts (Nuts), and fruits and vegetables (FruitVeg). ### Format A data frame with 25 rows (the European countries) and 9 columns (the food groups) ### Source Originated by A. Weber and cited in Hand et al., A Handbook of Small Data Sets, (1994, p. 297). ``` -------------------------------- ### Print Method for clustvar Objects Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Prints an object of class 'clustvar', generated by cutreevar and kmeansvar functions. ```APIDOC ## S3 method for class 'clustvar' print(x, ...) ### Arguments - **x** (clustvar) - An object of class `clustvar` generated by the functions `cutreevar` and `kmeansvar`. - **...** - Further arguments to be passed to or from other methods. They are ignored in this function. ``` -------------------------------- ### Print clustab Object Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Prints the contents of an object of class 'clustab'. This is a standard method for displaying summary information about the object. ```r print(x, ...) ``` -------------------------------- ### Summarize a clustvar object Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Displays the squared loadings for each cluster of variables in a clustvar object. ```R data(decathlon) part<-kmeansvar(X.quanti=decathlon[,1:10],init=5) summary(part) ``` -------------------------------- ### POST /predict Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Calculates new scores for objects on the synthetic variables of a given partition. ```APIDOC ## POST /predict ### Description Calculates new scores of objects described in a new dataset based on a partition of variables. ### Method POST ### Endpoint /predict ### Parameters #### Request Body - **object** (clustvar) - Required - An object of class clustvar. - **X.quanti** (matrix) - Optional - Numeric matrix of data for the new objects. - **X.quali** (matrix) - Optional - A categorical matrix of data for the new objects. ### Response #### Success Response (200) - **scores** (matrix) - The matrix of the scores of the new objects on the k synthetic variables. ``` -------------------------------- ### Plot Stability of Variable Partitions Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Generates a plot showing the index of stability of variable partitions against the number of clusters. Useful for determining an optimal number of clusters. ```r plot(stab,nmax=7) ``` -------------------------------- ### Describe Variable Partition in R Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Describes a partition of variables and provides scores for the synthetic variables of each cluster. It requires the partition object and the 'rec' element from a clustvar object. ```r descript(part, rec) ``` -------------------------------- ### Hierarchical Clustering for Variable Selection Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Performs hierarchical clustering on quantitative variables to help in choosing the number of clusters. This is a precursor to using kmeansvar. ```R data(decathlon) #choice of the number of clusters tree <- hclustvar(X.quanti=decathlon[,1:10]) stab <- stability(tree,B=60) ``` -------------------------------- ### clustofvar Dataset Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Dataset referring to 27 breeds of dogs, including their size, weight, speed, intelligence, affectivity, aggressiveness, and function. ```APIDOC ## clustofvar Dataset ### Description Data referring to 27 breeds of dogs. ### Format A data frame with 27 rows (the breeds of dogs) and 7 columns: their size, weight and speed with 3 categories (small, medium, large), their intelligence (low, medium, high), their affectivity and aggressiveness with 3 categories (low, high), their function (utility, compagny, hunting). ### Source Originated by A. Brefort (1982) and cited in Saporta G. (2011). ``` -------------------------------- ### Rand Index Calculation Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Calculates the Rand index, corrected Rand index, or asymmetrical Rand index between two partitions. ```APIDOC ## Rand index between two partitions ### Description Returns the Rand index, the corrected Rand index or the asymmetrical Rand index. The asymmetrical Rand index (corrected or not) measures the inclusion of a partition P into and partition Q with the number of clusters in P greater than the number of clusters in Q. ### Usage ```R rand(P, Q, symmetric = TRUE, adj = TRUE) ``` ### Arguments - **P** (factor) - The first partition. - **Q** (factor) - The second partition. - **symmetric** (boolean) - If FALSE, the asymmetrical Rand index is calculated. - **adj** (boolean) - If TRUE, the corrected index is calculated. ### See Also `stability` ``` -------------------------------- ### Print Method for clustab Objects Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Prints an object of class 'clustab', typically generated by the stability function. ```APIDOC ## S3 method for class 'clustab' print(object, ...) ### Arguments - **object** (clustab) - An object of class `clustab` generated by the function `stability`. - **...** - Further arguments passed to or from other methods. ``` -------------------------------- ### Plot Clustering Tree in R Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Generates a plot of the hierarchical clustering tree created by hclustvar. This helps visualize the relationships between variables. ```r plot(tree) ``` -------------------------------- ### Perform Variable Clustering with hclustvar in R Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Performs hierarchical clustering on variables using the hclustvar function. It takes a data frame subset as input and returns a clustering tree object. ```r tree <- hclustvar(decathlon[,1:10]) ``` -------------------------------- ### clusterscore Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Calculates the synthetic variable of a cluster using PCAmix. ```APIDOC ## clusterscore ### Description Calculates the synthetic variable of a cluster of variables, which is the first principal component of PCAmix. ### Parameters #### Arguments - **Z** (matrix) - Required - A centered and reduced data matrix. ### Response - **f** (vector) - The synthetic variables (scores on the first principal component). - **sv** (numeric) - The standard deviation of f. - **v** (vector) - The standardized loadings. ``` -------------------------------- ### cutreevar Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Cuts a hierarchical tree of variables into a specified number of clusters. ```APIDOC ## cutreevar ### Description Cuts a hierarchical tree of variables resulting from hclustvar into several clusters. ### Parameters #### Arguments - **obj** (hclustvar) - Required - An object of class 'hclustvar'. - **k** (integer) - Optional - The desired number of clusters. - **matsim** (boolean) - Optional - If TRUE, calculates matrices of similarities between variables in the same cluster. ``` -------------------------------- ### Calculate Rand index Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Computes the Rand index, corrected Rand index, or asymmetrical Rand index between two partitions. ```R rand(P, Q, symmetric = TRUE, adj = TRUE) ``` -------------------------------- ### hclustvar Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Performs ascendant hierarchical clustering of a set of variables, which can be quantitative, qualitative, or a mixture of both. The aggregation criterion is the decrease in homogeneity for the clusters being merged. ```APIDOC ## hclustvar ### Description Ascendant hierarchical clustering of a set of variables. Variables can be quantitative, qualitative or a mixture of both. The aggregation criterion is the decrease in homogeneity for the clusters being merged. The homogeneity of a cluster is the sum of the correlation ratio (for qualitative variables) and the squared correlation (for quantitative variables) between the variables and the center of the cluster which is the first principal component of PCAmix. PCAmix is defined for a mixture of qualitative and quantitative variables and includes ordinary principal component analysis (PCA) and multiple correspondence analysis (MCA) as special cases. Missing values are replaced by means for quantitative variables and by zeros in the indicator matrix for qualitative variables. ### Usage ```R hclustvar(X.quanti = NULL, X.quali = NULL, init = NULL) ``` ### Arguments - `X.quanti` (numeric matrix or coercible) - A numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns). - `X.quali` (categorical matrix or coercible) - A categorical matrix of data, or an object that can be coerced to such a matrix (such as a character vector, a factor or a data frame with all factor columns). - `init` (vector of integers) - An initial partition (a vector of integers indicating the cluster to which each variable is allocated). ### Details If the quantitative and qualitative data are in a same dataframe, the function `PCAmixdata::splitmix` can be used to extract automatically the qualitative and the quantitative data in two separated dataframes. ### Value - `height` (numeric vector) - A set of p-1 non-decreasing real values: the values of the aggregation criterion. - `clusmat` (matrix) - A p by p matrix with group memberships where each column k corresponds to the elements of the partition in k clusters. - `merge` (matrix) - A p-1 by 2 matrix. Row i of `merge` describes the merging of clusters at step i of the clustering. If an element j in the row is negative, then observation -j was merged at this stage. If j is positive then the merge was with the cluster formed at the (earlier) stage j of the algorithm. Thus negative entries in `merge` indicate agglomerations of singletons, and positive entries indicate agglomerations of non-singletons. ### References Chavent, M., Liquet, B., Kuentz, V., Saracco, J. (2012), ClustOfVar: An R Package for the Clustering of Variables. Journal of Statistical Software, Vol. 50, pp. 1-16. ### See Also `cutreevar`, `plot.hclustvar`, `stability` ### Examples ```R #quantitative variables data(decathlon) tree <- hclustvar(X.quanti=decathlon[,1:10], init=NULL) plot(tree) #qualitative variables with missing values data(vnf) tree_NA <- hclustvar(X.quali=vnf) plot(tree_NA) vnf2<-na.omit(vnf) tree <- hclustvar(X.quali=vnf2) plot(tree) #mixture of quantitative and qualitative variables data(wine) X.quanti <- PCAmixdata::splitmix(wine)$X.quanti X.quali <- PCAmixdata::splitmix(wine)$X.quali tree <- hclustvar(X.quanti,X.quali) plot(tree) ``` ``` -------------------------------- ### POST /mixedVarSim Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Calculates the similarity between two variables (quantitative or qualitative) using square cosine, correlation ratio, or canonical correlation. ```APIDOC ## POST /mixedVarSim ### Description Returns the similarity between two quantitative variables, two qualitative variables or a quantitative variable and a qualitative variable. ### Method POST ### Endpoint /mixedVarSim ### Parameters #### Request Body - **X1** (vector/factor) - Required - A vector or a factor. - **X2** (vector/factor) - Required - A vector or a factor. ``` -------------------------------- ### Print clustvar object Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Method for printing objects of class clustvar. ```R ## S3 method for class 'clustvar' print(x, ...) ``` -------------------------------- ### Compute Nearest Neighbors of Variables Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Computes the nearest neighbor for variables based on a dissimilarity matrix. ```R getnnsvar(diss, flag) ``` -------------------------------- ### kmeansvar Function Signature Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html The kmeansvar function signature for clustering variables. It accepts quantitative and qualitative data, initialization parameters, and iteration limits. ```R kmeansvar( X.quanti = NULL, X.quali = NULL, init, iter.max = 150, nstart = 1, matsim = FALSE ) ``` -------------------------------- ### Variable Selection within Clusters Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Selects a specified number of variables with the highest squared loadings within each cluster. ```APIDOC ## Selection of a given number of variables in each cluster. ### Description This function selects in each cluster a given number of variables having the highest squared loadings. The squared loading of a variable in a cluster is its squared correlation (for numerical variable) and its correlation ratio (for categorical variable) with the first PC of PCAmix applied to the variables of the cluster. ### Usage ```R selvar(part, nsel) ``` ### Arguments - **part** (clustvar) - An object of class `clustvar`. - **nsel** (numeric) - The number of variables selected in each cluster. ### Details If the number of variables in a cluster is smaller than `nsel`, all the variables of the cluster are selected. ### Value Returns a list where each element contains the `nsel` selected variables. ### Examples ```R data(decathlon) tree <- hclustvar(decathlon[,1:10]) part <- cutreevar(tree,4) part$var selvar(part,2) ``` ``` -------------------------------- ### Predict Scores on Synthetic Variables Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Calculates scores for new objects on the synthetic variables derived from a variable partition (obtained via `kmeansvar` or `cutreevar`). Requires a learning sample to define the partition and synthetic variables. ```r new <- predict(part,X.quanti.t,X.quali.t) ``` -------------------------------- ### Cut Variable Clusters in R Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Partitions the hierarchical clustering tree into a specified number of clusters using cutreevar. It returns an object describing the partition. ```r part <- cutreevar(tree,4) ``` -------------------------------- ### Select variables in clusters Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Selects a specified number of variables with the highest squared loadings in each cluster. ```R selvar(part, nsel) ``` ```R data(decathlon) tree <- hclustvar(decathlon[,1:10]) part <- cutreevar(tree,4) part$var selvar(part,2) ``` -------------------------------- ### hclustvar2 Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Performs ascendant hierarchical clustering of variables from a covariance or correlation matrix. ```APIDOC ## Hierarchical clustering of variables from a covariance matrix ### Description Ascendant hierarchical clustering of a set of variables from a covariance/correlation matrix. ### Usage ```R hclustvar2(x, init = NULL) ``` ### Arguments - `x` (matrix) - A covariance or correlation matrix. - `init` (vector of integers) - An initial partition (a vector of integers indicating the cluster to which each variable is allocated). ### Value - `height` (numeric vector) - A set of p-1 non-decreasing real values: the values of the aggregation criterion. - `clusmat` (matrix) - A p by p matrix with group memberships where each column k corresponds to the elements of the partition in k clusters. - `merge` (matrix) - A p-1 by 2 matrix. Row i of `merge` describes the merging of clusters at step i of the clustering. If an element j in the row is negative, then observation -j was merged at this stage. If j is positive then the merge was with the cluster formed at the (earlier) stage j of the algorithm. Thus negative entries in `merge` indicate agglomerations of singletons, and positive entries indicate agglomerations of non-singletons. ### See Also `cutreevar`, `plot.hclustvar`, `stability` ### Examples ```R data(decathlon) x <- cor(decathlon[,1:10]) tree <- hclustvar2(x) plot(tree, hang = -1, xlab="", sub="") ``` ``` -------------------------------- ### Plot Dendrogram of Variable Hierarchy Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Displays a dendrogram representing the hierarchy of variables resulting from `hclustvar`. An alternative 'index' type plots the aggregation levels. ```r plot(tree) ``` ```r plot(tree,type="index") ``` -------------------------------- ### Calculate synthetic variable Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Computes the synthetic variable of a cluster using the first principal component of PCAmix. ```R clusterscore(Z) ``` ```R data(decathlon) A <- 1:5 Z <- PCAmixdata::recod(X.quanti=decathlon[1:10,A], X.quali=NULL)$Z clusterscore(Z) Z%*%as.matrix(clusterscore(Z)$v) clusterscore(Z)$f ``` -------------------------------- ### Cut hierarchical tree Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Cuts a hierarchical tree of variables into a specified number of clusters. ```R cutreevar(obj, k = NULL, matsim = FALSE) ``` -------------------------------- ### Calculate dissimilarity between clusters Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Computes dissimilarity between two clusters when only the covariance or correlation matrix is provided. ```R clust_diss2(x, A, B) ``` ```R data(decathlon) x <- cor(decathlon[,1:10]) A <- c(1,3,4) B <- c(2,7,10) clust_diss2(x,A,B) ``` -------------------------------- ### getnnsvar Function Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Computes the nearest neighbor of variables based on a dissimilarity matrix and a flag. ```APIDOC ## Nearest neighbor of variables ### Description Nearest neighbor of variables ### Usage ``` getnnsvar(diss, flag) ``` ### Arguments `diss` | a dissimilarity matrix between variables ---|--- `flag` | a vector of size `p` which indicates if we want to compute nearest neighbor of variable j (flag[j]=1) or not (flag[j]=0) ``` -------------------------------- ### Assess Cluster Stability in R Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Calculates the stability of a variable clustering result using the stability function. It requires the clustering tree and the number of bootstrap replicates (B). ```r stability(tree,B=40) ``` -------------------------------- ### clust_diss Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Calculates the measure of aggregation of two clusters of variables based on the decrease in homogeneity. ```APIDOC ## clust_diss ### Description Calculates the measure of aggregation of two clusters of variables. ### Parameters #### Arguments - **A** (matrix) - Required - A centered and reduced data matrix for the first cluster. - **B** (matrix) - Required - A centered and reduced data matrix for the second cluster. ### Response - **Value** (numeric) - The aggregation measure between the two clusters. ``` -------------------------------- ### Calculate Similarity Between Variables Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Computes the similarity between two variables, which can be quantitative, qualitative, or a mix. The similarity is defined as a square cosine, adapting to the variable types (Pearson correlation, correlation ratio, or canonical correlation). ```r mixedVarSim(X1, X2) ``` -------------------------------- ### clust_diss2 Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Calculates dissimilarity between two clusters of variables using a covariance/correlation matrix. ```APIDOC ## clust_diss2 ### Description Dissimilarity between two clusters of variables when only the covariance/correlation matrix is known. ### Parameters #### Arguments - **x** (matrix) - Required - A covariance/correlation matrix. - **A** (vector) - Required - Indices of cluster A. - **B** (vector) - Required - Indices of cluster B. ### Response - **Value** (numeric) - The dissimilarity between the two clusters. ``` -------------------------------- ### Calculate aggregation criterion Source: https://cran.r-project.org/web/packages/ClustOfVar/refman/ClustOfVar.html Computes the measure of aggregation between two clusters of variables based on centered and reduced data matrices. ```R clust_diss(A, B) ``` ```R data(decathlon) A <- PCAmixdata::recod(X.quanti=decathlon[1:10,1:5], X.quali=NULL)$Z B <- PCAmixdata::recod(X.quanti=decathlon[1:10,6:10], X.quali=NULL)$Z clust_diss(A,B) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.