# Correlation Coefficient

Example Data | 244 | 238 | 1 |

Help | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|

## Correlation, Variance and Covariance (Matrices)## Description
## Usagevar(x, y = NULL, na.rm = FALSE, use) cov(x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman")) cor(x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman")) cov2cor(V) ## Arguments
## DetailsFor The inputs must be numeric (as determined by
If The denominator For When there are ties, Kendall's Scaling a covariance matrix into a correlation one can be achieved in
many ways, mathematically most appealing by multiplication with a
diagonal matrix from left and right, or more efficiently by using
## ValueFor ## NoteSome people have noted that the code for Kendall's tau is slow for
very large datasets (many more than 1000 cases). It rarely makes
sense to do such a computation, but see function
## ReferencesBecker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
Kendall, M. G. (1938) A new measure of rank correlation,
Kendall, M. G. (1945) The treatment of ties in rank problems.
## Examplesvar(1:10) # 9.166667 var(1:5, 1:5) # 2.5 ## Two simple vectors cor(1:10, 2:11) # == 1 ## Correlation Matrix of Multivariate sample: (Cl <- cor(longley)) ## Graphical Correlation Matrix: symnum(Cl) # highly correlated ## Spearman's rho and Kendall's tau symnum(clS <- cor(longley, method = "spearman")) symnum(clK <- cor(longley, method = "kendall")) ## How much do they differ? i <- lower.tri(Cl) cor(cbind(P = Cl[i], S = clS[i], K = clK[i])) ## cov2cor() scales a covariance matrix by its diagonal ## to become the correlation matrix. cov2cor # see the function definition {and learn ..} stopifnot(all.equal(Cl, cov2cor(cov(longley))), all.equal(cor(longley, method = "kendall"), cov2cor(cov(longley, method = "kendall")))) ##--- Missing value treatment: C1 <- cov(swiss) range(eigen(C1, only.values = TRUE)$values) # 6.19 1921 ## swM := "swiss" with 3 "missing"s : swM <- swiss colnames(swM) <- abbreviate(colnames(swiss), min=6) swM[1,2] <- swM[7,3] <- swM[25,5] <- NA # create 3 "missing" ## Consider all 5 "use" cases : (C. <- cov(swM)) # use="everything" quite a few NA's in cov.matrix try(cov(swM, use = "all")) # Error: missing obs... C2 <- cov(swM, use = "complete") stopifnot(identical(C2, cov(swM, use = "na.or.complete"))) range(eigen(C2, only.values = TRUE)$values) # 6.46 1930 C3 <- cov(swM, use = "pairwise") range(eigen(C3, only.values = TRUE)$values) # 6.19 1938 ## Kendall's tau doesn't change much: symnum(Rc <- cor(swM, method = "kendall", use = "complete")) symnum(Rp <- cor(swM, method = "kendall", use = "pairwise")) symnum(R. <- cor(swiss, method = "kendall")) ## "pairwise" is closer componentwise, summary(abs(c(1 - Rp/R.))) summary(abs(c(1 - Rc/R.))) ## but "complete" is closer in Eigen space: EV <- function(m) eigen(m, only.values=TRUE)$values summary(abs(1 - EV(Rp)/EV(R.)) / abs(1 - EV(Rc)/EV(R.))) |

R Output | Dataset Referenced | Date |
---|---|---|

Correlation Coefficient | Example Data | Mar 15, 2017 |

Correlation Coefficient | Example Data | Mar 15, 2017 |

Correlation Coefficient | Example Data | Mar 15, 2017 |

Correlation Coefficient | Bilgin_Data2 | Mar 15, 2017 |

Correlation Coefficient | R Dataset / Package datasets / UKgas | Mar 15, 2017 |

Recent Queries | App/Dataset | By | Date |
---|---|---|---|

Picostat Output - Simple Linear Regression | R Dataset / Package datasets / esoph | hyi2 | October 29, 2020 - 5:44 AM |

Picostat Output - Visual Summaries | R Dataset / Package datasets / esoph | hyi2 | October 29, 2020 - 5:42 AM |

Picostat Output - Simple Linear Regression | R Dataset / Package datasets / esoph | hyi2 | October 29, 2020 - 5:42 AM |

Picostat Output - Numerical Summaries | R Dataset / Package datasets / quakes | wicetram | October 24, 2020 - 3:20 PM |

Picostat Output - Visual Summaries | R Dataset / Package datasets / quakes | wicetram | October 24, 2020 - 3:17 PM |

#### Pagination

Title | Authored on | Content type |
---|---|---|

R Dataset / Package survival / veteran | March 9, 2018 - 1:06 PM | Dataset |

R Dataset / Package Ecdat / PatentsHGH | March 9, 2018 - 1:06 PM | Dataset |

R Dataset / Package psych / Holzinger | March 9, 2018 - 1:06 PM | Dataset |

R Dataset / Package wooldridge / fair | March 9, 2018 - 1:06 PM | Dataset |

R Dataset / Package COUNT / medpar | March 9, 2018 - 1:06 PM | Dataset |