corSmooth: Smooth a Non PD Correlation Matrix

Description Usage Arguments Value Author(s) References Examples

View source: R/corSmooth.R

Description

A function for smoothing a non-positive definite correlation matrix by the method of Knol and Berger (1991).

Usage

1
corSmooth(R, eps = 1e+08 * .Machine$double.eps)

Arguments

R

A non-positive definite correlation matrix.

eps

Small positive number to control the size of the non-scaled smallest eigenvalue of the smoothed R matrix. Default = 1E8 * .Machine$double.eps

Value

Rsmoothed

A Smoothed (positive definite) correlation matrix.

Author(s)

Niels Waller

References

Knol, D. L., and Berger, M. P. F., (1991). Empirical comparison between factor analysis and multidimensional item response models.Multivariate Behavioral Research, 26, 457-477.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## choose eigenvalues such that R is NPD
l <- c(3.0749126,  0.9328397,  0.5523868,  0.4408609, -0.0010000)

## Generate NPD R
R <- genCorr(eigenval = l, seed = 123)
print(eigen(R)$values)

#> [1]  3.0749126  0.9328397  0.5523868  0.4408609 -0.0010000

## Smooth R
Rsm<-corSmooth(R, eps = 1E8 * .Machine$double.eps)
print(eigen(Rsm)$values)

#> [1] 3.074184e+00 9.326669e-01 5.523345e-01 4.408146e-01 2.219607e-08

fungible documentation built on Sept. 29, 2021, 1:06 a.m.

Related to corSmooth in fungible...