braverock / PortfolioAnalytics

76 stars 46 forks source link

Return.clean() for method="boudt" runs covMcd() on a single column #15

Open sdittmar opened 5 years ago

sdittmar commented 5 years ago

The Return.clean() function in PortfolioAnalytics_1.1.0 hands single columns of the xts time series in a for loop to the clean.boudt() function, which than runs the covMcd() robust location and scatter estimation on a univariate time series.

Maybe the covMcd() function does have a univariate case, but it does seem either erroneous or inefficient.

sdittmar commented 5 years ago

The univariate case seems to be fully supported by the covMcd function and the FOR-loop is actually faster by a factor of 26x vs the multivariate covMcd in a small 2864 x 227 size xts example I tested. However, the $raw.center and $raw.cov results of the covMcd function are different between the univariate and the multivariate case. But since the results only flow into the calculation of the Mahalanobis distance and are not used elsewhere, I assume that speed was the reason for that "design choice"!?