linearShrinkEst()
computes the linear shrinkage estimate
of the covariance matrix for a given value of alpha
. The linear
shrinkage estimator is defined as the convex combination of the sample
covariance matrix and the identity matrix. The choice of alpha
determines the bias-variance tradeoff of the estimators in this class:
values near 1 are more likely to exhibit high variance but low bias, and
values near 0 are more likely to be be very biased but have low variance.
linearShrinkEst(dat, alpha)
A numeric data.frame
, matrix
, or similar object.
A numeric
between 0 and 1 defining convex combinations
of the sample covariance matrix and the identity. alpha = 1
produces
the sample covariance matrix, and alpha = 0
returns the identity.
A matrix
corresponding to the estimate of the covariance
matrix.
linearShrinkEst(dat = mtcars, alpha = 0.1)
#> mpg cyl disp hp drat wt
#> mpg 4.5324103 -0.91723790 -63.309721 -32.0732056 0.219506351 -0.51166847
#> cyl -0.9172379 1.21895161 19.966028 10.1931452 -0.066836694 0.13673710
#> disp -63.3097208 19.96602823 1536.979983 672.1158669 -4.706401915 10.76842040
#> hp -32.0732056 10.19314516 672.115867 470.9866935 -1.645110887 4.41926613
#> drat 0.2195064 -0.06683669 -4.706402 -1.6451109 0.928588135 -0.03727207
#> wt -0.5116685 0.13673710 10.768420 4.4192661 -0.037272073 0.99573790
#> qsec 0.4509149 -0.18868548 -9.605168 -8.6770081 0.008714073 -0.03054816
#> vs 0.2017137 -0.07298387 -4.437762 -2.4987903 0.011864919 -0.02736613
#> am 0.1803931 -0.04657258 -3.656401 -0.8320565 0.019015121 -0.03381048
#> gear 0.2135685 -0.06491935 -5.080262 -0.6358871 0.027598790 -0.04210806
#> carb -0.5363105 0.15201613 7.906875 8.3036290 -0.007840726 0.06757903
#> qsec vs am gear carb
#> mpg 0.450914919 0.201713710 0.180393145 0.21356855 -0.536310484
#> cyl -0.188685484 -0.072983871 -0.046572581 -0.06491935 0.152016129
#> disp -9.605168145 -4.437762097 -3.656401210 -5.08026210 7.906875000
#> hp -8.677008065 -2.498790323 -0.832056452 -0.63588710 8.303629032
#> drat 0.008714073 0.011864919 0.019015121 0.02759879 -0.007840726
#> wt -0.030548161 -0.027366129 -0.033810484 -0.04210806 0.067579032
#> qsec 1.219316613 0.067056452 -0.020495968 -0.02804032 -0.189411290
#> vs 0.067056452 0.925403226 0.004233871 0.00766129 -0.046370968
#> am -0.020495968 0.004233871 0.924899194 0.02923387 0.004637097
#> gear -0.028040323 0.007661290 0.029233871 0.95443548 0.032661290
#> carb -0.189411290 -0.046370968 0.004637097 0.03266129 1.160887097