Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mcor

Compute (Large) Correlation Matrix


Description

Compute a correlation matrix, possibly by robust methods, applicable also for the case of a large number of variables.

Usage

mcor(dm, method = c("standard", "Qn", "QnStable",
                    "ogkScaleTau2",  "ogkQn", "shrink"))

Arguments

dm

numeric data matrix; rows are observiations (“samples”), columns are variables.

method

a string; "standard" (default), "Qn", "QnStable", "ogkQn" and "shrink" envokes standard, elementwise robust (based on Q_n scale estimator, see Qn), robust (Q_n using OGK, see covOGK) or shrinked correlation estimate respectively.

Details

The "standard" method envokes a standard correlation estimator. "Qn" envokes a robust, elementwise correlation estimator based on the Qn scale estimte. "QnStable" also uses the Qn scale estimator, but uses an improved way of transforming that into the correlation estimator. "ogkQn" envokes a correlation estimator based on Qn using OGK. "shrink" is only useful when used with pcSelect. An optimal shrinkage parameter is used. Only correlation between response and covariates is shrinked.

Value

A correlation matrix estimated by the specified method.

Author(s)

Markus Kalisch kalisch@stat.math.ethz.ch and Martin Maechler

References

See those in the help pages for Qn and covOGK from package robustbase.

See Also

Qn and covOGK from package robustbase. pcorOrder for computing partial correlations.

Examples

## produce uncorrelated normal random variables
set.seed(42)
x <- rnorm(100)
y <- 2*x + rnorm(100)
## compute correlation of var1 and var2
mcor(cbind(x,y), method="standard")

## repeat but this time with heavy-tailed noise
yNoise <- 2*x + rcauchy(100)
mcor(cbind(x,yNoise), method="standard") ## shows almost no correlation
mcor(cbind(x,yNoise), method="Qn")       ## shows a lot correlation
mcor(cbind(x,yNoise), method="QnStable") ## shows still much correlation
mcor(cbind(x,yNoise), method="ogkQn")    ## ditto

pcalg

Methods for Graphical Models and Causal Inference

v2.7-2
GPL (>= 2)
Authors
Markus Kalisch [aut, cre], Alain Hauser [aut], Martin Maechler [aut], Diego Colombo [ctb], Doris Entner [ctb], Patrik Hoyer [ctb], Antti Hyttinen [ctb], Jonas Peters [ctb], Nicoletta Andri [ctb], Emilija Perkovic [ctb], Preetam Nandy [ctb], Philipp Ruetimann [ctb], Daniel Stekhoven [ctb], Manuel Schuerch [ctb], Marco Eigenmann [ctb], Leonard Henckel [ctb], Joris Mooij [ctb]
Initial release
2021-4-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.