Correlations

Simple bivariate correlation

cor() is used to compute correlations and cov() covariances. The share the same arguments.

cor(world[,2:10]) | Compute a correlation matrix (numerical data matrix or frame= |

cor(urb,infmor) | Compute correlation between two varuables |

>cor(urb,infmor, method="spearman") | Compute the spearmand coeefficient, default is "pearson"; "kendall" is the third available method |

cor(world[,2:10], na.rm=TRUE) | Remove missing values |

See help(cor)> for various use options to control missing data handling.

- symnum(cor(world[,2:10])) symbolic representation of a (correlation) matrix
- [library(corrgram)]corrgram(cor(world[,2:10])) a graphical representation of a correlation matrix.

Partial and semipartial (part) correlation

[library(ppcor)]

spcor(world[,2:4]) | Semipartial correlation of a matrix or frame |

pcor(world[,2:4]) | Partial correlation of a matrix or frame |

pcor(world[,c("infmor","urb","lit")]) | using column (variable) names |

pcor(world[,2:4], method="kendall") | use "kendall" instead of default "pearson", other possibility: "spearman" |

Related commands

- library(polycor) has many polychoric coefficients for contingency tables