Multidimensional scaling of discrete probability distributions
Multidimensional scaling of discrete probability distributions
Applies the multidimensional scaling (MDS) method to discrete probability distributions in order to describe T groups of individuals on which are observed q categorical variables. It returns an object of class mdsdd. It applies cmdscale to the distance matrix between the T distributions.
xf: object of class folder, list of arrays (or tables) or data frame.
If it is a folder, its elements are data frames with q columns (considered as factors). The tth element (t=1,…,T) matches with the tth group.
If it is a data frame, the columns with name given by the group.name argument is a factor giving the groups. The other columns are all considered as factors.
If it is a list of arrays (or tables), the tth element (t=1,…,T) is the table of the joint frequency distribution of q variables within the tth group. The frequency distribution is expressed with relative or absolute frequencies. These arrays have the same shape.
Each array (or table) xf[[i]] has:
the same dimension(s). If q=1 (univariate), dim(xf[[i]]) is an integer. If q>1 (multivariate), dim(xf[[i]]) is an integer vector of length q.
the same dimension names dimnames(xf[[i]]) (is non NULL). These dimnames are the names of the variables.
The elements of the arrays are non-negative numbers (if they are not, there is an error).
group.name: string. Name of the grouping variable. Default: groupname = "group".
distance: The distance or divergence used to compute the distance matrix between the discrete distributions (see Details). It can be:
"l1" (default) the Lp distance with p=1
"l2" the Lp distance with p=2
"chisqsym" the symmetric Chi-squared distance
"hellinger" the Hellinger metric (Matusita distance)
sub.title: string. Subtitle for the graphs (default NULL).
plot.eigen: logical. If TRUE (default), the barplot of the eigenvalues is plotted.
plot.score: logical. If TRUE, the graphs of new coordinates are plotted. A new graphic device is opened for each pair of coordinates defined by nscore argument.
nscore: numeric vector. If plot.score = TRUE, the numbers of the principal coordinates which are plotted. By default, nscore = 1:3. Its components cannot be greater than nb.factors.
filename: string. Name of the file in which the results are saved. By default (filename = NULL) they are not saved.
add: logical indicating if an additive constant should be computed and added to the non diagonal dissimilarities such that the modified dissimilarities are Euclidean (default TRUE; see add argument of cmdscale).
p: integer. Optional. When distance = "lp" (Lp distance with p>2), p is the parameter of the distance.
Details
If a folder is given as argument, the T discrete probability distributions ft corresponding to the T groups of individuals are estimated from observations. Then the distances/dissimilarities between the estimated distributions are computed, using the distance or divergence defined by the distance argument:
If the distance is "l1", "l2" or "lp", the distances are computed by the function matddlppar. Otherwise, it can be computed by matddchisqsympar ("chisqsym"), matddhellingerpar ("hellinger"), matddjeffreyspar ("jeffreys") or matddjensenpar ("jensen").
The association measures are computed accordingly to the value of the parameter associationThe computation uses the corresponding function of the package DescTools (see Assocs). Notice that an association measure between a constant variable with and other variable is set to zero. The association measure between each variable with itself is not computed and the diagonal of the returned association matrices is set to NA.
Returns
Returns an object of class mdsdd, that is a list including:
inertia: data frame of the eigenvalues and the percentages of their sum.
scores: data frame of the coordinates along the nb.factors first principal coordinates.
jointp: list of arrays. The joint probability distribution for each group.
margins: list of two data frames giving respectively:
The probability distribution of each variable for each group. Each column of the data frame corresponds to one level of one categorical variable and contains the probabilities of this level in each group.
The joint probability distribution of each pair of variables for each group. Each column of the data frame corresponds to one pair of levels of two categorical variables (one level per variable) and contains the probabilities of this pair of levels in each group.
associations: list of T matrices. Each matrix corresponds to a group and gives the pairwise association measures between the q categorical variables.
Saporta, G. (2006). Probabilit'es, Analyse des donn'ees et Statistique. Editions Technip, Paris.
Author(s)
Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Sabine Demotes-Mainard
See Also
print.mdsdd , plot.mdsdd , interpret.mdsdd
Examples
# Example 1 with a folder (10 groups) of 3 factors # obtained by converting numeric variablesdata(roses)xr = roses[,c("Sha","Den","Sym","rose")]xf = as.folder(xr, groups ="rose")xf = cut(xf, breaks = list(c(0,5,7,10), c(0,4,6,10), c(0,6,8,10)), cutcol =1:3)af = mdsdd(xf)print(af)print(af$jointp)print(af$margins[[1]])# equivalent to print(af$margins$margin1) print(af$margins[[2]])print(af$associations)# Example 2 with a data frame obtained by converting numeric variablesdata(roses)xr = roses[,c("Sha","Den","Sym","rose")]xr = cut(xr, breaks = list(c(0,5,7,10), c(0,4,6,10), c(0,6,8,10)), cutcol =1:3)ar = mdsdd(xr, group.name ="rose")print(ar)print(ar$jointp)print(ar$margins[[1]])# equivalent to print(ar$margins$margin1) print(ar$margins[[2]])print(ar$associations)# Example 3 with a list of 7 arraysdata(dspg)xl = dspg
mdsdd(xl)