Group Abstract Group Abstract

Message Boards Message Boards

0
|
18.1K Views
|
11 Replies
|
7 Total Likes
View groups...
Share
Share this post:

How to perform a correspondence analysis?

Posted 11 years ago
POSTED BY: Leo Hamminger
11 Replies
POSTED BY: Anton Antonov
Posted 11 years ago

Hello,

Please have a look at "Correspondence Analysis and Data Coding with Java and R" by F. Murtagh, published 2005. Prof. Murtagh did his PhD on CA with Prof. J.-P Benzecri (indeed a prominent figure in the French school of data analysis) who added the mathematical elegance to the theory using Einstein's tensor notation while in Princeton. The book has a companion site http://www.correspondances.info which has the the source code and data sets used in the book. The ISBN is 1-58488-528-9

Indeed, the only Mathematica treatment I was able to find was that in the paper cited above. I hope this helps you accomplish your goal.

POSTED BY: Mohsen Farid
POSTED BY: Anton Antonov
Posted 11 years ago
POSTED BY: Leo Hamminger

Though I do not know anything about correspondence analysis (could you give a link just out of curiosity?), you can possibly make use of the R-library from Mathematica using RLink:

http://reference.wolfram.com/language/RLink/tutorial/Reference.html

http://reference.wolfram.com/language/RLink/guide/RLink.html

POSTED BY: David Reiss

A little program of correspondence analysis that I make with Mathematica 9 André Dauphiné Geographer University of Nice Sophia-antipolis

(*Analyse des Correspondances*)
(*Importation des données, \
suppression du nom des variables*)
(*les noms des lignes sont placées \
dans le fichier nom*)

ClearAll["Global`*"]
d = Import[SystemDialogInput["FileOpen"], "XLS"];
d = Flatten[d, 1];
nomcol = Take[d, 1];
nomcol = Drop[Flatten[nomcol], 1];
d1 = Transpose[d];
nomligne = Take[d1, 1];
nomligne = Drop[Flatten[nomligne], 1];
d2 = Drop[d, 1, 1];
touttot = Total[Flatten[d2]];
totcol = Total[d2]/touttot;
totlig = Total[Transpose[d2]]/touttot;
ncol = Length[totcol];
nlig = Length[totlig];
d3 = d2/touttot;
d4 = Table[d3[[i, All]]/totlig[[i]], {i, 1, nlig}];
d5 = Table[d4[[All, i]]*(1/Sqrt[totcol[[i]]]), {i, 1, ncol}];
d5 = Transpose[d5];
dcent = Table[d5[[All, i]] - Sqrt[totcol[[i]]], {i, 1, ncol}];
dcor = Covariance[Transpose[dcent]];
Print["Matrice des covariances"]
dcotmat = dcor;
Grid[dcotmat, Frame -> All, Alignment -> "."]
{vals, vecs} = Eigensystem[N[dcor]];
recvals = Sqrt[vals];
trac = Total[vals];
Print["Pourcentage de variance par chaque composante"]
pcvals = (vals/trac)*100;
Column[pcvals, Frame -> All, Alignment -> "."]
ListPlot[pcvals, Filling -> Axis]
stur = recvals*vecs;
Print["Saturations composantes variables"]
saturations = Transpose[stur];
sturt = N[saturations];
Grid[sturt, Frame -> All, Alignment -> "."]
proj = vecs.dcent;
projt = Transpose[proj];
Print["Saturations composantes objets"]
projc = N[projt];
Grid[projc, Frame -> All, Alignment -> "."]
ny = DialogInput[
  DynamicModule[{name = ""}, Column[{"Choisir la composante 1",
     InputField[Dynamic[name], String],
     ChoiceButtons[{DialogReturn[name], DialogReturn[]}]}]]]
ny = ToExpression[ny];
nx = DialogInput[
  DynamicModule[{name = ""}, Column[{"Choisir la composante 2",
     InputField[Dynamic[name], String],
     ChoiceButtons[{DialogReturn[name], DialogReturn[]}]}]]]
nx = ToExpression[nx];
Print[]
Print["Graphiques des saturations composantes variables"]
dcomp = Partition[
   Riffle[saturations[[All, ny]], saturations[[All, nx]]], 2];
dcompespace = Partition[Riffle[projt[[All, ny]], projt[[All, nx]]], 2];
a1 = ListPlot[dcomp, PlotStyle -> Directive[PointSize[Large], Red], 
  AxesOrigin -> {0, 0}, AxesLabel -> {ny, nx}]
Print[]
Print["Graphiques des saturations composantes objets"]
a2 = ListPlot[dcompespace, 
  PlotStyle -> Directive[PointSize[Large], Blue], 
  AxesOrigin -> {0, 0}, AxesLabel -> {ny, nx}]
Print[]
Print["Graphiques des saturations composantes variables et \
composantes objets"]
Show[a1, a2]
POSTED BY: André Dauphiné
Posted 11 years ago

Hi Anton,

many thanks for your thoughts, very much appreciated. I definitely have homework to do and chances are that I will get back.

Best wishes, Leo

POSTED BY: Leo Hamminger
Posted 11 years ago

Very many thanks, excellent link. More burning of midnight oil ...

POSTED BY: Leo Hamminger
Posted 11 years ago

Hi David,

I do appreciate your effort and help.

As a matter of fact, I came across this article, but look at the output on Figure 5 (just before 8. Conclusion): it doesn't do Mathematica justice, I am afraid. (I know I am difficult ...)

It does appear as there is a white spot on the map, somewhere.

POSTED BY: Leo Hamminger

Hi Leo,

A bit of a google search comes up with this which may be of help:

http://www.mathematica-journal.com/2010/09/an-introduction-to-correspondence-analysis/

(There is a link in the above article that allows you to download it in Mathematica Notebook form so you have direct access to the code.)

POSTED BY: David Reiss
Posted 11 years ago
POSTED BY: Leo Hamminger
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard