Skip to contents

Compute the robust covariance and correlation matrix of a numeric matrix. The function is used to check whether S_r != S_r_tilda and R_r == R_r_tilda?

Usage

compute_cov_cor(x, control)

Arguments

x

A numeric matrix or an object that can be coerced to a numeric matrix.

control

A control object (S4) for one of the available control classes, e.g. CovControlMcd-class, CovControlOgk-class, CovControlSest-class, etc., containing estimation options. The class of this object defines which estimator will be used. Alternatively a character string can be specified which names the estimator - one of auto, sde, mcd, ogk, m, mve, sfast, surreal, bisquare, rocke. If "auto" is specified or the argument is missing, the function will select the estimator.

Value

A list with the following components:

S_r

The robust covariance matrix of cov_x.

S_r_tilda

The robust covariance matrix of cov_scale_x.

R_r

The robust correlation matrix of cov_x.

R_r_tilda

The robust correlation matrix of cov_scale_x.

cov_x = rrcov::CovRobust(x = x, control = control) cov_scale_x = rrcov::CovRobust(x = scale(x), control = control)

References

Zhang, Y. Y. (2013), An Object Oriented Solution for Robust Factor Analysis.

Author

Ying-Ying Zhang (Robert) robertzhangyying@qq.com

Examples

data("hbk")
hbk.x = hbk[,1:3]

compute_cov_cor(x = hbk.x, control = "mcd")
#> $S_r
#>            X1         X2        X3
#> X1 1.22688941 0.05500588 0.1271656
#> X2 0.05500588 1.24880175 0.1525276
#> X3 0.12716557 0.15252762 1.1598081
#> 
#> $S_r_tilda
#>             X1          X2          X3
#> X1 0.091958921 0.001827776 0.002965407
#> X2 0.001827776 0.018396393 0.001576843
#> X3 0.002965407 0.001576843 0.008414476
#> 
#> $R_r
#>            X1         X2        X3
#> X1 1.00000000 0.04443853 0.1066041
#> X2 0.04443853 1.00000000 0.1267385
#> X3 0.10660407 0.12673854 1.0000000
#> 
#> $R_r_tilda
#>            X1         X2        X3
#> X1 1.00000000 0.04443853 0.1066041
#> X2 0.04443853 1.00000000 0.1267385
#> X3 0.10660407 0.12673854 1.0000000
#>