{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0d19573c",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"id": "e405187b",
"metadata": {},
"source": [
"# Expected Utilities of Random Responses"
]
},
{
"cell_type": "markdown",
"id": "432e07c2",
"metadata": {},
"source": [
"## Overview\n",
"\n",
"[This QuantEcon lecture](https://python.quantecon.org/rand_resp.html) describes randomized response surveys in the tradition of Warner [[Warner, 1965](https://python.quantecon.org/zreferences.html#id10)] that are designed to protect respondents’ privacy.\n",
"\n",
"Lars Ljungqvist [[Ljungqvist, 1993](https://python.quantecon.org/zreferences.html#id11)] analyzed how a respondent’s decision about whether to answer truthfully depends on **expected utility**.\n",
"\n",
"The lecture tells how Ljungqvist used his framework to shed light on alternative randomized response survey techniques\n",
"proposed, for example, by [[Lanke, 1975](https://python.quantecon.org/zreferences.html#id18)], [[Lanke, 1976](https://python.quantecon.org/zreferences.html#id12)], [[Leysieffer and Warner, 1976](https://python.quantecon.org/zreferences.html#id13)],\n",
"[[Anderson, 1976](https://python.quantecon.org/zreferences.html#id14)], [[Fligner *et al.*, 1977](https://python.quantecon.org/zreferences.html#id15)], [[Greenberg *et al.*, 1977](https://python.quantecon.org/zreferences.html#id16)],\n",
"[[Greenberg *et al.*, 1969](https://python.quantecon.org/zreferences.html#id17)]."
]
},
{
"cell_type": "markdown",
"id": "e5af8f7f",
"metadata": {},
"source": [
"## Privacy Measures\n",
"\n",
"We consider randomized response models with only two possible answers, “yes” and “no.”\n",
"\n",
"The design determines probabilities\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
"\\text{Pr}(\\text{yes}|A)&=1-\\text{Pr}(\\text{no}|A)\\\\\n",
"\\text{Pr}(\\text{yes}|A^{'})&=1-\\text{Pr}(\\text{no}|A^{'})\n",
"\\end{aligned}\n",
"$$\n",
"\n",
"These design probabilities in turn can be used to compute the conditional probability of belonging to the sensitive group $ A $ for a given response, say $ r $:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(A|r)=\\frac{\\pi_A \\text{Pr}(r|A)}{\\pi_A \\text{Pr}(r|A)+ (1-\\pi_A) \\text{Pr}(r|A^{'})} \\tag{16.1}\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "7c3a4ecd",
"metadata": {},
"source": [
"## Zoo of Concepts\n",
"\n",
"At this point we describe some concepts proposed by various researchers"
]
},
{
"cell_type": "markdown",
"id": "b47d752d",
"metadata": {},
"source": [
"### Leysieffer and Warner(1976)\n",
"\n",
"The response $ r $ is regarded as jeopardizing with respect to $ A $ or $ A^{'} $ if\n",
"\n",
"\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
"\\text{Pr}(A|r)&>\\pi_A\\\\\n",
"\\text{or}&\\\\\n",
"\\text{Pr}(A^{'}|r)&>1-\\pi_A\n",
"\\end{aligned} \\tag{16.2}\n",
"$$\n",
"\n",
"From Bayes’s rule:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\frac{\\text{Pr}(A|r)}{\\text{Pr}(A^{'}|r)}\\times \\frac{(1-\\pi_A)}{\\pi_A} = \\frac{\\text{Pr}(r|A)}{\\text{Pr}(r|A^{'})} \\tag{16.3}\n",
"$$\n",
"\n",
"If this expression is greater (less) than unity, it follows that $ r $ is jeopardizing with respect to $ A $($ A^{'} $). Then, the natural measure of jeopardy will be:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
"g(r|A)&=\\frac{\\text{Pr}(r|A)}{\\text{Pr}(r|A^{'})}\\\\\n",
"&\\text{and}\\\\\n",
"g(r|A^{'})&=\\frac{\\text{Pr}(r|A^{'})}{\\text{Pr}(r|A)}\n",
"\\end{aligned} \\tag{16.4}\n",
"$$\n",
"\n",
"Suppose, without loss of generality, that $ \\text{Pr}(\\text{yes}|A)>\\text{Pr}(\\text{yes}|A^{'}) $, then a yes (no) answer is jeopardizing with respect $ A $($ A^{'} $), that is,\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
"g(\\text{yes}|A)&>1\\\\\n",
"\\text{and}&\\\\\n",
"g(\\text{no}|A^{'})&>1\n",
"\\end{aligned}\n",
"$$\n",
"\n",
"Leysieffer and Warner proved that the variance of the estimate can only be decreased through an increase in one or both of these two measures of jeopardy.\n",
"\n",
"An efficient randomized response model is, therefore, any model that attains the maximum acceptable levels of jeopardy that are consistent with cooperation of the respondents.\n",
"\n",
"As a special example, Leysieffer and Warner considered “a problem in which there is no jeopardy in a no answer”; that is, $ g(\\text{no}|A^{'}) $ can be of unlimited magnitude.\n",
"\n",
"Evidently, an optimal design must have\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A)=1\n",
"$$\n",
"\n",
"which implies that\n",
"\n",
"$$\n",
"\\text{Pr}(A|\\text{no})=0\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "0acc88f5",
"metadata": {},
"source": [
"### Lanke(1976)\n",
"\n",
"Lanke (1975) [[Lanke, 1975](https://python.quantecon.org/zreferences.html#id18)] argued that “it is membership in Group A that people may want to hide, not membership in the complementary Group A’.”\n",
"\n",
"For that reason, Lanke (1976) [[Lanke, 1976](https://python.quantecon.org/zreferences.html#id12)] argued that an appropriate measure of protection is to minimize\n",
"\n",
"\n",
"\n",
"$$\n",
"\\max \\left\\{ \\text{Pr}(A|\\text{yes}) , \\text{Pr}(A|\\text{no}) \\right\\} \\tag{16.5}\n",
"$$\n",
"\n",
"Holding this measure constant, he explained under what conditions the smallest variance of the estimate was achieved with the unrelated question model or Warner’s (1965) original model."
]
},
{
"cell_type": "markdown",
"id": "25407768",
"metadata": {},
"source": [
"### 2.3 Fligner, Policello, and Singh\n",
"\n",
"Fligner, Policello, and Singh reached similar conclusion as Lanke (1976). [[Fligner *et al.*, 1977](https://python.quantecon.org/zreferences.html#id15)]\n",
"\n",
"They measured “private protection” as\n",
"\n",
"\n",
"\n",
"$$\n",
"\\frac{1-\\max \\left\\{ \\text{Pr}(A|\\text{yes}) , \\text{Pr}(A|\\text{no}) \\right\\}}{1-\\pi_A} \\tag{16.6}\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "e04176c8",
"metadata": {},
"source": [
"### 2.4 Greenberg, Kuebler, Abernathy, and Horvitz (1977)\n",
"\n",
"[[Greenberg *et al.*, 1977](https://python.quantecon.org/zreferences.html#id16)]\n",
"\n",
"Greenberg, Kuebler, Abernathy, and Horvitz (1977) stressed the importance of examining the risk to respondents who do not belong to $ A $ as well as the risk to those who do belong to the sensitive group.\n",
"\n",
"They defined the hazard for an individual in $ A $ as the probability that he or she is perceived as belonging to $ A $:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A)\\times \\text{Pr}(A|\\text{yes})+\\text{Pr}(\\text{no}|A)\\times \\text{Pr}(A|\\text{no}) \\tag{16.7}\n",
"$$\n",
"\n",
"Similarly, the hazard for an individual who does not belong to $ A $ would be\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A^{'})\\times \\text{Pr}(A|\\text{yes})+\\text{Pr}(\\text{no}|A^{'}) \\times \\text{Pr}(A|\\text{no}) \\tag{16.8}\n",
"$$\n",
"\n",
"Greenberg et al. (1977) also considered an alternative related measure of hazard that “is likely to be closer to the actual concern felt by a respondent.”\n",
"\n",
"The “limited hazard” for an individual in $ A $ and $ A^{'} $ is\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A)\\times \\text{Pr}(A|\\text{yes}) \\tag{16.9}\n",
"$$\n",
"\n",
"and\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A^{'})\\times \\text{Pr}(A|\\text{yes}) \\tag{16.10}\n",
"$$\n",
"\n",
"This measure is just the first term in [(16.7)](#equation-eq-util-rand-seven-a), i.e., the probability that an individual answers “yes” and is perceived to belong to $ A $."
]
},
{
"cell_type": "markdown",
"id": "ec18562a",
"metadata": {},
"source": [
"## Respondent’s Expected Utility"
]
},
{
"cell_type": "markdown",
"id": "c94a5cbe",
"metadata": {},
"source": [
"### Truth Border\n",
"\n",
"Key assumptions that underlie a randomized response technique for estimating the fraction of a population that belongs to $ A $ are:\n",
"\n",
"- **Assumption 1**: Respondents feel discomfort from being thought of as belonging to $ A $. \n",
"- **Assumption 2**: Respondents prefer to answer questions truthfully than to lie, so long as the cost of doing so is not too high. The cost is taken to be the discomfort in 1. \n",
"\n",
"\n",
"Let $ r_i $ denote individual $ i $’s response to the randomized question.\n",
"\n",
"$ r_i $ can only take values “yes” or “no”.\n",
"\n",
"For a given design of a randomized response interview and a given belief about the fraction of the population\n",
"that belongs to $ A $, the respondent’s answer is associated with a conditional probability $ \\text{Pr}(A|r_i) $ that the individual belongs to $ A $.\n",
"\n",
"Given $ r_i $ and complete privacy, the individual’s utility is higher if $ r_i $ represents a truthful answer rather than a lie.\n",
"\n",
"In terms of a respondent’s expected utility as a function of $ \\text{Pr}(A|r_i) $ and $ r_i $\n",
"\n",
"- The higher is $ \\text{Pr}(A|r_i) $, the lower isindividual $ i $’s expected utility. \n",
"- expected utility is higher if $ r_i $ represents a truthful answer rather than a lie \n",
"\n",
"\n",
"Define:\n",
"\n",
"- $ \\phi_i \\in \\left\\{\\text{truth},\\text{lie}\\right\\} $, a dichotomous variable that indicates whether or not $ r_i $ is a truthful statement. \n",
"- $ U_i\\left(\\text{Pr}(A|r_i),\\phi_i\\right) $, a utility function that is differentiable in its first argument, summarizes individual $ i $’s expected utility. \n",
"\n",
"\n",
"Then there is an $ r_i $ such that\n",
"\n",
"\n",
"\n",
"$$\n",
"\\frac{\\partial U_i\\left(\\text{Pr}(A|r_i),\\phi_i\\right) }{\\partial \\text{Pr}(A|r_i)} <0, \\text{ for } \\phi_i \\in \\left\\{\\text{truth},\\text{lie}\\right\\} \\tag{16.11}\n",
"$$\n",
"\n",
"and\n",
"\n",
"\n",
"\n",
"$$\n",
"U_i\\left(\\text{Pr}(A|r_i),\\text{truth}\\right)>U_i\\left(\\text{Pr}(A|r_i),\\text{lie}\\right) , \\text{ for } \\text{Pr}(A|r_i) \\in [0,1] \\tag{16.12}\n",
"$$\n",
"\n",
"Suppose now that correct answer for individual $ i $ is “yes”.\n",
"\n",
"Individual $ i $ would choose to answer truthfully if\n",
"\n",
"\n",
"\n",
"$$\n",
"U_i\\left(\\text{Pr}(A|\\text{yes}),\\text{truth}\\right)\\geq U_i\\left(\\text{Pr}(A|\\text{no}),\\text{lie}\\right) \\tag{16.13}\n",
"$$\n",
"\n",
"If the correct answer is “no”, individual $ i $ would volunteer the correct answer only if\n",
"\n",
"\n",
"\n",
"$$\n",
"U_i\\left(\\text{Pr}(A|\\text{no}),\\text{truth}\\right)\\geq U_i\\left(\\text{Pr}(A|\\text{yes}),\\text{lie}\\right) \\tag{16.14}\n",
"$$\n",
"\n",
"Assume that\n",
"\n",
"$$\n",
"\\text{Pr}(A|\\text{yes})>\\pi_A>\\text{Pr}(A|\\text{no})\n",
"$$\n",
"\n",
"so that a “yes” answer increases the odds that an individual belongs to $ A $.\n",
"\n",
"Constraint [(16.14)](#equation-eq-util-rand-ten-b) holds for sure.\n",
"\n",
"Consequently, constraint [(16.13)](#equation-eq-util-rand-ten-a) becomes the single necessary condition for individual $ i $ always to answer truthfully.\n",
"\n",
"At equality, constraint $ (10.\\text{a}) $ determines conditional probabilities that make the individual indifferent between telling the truth and lying when the correct answer is “yes”:\n",
"\n",
"\n",
"\n",
"$$\n",
"U_i\\left(\\text{Pr}(A|\\text{yes}),\\text{truth}\\right)= U_i\\left(\\text{Pr}(A|\\text{no}),\\text{lie}\\right) \\tag{16.15}\n",
"$$\n",
"\n",
"Equation [(16.15)](#equation-eq-util-rand-eleven) defines a “truth border”.\n",
"\n",
"Differentiating [(16.15)](#equation-eq-util-rand-eleven) with respect to the conditional probabilities shows that the truth border has a positive slope in the space of conditional probabilities:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\frac{\\partial \\text{Pr}(A|\\text{no})}{\\partial \\text{Pr}(A|\\text{yes})}=\\frac{\\frac{\\partial U_i\\left(\\text{Pr}(A|\\text{yes}),\\text{truth}\\right) }{\\partial \\text{Pr}(A|\\text{yes})}}{\\frac{\\partial U_i\\left(\\text{Pr}(A|\\text{no}),\\text{lie}\\right) }{\\partial \\text{Pr}(A|\\text{no})}}>0 \\tag{16.16}\n",
"$$\n",
"\n",
"The source of the positive relationship is:\n",
"\n",
"- The individual is willing to volunteer a truthful “yes” answer so long as the utility from doing so (i.e., the left side of [(16.15)](#equation-eq-util-rand-eleven)) is at least as high as the utility of lying on the right side of [(16.15)](#equation-eq-util-rand-eleven). \n",
"- Suppose now that $ \\text{Pr}(A|\\text{yes}) $ increases. That reduces the utility of telling the truth. To preserve indifference between a truthful answer and a lie, $ \\text{Pr}(A|\\text{no}) $ must increase to reduce the utility of lying. "
]
},
{
"cell_type": "markdown",
"id": "baeee319",
"metadata": {},
"source": [
"### Drawing a Truth Border\n",
"\n",
"We can deduce two things about the truth border:\n",
"\n",
"- The truth border divides the space of conditional probabilities into two subsets: “truth telling” and “lying”. Thus, sufficient privacy elicits a truthful answer, whereas insufficient privacy results in a lie. The truth border depends on a respondent’s utility function. \n",
"- Assumptions in [(16.11)](#equation-eq-util-rand-nine-a) and [(16.11)](#equation-eq-util-rand-nine-a) are sufficient only to guarantee a positive slope of the truth border. The truth border can have either a concave or a convex shape. \n",
"\n",
"\n",
"We can draw some truth borders with the following Python code:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0efbf6e6",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"x1 = np.arange(0, 1, 0.001)\n",
"y1 = x1 - 0.4\n",
"x2 = np.arange(0.4**2, 1, 0.001)\n",
"y2 = (pow(x2, 0.5) - 0.4)**2\n",
"x3 = np.arange(0.4**0.5, 1, 0.001)\n",
"y3 = pow(x3**2 - 0.4, 0.5)\n",
"plt.figure(figsize=(12, 10))\n",
"plt.plot(x1, y1, 'r-', label='Truth Border of: $U_i(Pr(A|r_i),\\phi_i)=-Pr(A|r_i)+f(\\phi_i)$')\n",
"plt.fill_between(x1, 0, y1, facecolor='red', alpha=0.05)\n",
"plt.plot(x2, y2, 'b-', label='Truth Border of: $U_i(Pr(A|r_i),\\phi_i)=-Pr(A|r_i)^{2}+f(\\phi_i)$')\n",
"plt.fill_between(x2, 0, y2, facecolor='blue', alpha=0.05)\n",
"plt.plot(x3, y3, 'y-', label='Truth Border of: $U_i(Pr(A|r_i),\\phi_i)=-\\sqrt{Pr(A|r_i)}+f(\\phi_i)$')\n",
"plt.fill_between(x3, 0, y3, facecolor='green', alpha=0.05)\n",
"plt.plot(x1, x1, ':', linewidth=2)\n",
"plt.xlim([0, 1])\n",
"plt.ylim([0, 1])\n",
"\n",
"plt.xlabel('Pr(A|yes)')\n",
"plt.ylabel('Pr(A|no)')\n",
"plt.text(0.42, 0.3, \"Truth Telling\", fontdict={'size':28, 'style':'italic'})\n",
"plt.text(0.8, 0.1, \"Lying\", fontdict={'size':28, 'style':'italic'})\n",
"\n",
"plt.legend(loc=0, fontsize='large')\n",
"plt.title('Figure 1.1')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "c4fc4647",
"metadata": {},
"source": [
"Figure 1.1 three types of truth border.\n",
"\n",
"Without loss of generality, we consider the truth border:\n",
"\n",
"$$\n",
"U_i(\\text{Pr}(A|r_i),\\phi_i)=-\\text{Pr}(A|r_i)+f(\\phi_i)\n",
"$$\n",
"\n",
"and plot the “truth telling” and “lying area” of individual $ i $ in Figure 1.2:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b72d7d72",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"x1 = np.arange(0, 1, 0.001)\n",
"y1 = x1 - 0.4\n",
"z1 = x1\n",
"z2 = 0\n",
"plt.figure(figsize=(12, 10))\n",
"plt.plot(x1, y1,'r-',label='Truth Border of: $U_i(Pr(A|r_i),\\phi_i)=-Pr(A|r_i)+f(\\phi_i)$')\n",
"plt.plot(x1, x1, ':', linewidth=2)\n",
"plt.fill_between(x1, y1, z1, facecolor='blue', alpha=0.05, label='truth telling')\n",
"plt.fill_between(x1, z2, y1, facecolor='green', alpha=0.05, label='lying')\n",
"plt.xlim([0, 1])\n",
"plt.ylim([0, 1])\n",
"\n",
"plt.xlabel('Pr(A|yes)')\n",
"plt.ylabel('Pr(A|no)')\n",
"plt.text(0.5, 0.4, \"Truth Telling\", fontdict={'size':28, 'style':'italic'})\n",
"plt.text(0.8, 0.2, \"Lying\", fontdict={'size':28, 'style':'italic'})\n",
"\n",
"plt.legend(loc=0, fontsize='large')\n",
"plt.title('Figure 1.2')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "c56c748d",
"metadata": {},
"source": [
"## Utilitarian View of Survey Design"
]
},
{
"cell_type": "markdown",
"id": "f9fedc8d",
"metadata": {},
"source": [
"### Iso-variance Curves\n",
"\n",
"A statistician’s objective is\n",
"\n",
"- to find a randomized response survey design that minimizes the bias and the variance of the estimator. \n",
"\n",
"\n",
"Given a design that ensures truthful answers by all respondents, Anderson(1976, Theorem 1) [[Anderson, 1976](https://python.quantecon.org/zreferences.html#id14)] showed that the minimum variance estimate in the two-response model has variance\n",
"\n",
"\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
"V(\\text{Pr}(A|\\text{yes}) , \\text{Pr}(A|\\text{no}))\n",
"= &\\frac{{\\pi_A}^2 (1-\\pi_A)^2}{n}\\times \\frac{1}{\\text{Pr}(A|\\text{yes})-\\pi_A}\\times \\frac{1}{\\pi_A-\\text{Pr}(A|\\text{no})}\n",
"\\end{aligned} \\tag{16.17}\n",
"$$\n",
"\n",
"where the random sample with replacement consists of $ n $ individuals.\n",
"\n",
"We can use Expression [(16.17)](#equation-eq-util-rand-thirteen) to draw iso-variance curves.\n",
"\n",
"The following inequalities restrict the shapes of iso-variance curves:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\frac{d \\text{ Pr}(A|\\text{no})}{d\\text{ Pr}(A|\\text{yes})}\\bigg|_{\\text{constant variance}}=\\frac{\\pi_A-\\text{Pr}(A|\\text{no})}{\\text{Pr}(A|\\text{yes})-\\pi_A}>0 \\tag{16.18}\n",
"$$\n",
"\n",
"\n",
"\n",
"$$\n",
"\\frac{d^2 \\text{ Pr}(A|\\text{no})}{d\\text{ Pr}(A|\\text{yes})^2}\\bigg|_{\\text{constant variance}}=- \\frac{2 \\left[\\pi_A-\\text{Pr}(A|\\text{no})\\right]}{\\left[\\text{Pr}(A|\\text{yes})-\\pi_A \\right]^2}<0 \\tag{16.19}\n",
"$$\n",
"\n",
"From expression [(16.17)](#equation-eq-util-rand-thirteen), [(16.18)](#equation-eq-util-rand-fourteen-a) and [(16.19)](#equation-eq-util-rand-fourteen-b) we can see that:\n",
"\n",
"- Variance can be reduced only by increasing the distance of $ \\text{Pr}(A|\\text{yes}) $ and/or $ \\text{Pr}(A|\\text{no}) $ from $ r_A $. \n",
"- Iso-variance curves are always upward-sloping and concave. "
]
},
{
"cell_type": "markdown",
"id": "a5b80de9",
"metadata": {},
"source": [
"### Drawing Iso-variance Curves\n",
"\n",
"We use Python code to draw iso-variance curves.\n",
"\n",
"The pairs of conditional probabilities can be attained using Warner’s (1965) model.\n",
"\n",
"Note that:\n",
"\n",
"- Any point on the iso-variance curves can be attained with the unrelated question model as long as the statistician can completely control the model design. \n",
"- Warner’s (1965) original randomized response model is less flexible than the unrelated question model. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "526faa99",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"class Iso_Variance:\n",
" def __init__(self, pi, n):\n",
" self.pi = pi\n",
" self.n = n\n",
"\n",
" def plotting_iso_variance_curve(self):\n",
" pi = self.pi\n",
" n = self.n\n",
"\n",
" nv = np.array([0.27, 0.34, 0.49, 0.74, 0.92, 1.1, 1.47, 2.94, 14.7])\n",
" x = np.arange(0, 1, 0.001)\n",
" x0 = np.arange(pi, 1, 0.001)\n",
" x2 = np.arange(0, pi, 0.001)\n",
" y1 = [pi for i in x0]\n",
" y2 = [pi for i in x2]\n",
" y0 = 1 / (1 + (x0 * (1 - pi)**2) / ((1 - x0) * pi**2))\n",
"\n",
" plt.figure(figsize=(12, 10))\n",
" plt.plot(x0, y0, 'm-', label='Warner')\n",
" plt.plot(x, x, 'c:', linewidth=2)\n",
" plt.plot(x0, y1,'c:', linewidth=2)\n",
" plt.plot(y2, x2, 'c:', linewidth=2)\n",
" for i in range(len(nv)):\n",
" y = pi - (pi**2 * (1 - pi)**2) / (n * (nv[i] / n) * (x0 - pi + 1e-8))\n",
" plt.plot(x0, y, 'k--', alpha=1 - 0.07 * i, label=f'V{i+1}')\n",
" plt.xlim([0, 1])\n",
" plt.ylim([0, 0.5])\n",
" plt.xlabel('Pr(A|yes)')\n",
" plt.ylabel('Pr(A|no)')\n",
" plt.legend(loc=0, fontsize='large')\n",
" plt.text(0.32, 0.28, \"High Var\", fontdict={'size':15, 'style':'italic'})\n",
" plt.text(0.91, 0.01, \"Low Var\", fontdict={'size':15, 'style':'italic'})\n",
" plt.title('Figure 2')\n",
" plt.show()"
]
},
{
"cell_type": "markdown",
"id": "7bafb182",
"metadata": {},
"source": [
"Properties of iso-variance curves are:\n",
"\n",
"- All points on one iso-variance curve share the same variance \n",
"- From $ V_1 $ to $ V_9 $, the variance of the iso-variance curve increase monotonically, as colors brighten monotonically \n",
"\n",
"\n",
"Suppose the parameters of the iso-variance model follow those in Ljungqvist [[Ljungqvist, 1993](https://python.quantecon.org/zreferences.html#id11)], which are:\n",
"\n",
"- $ \\pi=0.3 $ \n",
"- $ n=100 $ \n",
"\n",
"\n",
"Then we can plot the iso-variance curve in Figure 2:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ec6f5bf1",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"var = Iso_Variance(pi=0.3, n=100)\n",
"var.plotting_iso_variance_curve()"
]
},
{
"cell_type": "markdown",
"id": "e7af057b",
"metadata": {},
"source": [
"### Optimal Survey\n",
"\n",
"A point on an iso-variance curves can be attained with the unrelated question design.\n",
"\n",
"We now focus on finding an “optimal survey design” that\n",
"\n",
"- Minimizes the variance of the estimator subject to privacy restrictions. \n",
"\n",
"\n",
"To obtain an optimal design, we first superimpose all individuals’ truth borders on the iso-variance mapping.\n",
"\n",
"To construct an optimal design\n",
"\n",
"- The statistician should find the intersection of areas above all truth borders; that is, the set of conditional probabilities ensuring truthful answers from all respondents. \n",
"- The point where this set touches the lowest possible iso-variance curve determines an optimal survey design. \n",
"\n",
"\n",
"Consquently, a minimum variance unbiased estimator is pinned down by an individual who is the least willing to volunteer a truthful answer.\n",
"\n",
"Here are some comments about the model design:\n",
"\n",
"- An individual’s decision of whether or not to answer truthfully depends on his or her belief about other respondents’ behavior, because this determines the individual’s calculation of $ \\text{ Pr}(A|\\text{yes}) $ and $ \\text{ Pr}(A|\\text{no}) $. \n",
"- An equilibrium of the optimal design model is a Nash equilibrium of a noncooperative game. \n",
"- Assumption [(16.12)](#equation-eq-util-rand-nine-b) is sufficient to guarantee existence of an optimal model design. By choosing $ \\text{ Pr}(A|\\text{yes}) $ and $ \\text{ Pr}(A|\\text{no}) $ sufficiently close to each other, all respondents will find it optimal to answer truthfully. The closer are these probabilities, the higher the variance of the estimator becomes. \n",
"- If respondents experience a large enough increase in expected utility from telling the truth, then there is no need to use a randomized response model. The smallest possible variance of the estimate is then obtained at $ \\text{ Pr}(A|\\text{yes})=1 $ and $ \\text{ Pr}(A|\\text{no})=0 $ ; that is, when respondents answer truthfully to direct questioning. \n",
"- A more general design problem would be to minimize some weighted sum of the estimator’s variance and bias. It would be optimal to accept some lies from the most “reluctant” respondents. "
]
},
{
"cell_type": "markdown",
"id": "7fba536c",
"metadata": {},
"source": [
"## Criticisms of Proposed Privacy Measures\n",
"\n",
"We can use a utilitarian approach to analyze some privacy measures.\n",
"\n",
"We’ll enlist Python Code to help us."
]
},
{
"cell_type": "markdown",
"id": "044748a0",
"metadata": {},
"source": [
"### Analysis of Method of Lanke’s (1976)\n",
"\n",
"Lanke (1976) recommends a privacy protection criterion that minimizes:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\max \\left\\{ \\text{Pr}(A|\\text{yes}) , \\text{Pr}(A|\\text{no}) \\right\\} \\tag{16.20}\n",
"$$\n",
"\n",
"Following Lanke’s suggestion, the statistician should find the highest possible $ \\text{ Pr}(A|\\text{yes}) $ consistent with truth telling while $ \\text{ Pr}(A|\\text{no}) $ is fixed at 0. The variance is then minimized at point $ X $ in Figure 3.\n",
"\n",
"However, we can see that in Figure 3, point $ Z $ offers a smaller variance that still allows cooperation of the respondents, and it is achievable following our discussion of the truth border in Part III:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a4a905f",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"pi = 0.3\n",
"n = 100\n",
"nv = [0.27, 0.34, 0.49, 0.74, 0.92, 1.1, 1.47, 2.94, 14.7]\n",
"x = np.arange(0, 1, 0.001)\n",
"y = x - 0.4\n",
"z = x\n",
"x0 = np.arange(pi, 1, 0.001)\n",
"x2 = np.arange(0, pi, 0.001)\n",
"y1 = [pi for i in x0]\n",
"y2 = [pi for i in x2]\n",
"\n",
"plt.figure(figsize=(12, 10))\n",
"plt.plot(x, x, 'c:', linewidth=2)\n",
"plt.plot(x0, y1, 'c:', linewidth=2)\n",
"plt.plot(y2, x2, 'c:', linewidth=2)\n",
"plt.plot(x, y, 'r-', label='Truth Border')\n",
"plt.fill_between(x, y, z, facecolor='blue', alpha=0.05, label='truth telling')\n",
"plt.fill_between(x, 0, y, facecolor='green', alpha=0.05, label='lying')\n",
"for i in range(len(nv)):\n",
" y = pi - (pi**2 * (1 - pi)**2) / (n * (nv[i] / n) * (x0 - pi + 1e-8))\n",
" plt.plot(x0, y, 'k--', alpha=1 - 0.07 * i, label=f'V{i+1}')\n",
"\n",
"\n",
"plt.scatter(0.498, 0.1, c='b', marker='*', label='Z', s=150)\n",
"plt.scatter(0.4, 0, c='y', label='X', s=150)\n",
"plt.xlim([0, 1])\n",
"plt.ylim([0, 0.5])\n",
"plt.xlabel('Pr(A|yes)')\n",
"plt.ylabel('Pr(A|no)')\n",
"plt.text(0.45, 0.35, \"Truth Telling\", fontdict={'size':28, 'style':'italic'})\n",
"plt.text(0.85, 0.35, \"Lying\",fontdict = {'size':28, 'style':'italic'})\n",
"plt.text(0.515, 0.095, \"Optimal Design\", fontdict={'size':16,'color':'b'})\n",
"plt.legend(loc=0, fontsize='large')\n",
"plt.title('Figure 3')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "107551ef",
"metadata": {},
"source": [
"### Method of Leysieffer and Warner (1976)\n",
"\n",
"Leysieffer and Warner (1976) recommend a two-dimensional measure of jeopardy that reduces to a single dimension when there is no jeopardy in a ‘no’ answer”, which means that\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A)=1\n",
"$$\n",
"\n",
"and\n",
"\n",
"$$\n",
"\\text{Pr}(A|\\text{no})=0\n",
"$$\n",
"\n",
"This is not an optimal choice under a utilitarian approach."
]
},
{
"cell_type": "markdown",
"id": "6cc47772",
"metadata": {},
"source": [
"### Analysis on the Method of Chaudhuri and Mukerjee’s (1988)\n",
"\n",
"[[Chadhuri and Mukerjee, 1988](https://python.quantecon.org/zreferences.html#id9)]\n",
"\n",
"Chaudhuri and Mukerjee (1988) argued that the individual may find that since “yes” may sometimes relate to the sensitive group A, a clever respondent may falsely but safely always be inclined to respond “no”. In this situation, the truth border is such that individuals choose to lie whenever the truthful answer is “yes” and\n",
"\n",
"$$\n",
"\\text{Pr}(A|\\text{no})=0\n",
"$$\n",
"\n",
"Here the gain from lying is too high for someone to volunteer a “yes” answer.\n",
"\n",
"This means that\n",
"\n",
"$$\n",
"U_i\\left(\\text{Pr}(A|\\text{yes}),\\text{truth}\\right)< U_i\\left(\\text{Pr}(A|\\text{no}),\\text{lie}\\right)\n",
"$$\n",
"\n",
"in any situation always.\n",
"\n",
"As a result, there is no attainable model design.\n",
"\n",
"However, under a utilitarian approach there should exist other survey designs that are consistent with truthful answers.\n",
"\n",
"In particular, respondents will choose to answer truthfully if the relative advantage from lying is eliminated.\n",
"\n",
"We can use Python to show that the optimal model design corresponds to point Q in Figure 4:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "49603456",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"def f(x):\n",
" if x < 0.16:\n",
" return 0\n",
" else:\n",
" return (pow(x, 0.5) - 0.4)**2"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7a7b63b8",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"pi = 0.3\n",
"n = 100\n",
"nv = [0.27, 0.34, 0.49, 0.74, 0.92, 1.1, 1.47, 2.94, 14.7]\n",
"x = np.arange(0, 1, 0.001)\n",
"y = [f(i) for i in x]\n",
"z = x\n",
"x0 = np.arange(pi, 1, 0.001)\n",
"x2 = np.arange(0, pi, 0.001)\n",
"y1 = [pi for i in x0]\n",
"y2 = [pi for i in x2]\n",
"x3 = np.arange(0.16, 1, 0.001)\n",
"y3 = (pow(x3, 0.5) - 0.4)**2\n",
"\n",
"plt.figure(figsize=(12, 10))\n",
"plt.plot(x, x, 'c:', linewidth=2)\n",
"plt.plot(x0, y1,'c:', linewidth=2)\n",
"plt.plot(y2, x2,'c:', linewidth=2)\n",
"plt.plot(x3, y3,'b-', label='Truth Border')\n",
"plt.fill_between(x, y, z, facecolor='blue', alpha=0.05, label='Truth telling')\n",
"plt.fill_between(x3, 0, y3,facecolor='green', alpha=0.05, label='Lying')\n",
"for i in range(len(nv)):\n",
" y = pi - (pi**2 * (1 - pi)**2) / (n * (nv[i] / n) * (x0 - pi + 1e-8))\n",
" plt.plot(x0, y, 'k--', alpha=1 - 0.07 * i, label=f'V{i+1}')\n",
"plt.scatter(0.61, 0.146, c='r', marker='*', label='Z', s=150)\n",
"plt.xlim([0, 1])\n",
"plt.ylim([0, 0.5])\n",
"plt.xlabel('Pr(A|yes)')\n",
"plt.ylabel('Pr(A|no)')\n",
"plt.text(0.45, 0.35, \"Truth Telling\", fontdict={'size':28, 'style':'italic'})\n",
"plt.text(0.8, 0.1, \"Lying\", fontdict={'size':28, 'style':'italic'})\n",
"plt.text(0.63, 0.141, \"Optimal Design\", fontdict={'size':16,'color':'r'})\n",
"plt.legend(loc=0, fontsize='large')\n",
"plt.title('Figure 4')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "1c437c69",
"metadata": {},
"source": [
"### Method of Greenberg et al. (1977)\n",
"\n",
"[[Greenberg *et al.*, 1977](https://python.quantecon.org/zreferences.html#id16)]\n",
"\n",
"Greenberg et al. (1977) defined the hazard for an individual in $ A $ as the probability that he or she is perceived as belonging to $ A $:\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A)\\times \\text{Pr}(A|\\text{yes})+\\text{Pr}(\\text{no}|A)\\times \\text{Pr}(A|\\text{no}) \\tag{16.21}\n",
"$$\n",
"\n",
"The hazard for an individual who does not belong to $ A $ is\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A^{'})\\times \\text{Pr}(A|\\text{yes})+\\text{Pr}(\\text{no}|A^{'}) \\times \\text{Pr}(A|\\text{no}) \\tag{16.22}\n",
"$$\n",
"\n",
"They also considered an alternative related measure of hazard that they said “is likely to be closer to the actual concern felt by a respondent.”\n",
"\n",
"Their “limited hazard” for an individual in $ A $ and $ A^{'} $ is\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A)\\times \\text{Pr}(A|\\text{yes}) \\tag{16.23}\n",
"$$\n",
"\n",
"and\n",
"\n",
"\n",
"\n",
"$$\n",
"\\text{Pr}(\\text{yes}|A^{'})\\times \\text{Pr}(A|\\text{yes}) \\tag{16.24}\n",
"$$\n",
"\n",
"According to Greenberg et al. (1977), a respondent commits himself or herself to answer truthfully on the basis of a probability in [(16.21)](#equation-eq-util-rand-seven-aa) or [(16.23)](#equation-eq-util-rand-eight-aa) **before** randomly selecting the question to be answered.\n",
"\n",
"Suppose that the appropriate privacy measure is captured by the notion of “limited hazard” in [(16.23)](#equation-eq-util-rand-eight-aa) and [(16.24)](#equation-eq-util-rand-eight-bb).\n",
"\n",
"Consider an unrelated question model where the unrelated question is replaced by the instruction “Say the word ‘no’”, which implies that\n",
"\n",
"$$\n",
"\\text{Pr}(A|\\text{yes})=1\n",
"$$\n",
"\n",
"and it follows that:\n",
"\n",
"- Hazard for an individual in $ A^{'} $ is 0. \n",
"- Hazard for an individual in $ A $ can also be made arbitrarily small by choosing a sufficiently small $ \\text{Pr}(\\text{yes}|A) $. \n",
"\n",
"\n",
"Even though this hazard can be set arbitrarily close to 0, an individual in $ A $ will completely reveal his or her identity whenever truthfully answering the sensitive question.\n",
"\n",
"However, under utilitarian framework, it is obviously contradictory.\n",
"\n",
"If the individuals are willing to volunteer this information, it seems that the randomized response design was not necessary in the first place.\n",
"\n",
"It ignores the fact that respondents retain the option of lying until they have seen the question to be answered."
]
},
{
"cell_type": "markdown",
"id": "3cd579a8",
"metadata": {},
"source": [
"## Concluding Remarks\n",
"\n",
"The justifications for a randomized response procedure are that\n",
"\n",
"- Respondents are thought to feel discomfort from being perceived as belonging to the sensitive group. \n",
"- Respondents prefer to answer questions truthfully than to lie, unless it is too revealing. \n",
"\n",
"\n",
"If a privacy measure is not completely consistent with the rational behavior of the respondents, all efforts to derive an optimal model design are futile.\n",
"\n",
"A utilitarian approach provides a systematic way to model respondents’ behavior under the assumption that they maximize their expected utilities.\n",
"\n",
"In a utilitarian analysis:\n",
"\n",
"- A truth border divides the space of conditional probabilities of being perceived as belonging to the sensitive group, $ \\text{Pr}(A|\\text{yes}) $ and $ \\text{Pr}(A|\\text{no}) $, into the truth-telling region and the lying region. \n",
"- The optimal model design is obtained at the point where the truth border touches the lowest possible iso-variance curve. \n",
"\n",
"\n",
"A practical implication of the analysis of [[Ljungqvist, 1993](https://python.quantecon.org/zreferences.html#id11)] is that uncertainty about respondents’ demands for privacy can be acknowledged by **choosing $ \\text{Pr}(A|\\text{yes}) $ and $ \\text{Pr}(A|\\text{no}) $ sufficiently close to each other**."
]
}
],
"metadata": {
"date": 1724022911.3431752,
"filename": "util_rand_resp.md",
"kernelspec": {
"display_name": "Python",
"language": "python3",
"name": "python3"
},
"title": "Expected Utilities of Random Responses"
},
"nbformat": 4,
"nbformat_minor": 5
}