Nobel Prize Winners An example on Nobel prize winners by G8 countries from 1901 to 2015 from a Youtube video by Francois Husson, \url{www.youtube.com/watch?v=Z5Lo1hvZ9fA} \textbf{Code is incomplete or wrong.} I just liked the data. rm(list = ls()) nobel = matrix(c( 4, 3, 2, 4, 1, 4, 8, 3, 11, 12, 10, 9, 24, 1, 8, 18, 5, 24, 1, 1, 6, 5, 1, 5, 6, 0, 2, 3, 1, 11, 4, 3, 5, 2, 3, 10, 23, 6, 7, 26, 11, 20, 51, 43, 8, 70, 19, 66),6,8) nobel=t(nobel) nobel rowSums(nobel) colSums(nobel) # rownames Canada France Germany Italy Japan Russia UK USA # colnames Chem Econ Lit Med Peace Physics # fit indep/homogen model to table fit <- chisq.test(nobel,correct=FALSE) fit fit$expected fit$residual # Singular Value Decomp of residual matrix ca=svd(fit$residual) L=diag(ca$d) L U=ca$u %*% sqrt(L) U V=ca$v %*% sqrt(L) V #This should reproduce fit$residual PR=U%*%L%*%t(V) PR # Pearson Chi-square X2=PR%*%t(PR) sum(diag(X2)) #SVD Plot plot(U[,1],U[,2], xlim=c(-1,1),ylim=c(-1,1), ,xlab="Factor 1",ylab="Factor 2") text(U[,1],U[,2]-.075,labels= c("Canada","France","Germany", "Italy","Japan","USSR","UK","USA")) lines(V[,1],V[,2],pch=15,type="p") text(V[,1]+.075,V[,2],labels= c("Chem","Econ","Lit","Med","Peace","Phys"))