Three different types of correlation coefficients: Pearson rho, Spearman R, and Kendall tau Also, jackknife and bootstrap confidence intervals for all three. Starting random-number seed: 123456 (Enter a number on the command line to specify a different seed.) Prepacked Lubricants and Survival Times for Engines (Source of data unknown.) Lubricant Survival Lubricant Survival ------------------------------------------------ 1. 29 23 11. 84 429 2. 21 36 12. 37 489 3. 30 67 13. 94 504 4. 45 104 14. 56 925 5. 48 147 15. 67 980 6. 92 164 16. 79 1254 7. 74 247 17. 70 2961 8. 61 304 18. 93 5351 9. 99 355 19. 76 9915 10. 24 408 20. 72 11301 ------------------------------------------------ Pearson correlation coefficient (n=20): Rho=0.290556 T=1.2883 Classical P=0.21396 (Student's t, df=18) Permutation test based on 100,000 permutations: Each permutation fixes the Xs, permutes the Ys P=22143/100,000=0.22143 95% CI for true P: (0.2189, 0.2214, 0.2240) Data and within-sample midranks for both samples: Lubricant Survival Lubricant Survival ------------------------------------------------------------ 1. 29 ( 3) 23 ( 1) 11. 84 (16) 429 (11) 2. 21 ( 1) 36 ( 2) 12. 37 ( 5) 489 (12) 3. 30 ( 4) 67 ( 3) 13. 94 (19) 504 (13) 4. 45 ( 6) 104 ( 4) 14. 56 ( 8) 925 (14) 5. 48 ( 7) 147 ( 5) 15. 67 (10) 980 (15) 6. 92 (17) 164 ( 6) 16. 79 (15) 1254 (16) 7. 74 (13) 247 ( 7) 17. 70 (11) 2961 (17) 8. 61 ( 9) 304 ( 8) 18. 93 (18) 5351 (18) 9. 99 (20) 355 ( 9) 19. 76 (14) 9915 (19) 10. 24 ( 2) 408 (10) 20. 72 (12) 11301 (20) ------------------------------------------------------------ Spearman correlation coefficient (n=20): R=0.508271 Z=2.2155 Large-sample P=0.02673 (two-sided normal) Doing 100,000 permutations fixing RankXs, permuting RankYs: P=2346/100,000=0.02346 95% CI for true P: (0.0225, 0.0235, 0.0244) Kendall correlation coefficient (n=20): Kendall K=72 Kendall tau=0.378947 0 ties Large-sample Z=2.3360 P=0.0195 (2-sided, tie-corrected) Doing 100,000 permutations fixing Xs, permuting Ys: P=2063/100,000=0.02063 95% CI for true P: (0.0197, 0.0206, 0.0215) REVISITING the Pearson correlation coefficient: For Xs and log(Y)s: Rho=0.546574 T=2.76915 Classical P=0.01264 (Student's t, df=18) Doing 100,000 permutations fixing Xs, permuting log(Y)s: P=1257/100,000=0.01257 95% CI for true P: (0.0119, 0.0126, 0.0133) Log-transformed data: Lubricant LogSurv Lubricant LogSurv ------------------------------------------------ 1. 29 3.14 11. 84 6.06 2. 21 3.58 12. 37 6.19 3. 30 4.20 13. 94 6.22 4. 45 4.64 14. 56 6.83 5. 48 4.99 15. 67 6.89 6. 92 5.10 16. 79 7.13 7. 74 5.51 17. 70 7.99 8. 61 5.72 18. 93 8.59 9. 99 5.87 19. 76 9.20 10. 24 6.01 20. 72 9.33 ------------------------------------------------ CONFIDENCE INTERVERVALS FOR RHO, R, and TAU? ALTERNATIVE P-VALUES? JACKKNIFES AND BOOTSTRAPS: Using the jackknife: Pearson rho for Xs and Ys: (See Section 5.2 in text for a discussion of jackknifes, or else the Jackknife Handout on the Math408 Web site.) Jackknife of Pearson rho (n=20, original rho=0.2906) Delete-1 rho values: 0.2659(1) 0.2640(2) 0.2673(3) 0.2763(4) 0.2789(5) 0.3385(6) 0.3062(7) 0.2907(8) 0.3490(9) 0.2742(10) 0.3184(11) 0.2772(12) 0.3344(13) 0.2878(14) 0.2938(15) 0.3004(16) 0.2864(17) 0.2347(18) 0.2692(19) 0.3163(20) Jackknife pseudo-values for rho: 0.7586(1) 0.7957(2) 0.7333(3) 0.5619(4) 0.5121(5) -0.6211(6) -0.0074(7) 0.2877(8) -0.8191(9) 0.6008(10) -0.2394(11) 0.5434(12) -0.5418(13) 0.3428(14) 0.2293(15) 0.1028(16) 0.3694(17) 1.3512(18) 0.6959(19) -0.1979(20) For original rho=0.2906: Jackknife mean, 95% CIs, and jackknife (two-sided) P-values: Normal: (0.0340, 0.2729, 0.5119) Z=2.2387 P=0.02518 Student-t: (0.0178, 0.2729, 0.5281) T=2.2387 P=0.03734 (19 df) Pearson rho for Xs and log(Y)s: Jackknife of Pearson rho (n=20, original rho=0.5466) Delete-1 rho values: 0.4814(1) 0.4742(2) 0.5063(3) 0.5310(4) 0.5365(5) 0.6174(6) 0.5617(7) 0.5468(8) 0.5966(9) 0.5785(10) 0.5609(11) 0.5641(12) 0.5695(13) 0.5556(14) 0.5456(15) 0.5371(16) 0.5479(17) 0.4995(18) 0.5480(19) 0.5667(20) Jackknife pseudo-values for rho: 1.7845(1) 1.9218(2) 1.3109(3) 0.8429(4) 0.7372(5) -0.7983(6) 0.2591(7) 0.5430(8) -0.4046(9) -0.0600(10) 0.2750(11) 0.2133(12) 0.1114(13) 0.3742(14) 0.5650(15) 0.7264(16) 0.5207(17) 1.4418(18) 0.5199(19) 0.1650(20) For original rho=0.5466: Jackknife mean, 95% CIs, and jackknife (two-sided) P-values: Normal: (0.2562, 0.5525, 0.8487) Z=3.6552 P=0.00026 Student-t: (0.2361, 0.5525, 0.8688) T=3.6552 P=0.00168 (19 df) Using the bootstrap: Pearson rho for Xs and Ys: (See Section 8.4 in text for a discussion of bootstraps, or else the Bootstrap Handout on the Math408 Web site.) Bootstrap of Pearson rho (10,000 replications, original rho=0.2906) Bootstrap median and 95% CI for rho: (0.2230, 0.3037, 0.3911) Bootstrap test for rho!=0: One-sided P: P=45/10,000 = (0.0032, 0.0045, 0.0058) Two-sided P: (0.0064, 0.0090, 0.0116) Pearson rho for Xs and log(Y)s: Bootstrap of Pearson rho (10,000 replications, original rho=0.5466) Bootstrap median and 95% CI for rho: (0.4576, 0.5597, 0.6447) Bootstrap test for rho!=0: One-sided P: P=29/10,000 = (0.0018, 0.0029, 0.0040) Two-sided P: (0.0037, 0.0058, 0.0079) Bootstraps for Kendall tau for Xs and Ys: Bootstrap of Kendall tau (10,000 replications, tau=0.378947) Recall: Large-sample Z=2.3360 P=0.0195 (2-sided, tie-corrected) 95% CI for true permutation-test P-value: (0.0197, 0.0206, 0.0215) Bootstrap median and 95% CI for tau: (0.2632, 0.3684, 0.4579) Bootstrap test for tau!=0: One-sided P: P=123/10,000 = (0.0101, 0.0123, 0.0145) Two-sided P: (0.0203, 0.0246, 0.0289)