Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Chi2Dist

chi2 distance between the rows of a rectangular matrix.


Description

Computesthe I*I matrix D which is the chi2 distance matrix between the rows of an I*J rectangular matrix X (with non-negative elements), and provides the I*1 m vector of mass (where the mass of a row is the sum of the entries of this row divided by the grand total of the matrix). When the distance matrix and the associated vector of masses are used as input to the function mmds the results will give the factor scores of the correspondence analysis of the matrix X. The function is used by the function Chi2DistanceFromSort that computes the chi2 distance for the results of a sorting task.

Usage

Chi2Dist(X)

Arguments

X

A rectangle matrix with non-negative elements

Value

Sends back a list

$Distance

the squared chi2 distance matrix computed the rows of matrix X.

masses

the vector of masses of the rows of of matrix X.

Author(s)

Herve Abdi

References

The procedure and references are detailled in (Paper available from www.utdallas.edu/~herve): Abdi, H. (2007). Distance. In N.J. Salkind (Ed.): Encyclopedia of Measurement and Statistics. Thousand Oaks (CA): Sage. pp. 304–308.

And in:
Abdi, H., & Valentin, D. (2006). Mathematiques pour les Sciences Cognitives (Mathematics for Cognitive Sciences). Grenoble: PUG.

See also (for the example):

Abdi, H., & Williams, L.J. (2010). Principal component analysis. Wiley Interdisciplinary Reviews: Computational Statistics,2, 433–459.

See Also

Examples

# Here is a data matrix from Abdi & Williams (2012)
# page 449, Table 15. Punctuation of 6 French authors
Punctuation = matrix(c(
  7836,   13112,   6026,
 53655,   102383, 42413, 
115615,   184541, 59226, 
161926,   340479, 62754, 
 38177,   105101, 12670, 
 46371,    58367, 14299),
     ncol =3,byrow = TRUE)
colnames(Punctuation) <-c('Period','Comma','Other')
rownames(Punctuation) <-c('Rousseau','Chateaubriand',
                   'Hugo','Zola','Proust','Giroudoux') 
# 1. Get the Chi2 distance matrix
#     between the rows of Punctuation 
Dres <- Chi2Dist(Punctuation)
# check that the mds of the Chi2 distance matrix
# with CA-masses gives the CA factor scores for I 
# 2. Use function mmds from DistatisR 
#
testmds <- mmds(Dres$Distance,masses=Dres$masses)
# Print the MDS factor scores from mmds
print('Factor Scores from mds')
print(testmds$FactorScores)
print('It matches CA on X (see Abdi & Williams, 2010. Table 16, p. 449)')
# Et voila!

DistatisR

DiSTATIS Three Way Metric Multidimensional Scaling

v1.0.1
GPL-2
Authors
Derek Beaton [aut, com, ctb], Cherise Chin Fatt [ctb], Herve Abdi [aut, cre]
Initial release
2013-07-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.