# # # function [Xr,Xc,Phi,Gamma,Lambda2,pc,ac]=corresp(N) # # Performs correspondence analysis on a contingency table N # # Input: N # # Output: # Xr (representation of rows) # Xc (representation of columns) # Phi Standard coordinates of rows # Gamma Standard coordinates of columns # Lambda2 vector containing squared singular values # pc vector containing percentages of Lambda2 # ac vector containing cumulative percentages of Lambda2 # # # Needs: # profile.m # percent.m # function [Xr,Xc,Phi,Gamma,Lambda2,pc,ac]=corresp(N) [P,Q,A,B,n,p,q]=profile(N); [U,Lambda,V]=svd((diag(p))^(-0.5)*(N/n-p*q)*(diag(q))^(-0.5),0); Lambda2=(diag(Lambda.*Lambda))'; [fp,pc,ac,np]=percent(Lambda2); Xr=(diag(p))^(-0.5)*U*Lambda; Xc=(diag(q))^(-0.5)*V*Lambda; Phi=(diag(p))^(-0.5)*U; Gamma=(diag(q))^(-0.5)*V; endfunction