Using Kish's effective sample size with weighted quantiles


Update: this blog post is a part of research that aimed to build weighed versions of various quantile estimators. A preprint with final results is available on arXiv: arXiv:2304.07265 [stat.ME]. Some information in this blog post can be obsolete: please, use the preprint as the primary reference.

In my previous posts, I described how to calculate weighted quantiles and their confidence intervals using the Harrell-Davis quantile estimator. This powerful technique allows applying quantile exponential smoothing and dispersion exponential smoothing for time series in order to get its moving properties.

When we work with weighted samples, we need a way to calculate the effective samples size. Previously, I used the sum of all weights normalized by the maximum weight. In most cases, it worked OK.

Recently, Ben Jann pointed out that it would be better to use the Kish’s formula to calculate the effective sample size. In this post, you find the formula and a few numerical simulations that illustrate the actual impact of the underlying sample size formula.

Let’s say we have a sample $x = \{ x_1, x_2, \ldots, x_n \}$ with a vector of corresponding weights $w = \{ w_1, w_2, \ldots, w_n \}$. In the non-weighted case (when all weights $w_i$ are equal), we can safely use the sample size $n$ in all equations that required the sample size. However, in the weighted case (when we have different values in $w$), we should perform some adjustments and calculate the effective sample size. Initially, I used the sum of all weights normalized by the maximum element:

$$ n_\textrm{eff/norm} = \dfrac{\sum_{i=1}^n w_i}{\max_{i=1}^{n} w_i}. $$

In kish1965, there is a better way to estimate the effective sample size:

$$ n_\textrm{eff/kish} = \frac{\Big( \sum_{i=1}^n w_i \Big)^2}{\sum_{i=1}^n w_i^2 }. $$

Let’s compare both approaches on a few data sets. First, let’s check the time series with two change points from the original post:

Here we estimate the moving median using exponential smoothing with lifetime = 5. As we can see, the Kish’s formula gives a shorter “retraining interval” after each change point.

Now let’s try another time series from the quantile exponential smoothing post with (monotonically increasing sine wave pattern with high outliers):

Here we can notice that the Kish’s formula is more resistant to outliers (it gives a smoother line with a fewer number of sharp peaks).

I have performed a series of additional experiments, and all of them have shown that the Kish’s formula provides better results. Of course, it worth to carefully measure the statistical efficiency of both options. However, based on the first impression, the Kish’s effective sample size is my new approach of choice. Thanks again to Ben Jann for the valuable hint!

References


References (6)

  1. Dispersion exponential smoothing (2021-05-11) 4 3 Mathematics Statistics Research
  2. Survey Sampling (1965) by L Kish 2 Mathematics Statistics
  3. Quantile exponential smoothing (2021-05-04) 7 3 Mathematics Statistics Research
  4. Robust alternative to statistical efficiency (2021-06-01) 4 3 Mathematics Statistics Research
  5. Weighted quantile estimators (2020-09-29) 6 8 Mathematics Statistics Research
  6. Quantile confidence intervals for weighted samples (2020-12-08) 3 5 Mathematics Statistics Research
  1. Weighted quantile estimators (2020-09-29) 6 8 Mathematics Statistics Research
  2. Quantile confidence intervals for weighted samples (2020-12-08) 3 5 Mathematics Statistics Research
  3. Weighted Mann-Whitney U test, Part 1 (2023-07-04) 4 2 Mathematics Statistics Research
  4. Weighted Mann-Whitney U test, Part 3 (2024-01-30) 8 Mathematics Statistics Research
  5. Weighted trimmed Harrell-Davis quantile estimator (2022-04-19) 5 Mathematics Statistics Research