compute a cube of covariance and a cube of distance between the items (rows) of a matrix of measurements comprising K different blocks of possibly different number of variables.
compute a cube of covariance and a cube of distance between the items (rows) of a matrix of measurements comprising K different blocks of possibly different number of variables.
list2CubeOfCovDis
compute a cube of covariance and a cube of (squared) Euclidean distance between the items (rows) a matrix of measurements comprising K different blocks of possibly different number of variables. The variables describing the items can scaled to norm 1 and centered. The whole matrix for a block can be scaled by its first eigenvalue (a la DISTATIS). Blocks can have different number of variables and when all blocks have same number of variables list2CubeOfCovDis
is a more efficient alternative
list2CubeOfCovDis(Data, Judges, scale =TRUE, center =TRUE, ev.scale =TRUE)
Arguments
Data: a matrix of dimensions I items by J quantitative variables (structured in K blocks of Jk variables each). No Default.
Judges: a J components character vector identifiying the variables corresponding to each block of variables. No Default.
scale: (Default: TRUE), when TRUE
scale to norm 1 each column for each slice.
center: (Default: TRUE), when TRUE
centers each column.
ev.scale: (Default: TRUE), when TRUE
normalizes each slice (i.e., each I items by J matrix) so that its first eigenvalue is equal to 1.
Returns
a list with 1) cubeOfCovariance
a cube of KI by I covariance matrices; and 2) codecubeOfDistance
a cube of KI by I
(squared) Euclidean distance matrices.
Details
The input of list2CubeOfCovDis is a I items by J quantitative variables that are organized in K blocks (i.e., submatrices) each comprising Jk variables (with sum Jk=J).
By default list2CubeOfCovDis
centers and normalizes each column for each block and then normalize each covariance matrix such that the first eigenvalue of each covariance matrix (for a given block) is equal to 1.
A distatis analysis of the Distance matrices with the option Distance = TRUE will give the same results as the distatis analysis of the Covariance matrices with the option Distance = FALSE.
Examples
path2file <- system.file("extdata","BeersFlashProfile.xlsx", package ='DistatisR')# read the data in the excel file with read.df.excelbeerDataFlash <- read.df.excel(path = path2file, sheet ='Rankings')$df.data
# Extract the namers of the judges (first 2 characters)JudgesVars <- colnames(beerDataFlash)zeJudges <- substr(JudgesVars,1,2)# call list2CubeOfCovDistest.list2 <- list2CubeOfCovDis(Data = beerDataFlash , Judges = zeJudges)