## Section 5.4 examples ## MBA Example: gmat <- c(710,610,640,580,545,560,610,530,560,540,570,560) gpa <- c(4.0,4.0,3.9,3.8,3.7,3.6,3.5,3.5,3.5,3.3,3.2,3.2) ### Spearman's rho: cor.test(gmat, gpa, alternative="greater", method="spearman", exact=T) ## Note that the Spearman coefficient is the same as the Pearson coefficient ## calculated on the ranks of each sample: cor(gmat, gpa, method="spearman") cor(rank(gmat), rank(gpa), method="pearson") ### Kendall's tau: cor.test(gmat, gpa, alternative="greater", method="kendall", exact=T) ############################## ## Daniels Test for Trend: global.temps <- c(-0.493, -0.457, -0.466, -0.497, -0.315, -0.077, 0.063, -0.036, -0.025, -0.002, 0.317, 0.563, 0.923) time <- 1:length(global.temps) # Using Spearman: cor.test(time, global.temps, alternative="greater", method="spearman", exact=T) # Using Kendall: cor.test(time, global.temps, alternative="greater", method="kendall", exact=T) ################################# ### Kendall's Tau for binary ordered data: math <- c(0,0,1,0,1,1,0,0,1,1,1,0,1,0,0,1,1,1,1,1) history <- c(0,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1) cor.test(math, history, alternative="two.sided", method="kendall", exact=T)