mateuszbaran / CovarianceEstimation.jl

Lightweight robust covariance estimation in Julia
MIT License
42 stars 7 forks source link

Variance shrinkage #31

Open tlienart opened 5 years ago

tlienart commented 5 years ago

In Schafer and Strimmer (and other papers) they also discuss variance shrinkage and then they tend to combine both shrinkage of the sample covariance with shrinkage of the variance (e.g. in corpcor).

So I guess we could implement similar variance shrinkage estimators and allow the combination.

Any ideas for how the APi could be modified to allow this?

mateuszbaran commented 5 years ago

The user-facing API for this is already implemented for Simple covariance. The only problem, I think, would be balancing efficiency and complexity of implementation. Both cov(x::AbstractVector, c::CovarianceEstimator) and cov(x::AbstractVector, y::AbstractVector, c::CovarianceEstimator) can be implemented using cov(X::AbstractMatrix, c::CovariaceEstimator) (at least as a generic fallback).

tlienart commented 5 years ago

Hmm I'm not sure I like that completely or maybe I didn't get your idea. The idea here is that some methods do something like:

S = cov(X, Simple()) # possibly corrected
dS = Diagonal(S)
target = median(dS)
delta = # (some formula for intensity of variance shrinkage)
dS_shrunk = (1-delta) * dS + delta * target

with thereafter two possible paths: plug that diagonal back into another shrinkage estimator or just return it. In the first case it can just be considered as yet another CovarianceEstimator but not really in the second?

So it seems to me that we should maybe write a var function which possibly takes a LinearShrinkage method with specific targets (?) and returns a vector of size p. Btw this is what is done in corpcor with their method var.shrink.

mateuszbaran commented 5 years ago

Well, what I was saying is that existing methods already work when p=1, so you can get variance this way. I wasn't thinking about variance shrinkage methods that don't work this way. You are right that they should come as methods of var.

I don't really have any use cases for variance shrinkage right now so feel free here :).