When calculating a weighted median ensemble using simple_ensemble(), quantile crossing may occur due to this documented issue in matrixStats::weightedMedian(), which is called within simple_ensemble().
The discussion on the issue indicates that when there are duplicate x values, an unstable sort function may result in the weight values being flipped for the duplicate x values. This causes an issue when interpolate=TRUE, which is the default behavior for weightedMedian(), and produces an incorrect weighted median.
This is demonstrated by the following data, which should produce a weighted median of zero but actually produces a value of 0.078
Thanks for investigating, Li! I support setting interpolate = FALSE, which will also result in a more conventionally-understandable weighted median calculation.
When calculating a weighted median ensemble using
simple_ensemble()
, quantile crossing may occur due to this documented issue inmatrixStats::weightedMedian()
, which is called withinsimple_ensemble()
.The discussion on the issue indicates that when there are duplicate x values, an unstable sort function may result in the weight values being flipped for the duplicate x values. This causes an issue when
interpolate=TRUE
, which is the default behavior forweightedMedian()
, and produces an incorrect weighted median.This is demonstrated by the following data, which should produce a weighted median of zero but actually produces a value of 0.078
Below, a reproducible example for the same issue occurring with
simple_ensemble
is given based on the data set above:My proposal is to fix this issue in
simple_ensemble
by adding "interpolate = FALSE" toagg_args
when the user asks for a weighted median