CovarianceEstimation.jl icon indicating copy to clipboard operation
CovarianceEstimation.jl copied to clipboard

Supporting passing in weights

Open rofinn opened this issue 7 years ago • 9 comments

It might be nice to support a lower level fit and transform API on top of just cov. This would allow folks to pass in an existing covariance matrix that they'd like to apply an estimation method to (e.g., a weighted covariance).

rofinn avatar Dec 03 '18 03:12 rofinn

I don't quite understand how would that work. Implemented formulas for covariance shrinkage assume normal covariance and a specific shrinkage target. Wouldn't using weighted covariance lead to wrong shrinkage coefficients?

mateuszbaran avatar Dec 03 '18 09:12 mateuszbaran

Hmmm, good point. I guess the R corpcor just lets you pass in the weights with a data matrix rather than precomputed values.

rofinn avatar Dec 08 '18 17:12 rofinn

StatsBase.jl has its own approach to weights and it looks nicer. I think it would be good to have a similar design here.

mateuszbaran avatar Dec 09 '18 15:12 mateuszbaran

Supporting weights, following the StatsBase API of cov(ce::CovarianceEstimator, X::AbstractMatrix, w::AbstractWeights), would be really useful :)

nickrobinson251 avatar Jun 04 '19 17:06 nickrobinson251

Yes, it would be very useful, but I still don't know if it's even possible to have generic implementation for all types of weights. Frequency weights should be relatively easy to support though. What kind of weights do you need?

mateuszbaran avatar Jun 04 '19 18:06 mateuszbaran

I believe AnalyticWeights. But also I am not sure weighted Lediot-Wolf is possible (I was hoping it was)

nickrobinson251 avatar Jul 01 '19 13:07 nickrobinson251

Unfortunately, I don't know how to modify Ledoit-Wolf to make it work with AnalyticWeights. If you find a paper about it, I will definitely like to see it.

mateuszbaran avatar Jul 01 '19 13:07 mateuszbaran

My colleague tells me it is not possible (or at least the proof in the LW paper breaks down when weights are added) ...but i've not done the working myself nor seen a paper on it.

nickrobinson251 avatar Jul 01 '19 15:07 nickrobinson251

NOTE: a potential work around could be to collect a weighted sampling first and then estimate the covariance from that.

rofinn avatar Jul 02 '19 00:07 rofinn