cor.all: Compute Cross Correlations

View source: R/cor_all.R

cor.allR Documentation

Compute Cross Correlations

Description

Computes correlations among numeric data.

Usage

cor.all(data, method = "pearson", na.method = "pairwise",
  distribution = "normal")

Arguments

data

any rectangular object such as a data.frame or matrix.

method

a character string indicating which correlation coefficient is to be used. One of "pearson," "kendall," or "spearman," can be abbreviated.

na.method

a character string indicating which method to use for missing values. One of "fail," "omit," "pairwise," can be abbreviated.

distribution

a character string indicating the assumed distribution of the data. One of "normal," "lognormal," or "log1p", which can be abbreviated.

Details

The null hypothesis is that the data are not correlated with one another. The alternate hypothesis is that they are correlated with one another. This is a two-sided test. For other options, see cor.all.

If method is "pearson," then the correlation is based on Pearson's product moment correlation coefficient. If method is "kendall," then Kendall's tau is used to estimate a rank-based measure of association. If method is "spearman", then Spearman's rho is used to estimate the correlation of the ranks of the data. The last two methods may be used if the data do not necessarily come from a bivariate normal distribution.

If na.method is "fail," then cor.all stops if there are any missing numeric values. If it is "omit," then all rows with any missing values is removed before the correlations are computed. That option will always produce a correlation matrix that is positive definite. If na.method is "pairwise," then missing values are removed from each pairwise correlation.

If distribution is "normal," then the assumption for method = "pearson" is that the data are bivariate normal. If distribution is "lognormal," then the assumption for method = "pearson" is that the data are bivariate log-normal and all data are natural log-transformed. If distribution is "log1p," then the assumption for method = "pearson" is that the data are bivariate log-normal after adding 1 and all data are transformed using the log1p function. The data are transformed for any method, but only produce a different result for method = "pearson."

Value

An object of class "cor.all," which has these components:

estimates

a matrix of the correlations between each pair of numeric variables in data

p.values

a matrix of the attained p-values between each pair of numeric variables in data

counts

a matrix of observations in each pair of numeric variables in data

alternative

a character string indicating the alternative hypothesis, always "two.sided"

na.method

a character string indicating the method to handle missing values

method

a character string describing the method to compute the correlations

data.name

the name of the data set, derived from data

data

a data frame of the numeric variables

call.method

a character string indicating the method to compute the correlations

distribution

a character string indicating the distribution assumption of the data

Note

The print, plot, and summary methods are available for an object of class "cor.all."

References

Conover, W.J., 1980, Practical nonparametric statistics (2d ed.): New York, Wiley, 512 p.

Helsel, D.R. and Hirsch, R.M., 2002, Statistical methods in water resources: U.S. Geological Survey Techniques of Water-Resources Investigations, book 4, chap. A3, 522 p.

See Also

cor.test, plot.cor.all, summary.cor.all

Examples

## Not run: 
library(smwrData)
data(TNLoads)
cor.all(TNLoads[, 1:5])
cor.all(TNLoads, method="spearman")

## End(Not run)

USGS-R/smwrStats documentation built on Oct. 11, 2022, 6:15 a.m.