In the previous article, I introduced three estimation methods of Randomized Response: Maximum Likelihood, Gibbs Sampling and Collapsed Variational Bayesian.
I implemented and experimented with these methods in Python.
- iir/privacy/randomized-response at master · shuyo/iir · GitHub
- rr-mle.py
- Maximum Likelihood Estimation
- rr-gibbs.py
- Gibbs Sampling
- rr-vb.py
- Collapsed Variational Bayes
- rr-mle.py
rr-mle.py and rr-gibbs.py draw the result as charts after 10000 trials.
rr-vb.py separates inference trials and result drawing because of the very long execution time.
$ python rr-vb.py 100 # 1000 inference trials (parallel execution)
$ python rr-vb.py # result report
On a survey with choices, it estimates the ratio of true answers from N(=100,1000,10000) answers at ratio of 1:2:3:4 (i.e.
) randomized by Randomized Response mechanism with a design matrix with p=1/5 (see the previous article for notation).
Maximum Likelihood Estimation (MLE)
These figures are histograms of the 10000 estimates from randomized answers.
MLE has the same variance regardless of the true value because they are solutions to a linear equation. The smaller N, the larger the variance, so it may have more than 1 or a negative estimate.
Gibbs Sampling (GS)
These figures are histograms of 10000 Gibbs Sampling estimates (average of last 200 samples) with a prior parameter .
There is almost no difference between MLE and GS when N is large enough.
On the other hand, the Bayesian model is effective when N is small and MLE estimate may be negative. In MLE, estimates may be negative, but it is with in the positive range in Gibbs Sampling estimation. Its variance is also smaller than MLE’s.
MLE | GS 1.0 | GS 0.1 | GS 0.01 | |
0.10 | 0.18 | 0.13 | 0.11 | |
0.21 | 0.09 | 0.18 | 0.26 |
In Bayesian model, the estimates tends to be leveled from the true value due to regularization effect of prior. The above table is the mean and standard deviation of the esitmate for MLE and Gibbs sampling (“GS [num]” means Gibbs sampling estimation with prior parameter
[num]).
In Gibbs Sampling with , the estimate is approaching 0.25(=1/D). The leveling effect can be weakened by reducing the prior parameter
instead of increasing variance. But Gibbs Sampling estimation with a lower prior parameter has another problem.
These figures are histograms with . Because of the strong influence of the Dirichlet prior, only one of the estimates is close to 1, and the others collapse to 0. Though the mean of the estimates is close to the true value, the median is 0 (useless!!).
It remains even with N=1000.
Collapsed Variational Bayesian (VB)
These figures are histograms of 10000 estimates on Collapsed Variational Bayesian with a prior parameter .
The results of GS and VB look the same in the above figures, but VB has a smaller variance. The boxplots of estimates tells us that VB’s estimates are better than GS’s.
In all cases, VB(each left) has smaller variances than GS(each right). The standard deviations are written at the horizontal axis label.
In GS, there was a problem that estimates tend to degenerate when a prior parameter is small. What about VB?
The effect of prior remains for N=100, but “ordinary estimates” are obtained. The boxplot makes this clearer.
On GS, of N=100 collapses to 0 or is outliers, and
takes evenly from 0 to 1 (the variance is also extremely large!). VB has ordinary mountain-shaped distributions.
VB also has smaller variances than GS for large N, so it is available to balance leveling and variance by choosing the appropriate a prior parameter.