{"word_count": 305, "character_count": 2684}
This week, in the course on non-supervised techniques for data science, we've been using a dataset, with candidate for the presidential elections in 2002 (per row) and newpapers (per column). In order to visualize that dataset, consider three candidates, and three newspapers&#62; base=read.table("http://freakonometrics.free.fr/election2002.txt",header=TRUE)&#62; sb=base[,c(2,3,4)]&#62; sb=sb[c(4,12,7),]&#62; (N=sb)       LeFigaro Liberation LeMondeJospin        7         41      26Chirac       35          9      18Mamere        1         10       7The first part is based on a description of rows. Consider here rows are conditional probabilities, in the set of newspapers,&#62; (L=N/apply(N,1,sum))         LeFigaro Liberation   LeMondeJospin 0.09459459  0.5540541 0.3513514Chirac 0.56451613  0.1451613 0.2903226Mamere 0.05555556  0.5555556 0.3888889The "average row" is the marginal distribution of newspapers&#62; (Lbar=apply(N,2,sum)/sum(N))  LeFigaro Liberation    LeMonde  0.2792208  0.3896104  0.3311688If we visualize those individuals, in the set of newpapers (in the simplexe in the newspapers space), we haveHere it is,But actually, we will not stay in the simplexe. A PCA is considered, with weights on individuals, that take into account the importance of the different candidates, and weights for the scalar product (in order to have a distance related to the chi-square distance, and not a standard Euclidean distance)&#62; matL0=t(t(L)-Lbar)&#62; library(FactoMineR)&#62; acpL=PCA(matL0,scale.unit=FALSE,+   row.w=(apply(N,1,sum)),+   col.w=1/(apply(N,2,sum)))&#62; plot.PCA(acpL,choix="ind",ylim=c(-.02,.02))&#160;The second part is based on a description of columns. Here Columns are conditional probabilities, in the set of candidates,&#62; (C=t(t(N)/apply(N,2,sum)))         LeFigaro Liberation   LeMondeJospin 0.16279070  0.6833333 0.5098039Chirac 0.81395349  0.1500000 0.3529412Mamere 0.02325581  0.1666667 0.1372549Here again, we can compute the "average column"&#62; (Cbar=apply(N,1,sum)/sum(N))   Jospin    Chirac    Mamere 0.4805195 0.4025974 0.1168831In the simplex, points arei.e.But here again, we won't use that simplexe. We consider a PCA, with two vectors of weights, some to take into account the weights of the newspapers, and some to get a chi-square distance&#62; Cbar=apply(N,1,sum)/sum(N)&#62; matC0=C-Cbar&#62; acpC=PCA(t(matC0),scale.unit=FALSE,+          row.w=(apply(N,2,sum)),+          col.w=1/(apply(N,1,sum)))&#160;Now, we can almost overlap the two projections. Almost because we might, sometime switch right and left, top and bottom. Because if  is a (unit) eigenvector, so is . Here, for instance, we should swich them&#62; CA(N)