Showing posts with label Urns. Show all posts
Showing posts with label Urns. Show all posts

Monday, July 13, 2020

Expected Runs in Sampling Without Replacement

This is the solution to the problem posed a couple weeks earlier.

The trick is to realize we can write \[ f(x|N,M) = \sum^{M}_{k=1}\frac{(M)_{k}}{(N)_{k}}x^{k} \tag{1}\] where \((M)_{k} = M(M-1)(\dots)(M-(k-1))\) is the falling factorial. This permits us to rewrite the expected length of a run as \[ \mathbb{E}[L|N,M] = \left.\frac{\mathrm{d}}{\mathrm{d}x}f(x|N,M)\right|_{x=1}. \tag{2} \] But astute readers will recognize Eq (1) is Gauss's hypergeometric function \[ f(x|N,M) = \frac{M}{N}x {}_{2}F_{1}(1, 1-M;1-N;x) \tag{3} \] which permits us to deduce \[ \mathbb{E}[L|N,M] = \frac{M(1+N)}{(1+N-M))(1+N-(M-1))} \] which is the expected run for M red balls in an urn with N balls. This assumes \(M\gt2\), otherwise we can manually compute the expected run trivially.

HOWEVER, we need to normalize the probabilities, since we are considering a slightly different experiment: we are varying the sample size \(n\) from 1 to M (as opposed to varying the portion k of the fixed sample size n balls drawn are of the specified color). That is to say, we need to divide through by \(f(1|N,M)=M/(N+1-M)\) to give us \[ \mathbb{E}[L|N,M] = \frac{(1+N)}{(1+N-(M-1))} \tag{4} \] which, if we fix \(p=M/N\) as both \(M\to\infty\) and \(N\to\infty\), recovers the geometric distribution. [The expected value is approximately \(N/(N-M) = (N - M + M)/(N - M)\) which is \(1 + (M/(N-M)) = 1 + (p/(1-p)) = 1/(1-p)\). Then use the geometric distribution with \(1-p\) for the probability of "success", so we count the number of "failures" with the geometric distribution to coincide with the length of a run in our situation.] (This is an example of a sanity check.)

I suspect there's a way to solve this puzzle elegantly without invoking hypergeometric functions, but this accidentally fell into my lap (literally).

Homework 1. What if we fix \(n\) draws from an urn, sampled without replacement. Suppose this urn contains K red balls, the remainder are white, for a total of N balls. What's the expected first run's length? I.e., if you draw a white, what's the number white balls you expect to draw until you draw a red? And if you first draw a red ball, then what's the number of red balls you expect to draw until drawing a white?

Homework 2. If we consider sampling without replacement from an urn (possibly with balls of multiple colors), then what does the distribution look like on finite sequences of runs of different colors? I.e., specifying a sample as drawing \(n_{1}\) of a color \(c_{1}\), then \(n_{2}\) of \(c_{2}\), then..., such that \(n_{1}+\dots + n_{k}=n\). What does the sample space look like? What's the probability distribution look like?

Friday, July 3, 2020

Runs in a sample

A puzzle to celebrate the 4th of July. This is a bit more open-ended (hence it's a "puzzle", not an "exercise"). Consider an urn, with N balls and an unknown number K of red balls (the remainder are white). We will be sampling without replacement.

First, define a run as drawing one ball after another of the same color.

Puzzle. How can we use the sample of n balls written as a sequence of runs \((k_{1},c_{1})\), ..., \((k_{m},c_{m})\) for a run of length \(k_{i}\) of color \(c_{i}\)? Are there cases where using this data would give less informative inferences than the vanilla inference? (And what's the inferred variance?)

Some exercises might make this all easier.

Exercise 1. Let B be the background information that an urn contains N balls, K of which are red. Is the probability the first k balls drawn are red: \[\Pr(R_{k}\dots R_{1}|B) = \frac{(K-(k-1))(\dots)(K-1)K}{(N-(k-1))(\dots)(N-1)N}\] or should we suppose the run ends when we draw a white ball? I.e., we should examine \(W_{k+1}R_{k}\dots R_{1}\) as a run of k red balls terminated by drawing a white ball? Does the sum of probabilities sum to 1? If not, why not? (And what does it sum to?)

Out of laziness, I sometimes write \(\Pr(n|K,N)\) for a run of n red balls when the urn contains K red balls and N balls in the urn in total.

Exercise 1B. What is \(\Pr(n|K,N+1)\) in terms of   \(\Pr(n-1|K,N)\)? Similarly, what is \(\Pr(n|K+1,N)\) in terms of   \(\Pr(n-1|K,N)\)? Can we relate \(\Pr(n|K+1,N+1)\) and \(\Pr(n|K,N)\)?

Exercise 2. In an urn with N balls (K of which are red), what's the expected length of a run of red balls?

This is rather tricky. Using the solution from exercise 1, the expected value for the length of a run of red balls would be \[\mathbb{E}[L] = \sum_{k=1}^{K}k\Pr(k|K,N)\] where \(L\) is the random variable denoting the length of a run of red balls drawn from the urn (sampled without replacement).

Exercise 3. Consider the "large urn limit", where \(p=K/N\) is fixed as \(N\to\infty\) and \(K\to\infty\). (a) Prove sampling without replacement [the hypergeometric distribution] becomes sampling with replacement [the binomial distribution]. (b) How does the expected length of a run of red balls change?

Could we use exercise 3 as a sanity check on the solution to exercise 2 under appropriate limits?

Exercise 4 (open-ended). Think of at least three ways to test your solutions to exercises 1, 2 and 3(b). [Punishment: if you thought about the \(K=1\) case, think of four more ways to test your solutions.]

Arguably, using the solution of exercise 3 is one check of the solution of exercise 2. Finding two more gives us more confidence in our solution being correct; it is good practice when solving problems and we don't know the solution.

Addendum: The solution will be posted Monday July 13, 2020, at 9:00am PDT.

Further Reading

  1. D.M. Bloom, "Probabilities of Clumps in a Binary Sequence (and How to Evaluate Them Without Knowing a Lot)." Mathematics Magazine 69, no.5 (1996) pp. 366–372. (Bloom considers the combinatorics for no-run samples, which is the complement of the situation we're interested in.)
  2. I.P. Goulden, and D.M. Jackson, Combinatorial Enumeration. New York: Wiley, 1983.
  3. Check your results for a deck of cards (OEIS A086438)

Monday, June 29, 2020

Polling as Sampling from Urns

Last time we discussed a simple model of polling where each demographic were a different color ball in an urn, with supporters of a candidate (and those not supporting that candidate) as solids and stripes. We saw with data from the Hispanic demographics that overdispersion was present and diluted support for Biden.

But we assumed the polls which formed the basis of our reasoning were a perfect representative sample. I think we will begin to tease this apart in this post. I don't think I'll discuss sampling methods yet.

Instead, in this post, I'll start with several urns with different quantities of striped and solid balls. Even using ideal sampling methods, the techniques produce a wide range of estimates of the proportion of striped balls to the rest of the urn.

Toy Problem

Consider 4 urns, A, C, F, and T. We have balls with three colors (red, green, blue) which are either striped or solid. We want to know how many solid balls are in each urn from a given sample. But we perform this backwards: we begin with knowing the number of striped and solid balls in each urn, and consider different sampling methods.

Urn ANumber SolidNumber StripedTotal% of Balls
Green962,036357,2941,319,33096.12%
Blue34,1477,53241,6793.04%
Red3,3488,24211,5900.84%
Total999,531 (72.8%)373,0681,372,599
Urn CNumber SolidNumber StripedTotal% of Balls
Green6,628,5921,910,7048,539,29697.48%
Blue130,71120,448151,1591.72%
Red19,51949,72669,2450.79%
Total6,778,822 (77.4%)1,980,8788,759,700
Urn FNumber SolidNumber StripedTotal% of Balls
Green364,392126,652491,04421.01%
Blue598,611193,014791,62533.88%
Red276,758777,1661,053,92445.11%
Total1,239,761 (53.0%)1,096,8322,336,593
Urn TNumber SolidNumber StripedTotal% of Balls
Green4,723,2361,716,6326,439,86896.91%
Blue110,39532,782143,1772.15%
Red18,83043,64562,4750.94%
Total4,852,461 (73.0%)1,793,0596,645,520

Data derived from the ACS 1-year estimate, B03001 for Arizona, California, Florida, and Texas. The counts of colored and striped balls randomly generated based off of crude Bayesian estimates from several recent FOX news and New York Times polls.

There are a total of 13,870,575 solid balls (72.566%) and 5,243,837 (27.434%) striped balls.

Exercise 1. If we had a hypothetical urn with 5,243,837 striped balls and 13,870,575 solid balls, and if we sampled without replacement n balls, what's the expected number of striped balls drawn? What's the interval containing 75% of the probability distribution about the mean for different sample sizes \(n=75,100,125\)?

This requires being more precise about what we're really interested in finding. The expected number of striped balls in a sample of n balls would be \(0.27434n\). This is unambiguous. (The median value would be, for \(n=100\), 27 striped balls.)

Constructing the interval can be done thus: the upper bound of k for \(\Pr(X\leq k|M,N,n=100)\approx 7/8\) empirically is about \(k\approx32\), and for the lower bound \(\Pr(X\leq k|M,N,n=100)\approx 1/8\) is about \(k\approx 22\). This would give us an interval of 27 ± 5.

We could also consider constructing an interval similar to the "highest posterior density interval". Intuitively, we plot the probability density function, then take a horizontal line tangent to the mode (peak of the PDF). We begin lowering the horizontal line until the area under the probability density between the intersection points equals 75%. This produces a slightly different value since the distribution is not symmetric, though for the sample sizes we are considering the differences would not be appreciable.

Exercise 2. If we drew 4 samples (each sampled without replacement) with each sample consisting of n balls, what's the expected number of striped balls drawn? What's the interval containing 75% of the probability distribution about the mean for \(n=75,100,125\)?

Constructing the intervals of expected striped balls drawn for \(n=100\) samples: urns A and T have interval 27 ± 5 striped balls, urn C has interval \(18\leq k\leq27\), and urn F has an interval \(41\leq k\leq53\).

Observe that urn C has an interval with fewer striped balls than the hypothetical pooled urn, whereas urn F has its interval centered at nearly double the hypothetical pooled urn's, and urns A and T coincide with the hypothetical pooled urn.

Exercise 3. If we sampled proportional to the number of balls in each urn (e.g., \(2336593/(5243837 + 13870575) \approx 12.22\%\) of the sample are drawn from urn F) and we sampled without replacement, what's the expected number of striped balls drawn? What's the interval containing 75% of the probability distribution about the mean for \(n=75,100,125\)? What's the expected number of balls of each color drawn?

This is several independent sampling problems, with \(n_{A} = nN_{A}/N\approx0.07n\), \(n_{C} = nN_{C}/N\approx 0.45n\), \(n_{F} = nN_{F}/N\approx 0.12n\), and \(n_{T} = nN_{T}/N\approx 0.35n\). The expected number of striped balls in the sample would be the sum of the expected number from a sample from respective urns with respective sizes. But some simple algebra shows this is just the expected value of the hypothetical pooled urn from exercise 1.

Since the wording suggests we move from urn to urn, taking a specific sample from each one independently, the intervals are computed independently, and the sum of the lower-bounds gives us the lower-bound for the resulting sample (and similarly for the upper-bound).

Exercise 4. What if each urn gets sampled equally? So a quarter of the sample is drawn from urn A, a quarter from urn C, etc. What is the expected value of striped balls appearing in the sample? What is the 75% interval for \(n=100\)?

This gives us an expected 30.92905 striped balls in the sample. The interval with 75% probability consists of \(20\leq k\leq41\) striped balls; the 50% intervals gives us 30 ± 6 striped balls.

Exercise 5. What if each urn gets sampled in this manner: we first fix a desired sample size \(n\geq100\). We want to randomly sample without replacement so we get at least \((R/N)n\) red balls (where there are \(R\) red balls and \(N\) total balls in the urn initially), at least \((G/N)n\) green balls (where \(G\) is the initial number of green balls in the urn) and at least \((B/N)n\) blue balls (with \(B\) the initial number of blue balls in the urn). We will have our sample consist of \(g\) green balls, \(r\) red balls, and \(b\) blue balls where \(r+g+b\geq n\). (A) What is the expected sample size for each urn for \(n=150\)? (B) What is the expected number of striped balls for each color? (C) [Open ended] Can we apply some set of weightings to better reflect the urn's composition?

We first compute how many balls we want, at minimum, drawn for each urn:

  • Urn A's sample needs at least 144 green balls, 5 blue balls, and 1 red ball
  • Urn C's sample needs at least 146 green balls, 3 blue balls, and 1 red ball
  • Urn F's sample needs at least 32 green balls, 51 blue balls, and 68 red ball
  • Urn T's sample needs at least 145 green balls, 3 blue balls, and 1 red ball
The exact numbers may differ due to rounding concerns, or desire for sampling particular subpopulations.

If we consider the stopping condition to be drawing s balls of a certain color (which the urn has K balls of that particular color), then we can compute the expected number of draws \(k+s\) needed using the negative hypergeometric distribution. The expected number of draws would be \[ n \approx s + s\frac{N-K}{K+1} = s\frac{N+1}{N-K+1}. \] This formula differs from a naive reading of the wikipedia page, because their "K" is our "N-K".

However, if we want our sample to contain the desired minimum with \(\alpha\) probability, we need at least \(\Pr(X\geq s\mid N, K, n)\geq \alpha\). Just brute forcing this, we find A needs \(n=354\), C needs \(n=378\), urn F requires \(n=194\), and finally T needs \(n=318\).

For, e.g., urn A, this has the unfortunate side effect of producing somewhere between double to triple as many green and blue balls as needed. So how do we handle this? We want to avoid discarding information (as a rule of thumb in life, but especially in statistics), so we may want to take the ratio of striped green balls to solid green balls, then multiply by the desired sample size for green balls (144). There are other possibilities, but this is the quickest for us.

Numerically, we find the samples produced for each urn has with the 90% confidence interval estimating solid balls of specific color in parentheses:

  • Urn A's sample has 340 green balls (234–261), 11 blue balls (7–11), and 3 red ball (0–2)
  • Urn C's sample needs at least 369 green balls (273–299), 7 blue balls (4–7), and 3 red ball (0–2)
  • Urn F's sample needs at least 41 green balls (26–35), 66 blue balls (44–55), and 87 red ball (16–30)
  • Urn T's sample needs at least 309 green balls (214–239), 7 blue balls (3–7), and 3 red ball (0–2)

If we were to normalize the overcounted balls, then we end up with the estimates:

  • Urn A's weighted sample has between 99 to 111 striped green balls, 2 or 3 striped blue balls, and at most 1 striped red ball, for a weighted total of somewhere between 102 to 115 striped balls (68%-76.67% striped)
  • Urn C's weighted sample has between 108 to 118 striped green balls, 2 (well, between 1.75 to 2) striped blue balls, and at most 1 striped red ball, for weighted total of somewhere between 111 to 121 striped balls (74%-80%)
  • Urn F's weighted sample has between 20 to 27 striped green balls, 34 to 42.5 striped blue balls, and 12.5 to 23 striped red ball, for a weighted total somewhere between 66 to 93 striped balls (44%-62%)
  • Urn T's weighted sample reports somewhere between 100 to 112 striped green balls, 1 to 3 striped blue balls, and at most 1 striped red ball, for a weighted total of 101 to 116 striped balls (67%-77%)

But if we were given this data, working backwards, we would end up with radically different estimates for the population size. Urn F has a "margin of error" of about ±9%, which would be huge. The reported margin of error (at 90% confidence) would be at most 6.75%, though. The reported margin of error underestimates the actual range of variability the polls could report.

On the other hand, for urn T, we see the reported margin-of-error would be 6.315% (at 90% confidence) whereas its estimates have a ± 5% margin. In this case, the margin of error reported over-estimates the interval width.

Observation 1. The number of striped balls drawn using these different sampling methods produce different estimates for the total number of striped balls in each of the urns.

Observation 2. For urns with high proportion of striped balls, the margin of error decreases. For urns with low estimates of striped balls with decent sample sizes should be believed.

Homework 1. Given the range of estimates for each of these sampling methods, produce plots estimating the number of striped balls in each urn.

A concluding remark: the reader may object at the sample size of 150 being too small. This is a valid criticism, but when you examine the polling crosstabs, it's not uncommon to find 150 Hispanics polled. The guiding question I have writing this series of posts is whether we can extract anything meaningful from the polling results.

Saturday, June 27, 2020

This one strange trick helps Hispanic support of Biden

Harry Enten noted a few weeks ago how Biden is doing worse than Clinton among Hispanic voters. I wanted to use this as a pretense to investigate some of the probability theoretic aspects of polling.

We'll specifically be building a series of toy models, progressively exploring aspects of polling a composite heterogeneous demographic like Hispanic Americans. These are idealizations which can be developed further into more accurate models, but even the approximations inform us about aspects seldom considered.

The basic game plan (the tl;dr version): we consider sampling without replacement as a hypergeometric distribution, then estimate the population of "successes" out of all trials using the maximum likelihood point-estimate and Bayesian conjugate prior. In section 2, we move on to consider multiple hypergeometric distributions pooled together (analogous to striped and solid balls of different colors) and apply the same methods to this more general setting.

Assumption 1. The polls are ideal, representative samples of the populations.

We will have a follow up post discussing sampling methods, and how it affects poll results.

Base Case

The floor model of polling amounts to treating respondents as balls in an urn. There are three types of balls (red, white, and blue, for America—err, I mean, for Republican, undecided, and Democrat leaning voters) and we assume the balls do not change color. For our interests, Biden's polling, there are B blue balls and N all balls (blue and non-blue alike).

We sample without replacement n balls, meaning: we take a ball out of the urn, inspect its color, make note of it, then set the ball aside (we do not return it to the urn or replace it), and repeat this process n times. The total number of blue balls drawn from the urn b will be reported.

Exercise 1. What is the probability of drawing \(b\) blue balls given \(N, B, n\)?

There are a number of ways to derive the solution. In frequentist terms, there are \[\binom{N}{n} = \frac{(N)!}{n!(N-n)!}\tag{1a}\] ways to draw n balls from the urn containing N balls without putting the sampled balls back. (We read the left-hand side of Eq (1a) as "N choose n".) This is the denominator of the probability.

The numerator is the product of the number of ways to draw b balls from a possible B cases, and similarly the number of ways to draw \(n-b\) non-blue balls from the population of \(N-B\) non-blue balls. This gives us the answer \[\Pr(b\mid N, B, n) = \frac{\binom{B}{b}\binom{N-B}{n-b}}{\binom{N}{n}}.\tag{1b}\] Readers familiar with probability recognize this as the probability mass function for the Hypergeometric distribution.

Exercise 2. What is the expected value and variance for the hypergeometric distribution?

This is a problem the reader should work out on their own. One trick is to introduce \(p=B/N\) as the proportion of the population which is blue. For \(N\to\infty\) with \(p\) fixed, the variance of a hypergeometrically distributed random variable \(X \sim \operatorname{Hypergeometric}(N, B, n)\) should approach the binomial variance \(\operatorname{Var}[X]\to np(1-p)\).

Exercise 3. How can we estimate \(B\) given \(N\), \(n\), and an observed \(b\)?

One way to solve this is to consider the value of \(B\) which maximizes the probability \(Pr(b\mid N, B, n)\). This would give us approximately \(B\approx (N/n)b\).

Bayesian Estimates

A more Bayesian approach would use the conjugate prior for the Hypergeometric distribution, i.e., the Beta-Binomial distribution to describe a random variable \(B\sim\operatorname{BetaBin}(N, \alpha, \beta)\) for some initial prior of the relative frequency of blue balls \(\alpha\) and non-blue balls \(\beta\) (an uninformed guess would be \(\alpha=\beta=1\)).

After observing a sample of \(n\) draws produce \(b\) blue balls, the estimate is updated to \(B-b\sim\operatorname{BetaBin}(N-n, \alpha+b, \beta+n-b)\). As more samples are done, we tally up the number of blue balls seen in all of them, and treat it as if it were a single sample. (That's the property of being a conjugate prior.)

Exercise 4. Given \(N = 40\times 10^{6}\), \(n = 273\), and \(b = 161\), estimate \(B\).

These numbers are not pulled out of thin air (though it might seem that way). Roughly 2/3 of any demographic groups is voting age, and there are approximately 60m Hispanic Americans,1According to the ACS 1-year estimate, B03001. which means about 40m are voting age. In a recent poll, the New York Times found 87+74 = 161 Hispanics supporting Biden out of 273 Hispanics polled.

In a separate-though-related poll, the New York Times reported among Hispanics 64% support Biden.

Using the first set of polls from battleground states, we can produce the following estimate for the number of Biden supporting Hispanic Americans (with the quantiles at 5%, 95%, and the expected value indicated with vertical lines):

Estimates using the New York Times Battleground polls and N = 40m. The quantiles are at 21,619,245 and 25,530,281 for the 5% and 95% respectively, with the expected value at 23,589,744.

Note this corresponds to 58.97% ± 4.9% support. The wide margins stem from a lack of data. We can make an informative statement from this little data and crude model: Harry Enten noted Clinton led by 61% to 23% among Hispanics pre-election, but that lies within the credible interval we just constructed. In other words, Biden is doing alright among the Hispanics, unless the few polls we have used were skewed or biased.

Exercise 5. Perform the same analysis with Trump's numbers among Hispanics. Trump has \(t=75\) respondents supporting him and \(n-t=198\) not supporting him. [Spoiler: 27.47% ± 4.4%]

Heterogeneity

This model fails for the simple reason that people are not balls in an urn. No demographic is a homogeneous blob, so how can we start to introduce heterogeneity?

Some data to help us is a poll Telemundo conducted back in March 2020 specifically concerning the Latino vote in Florida and Arizona. We can now examine how Cuban-Americans poll compared to other Hispanic Americans.

Let's isolate the interesting aspects from a probabilistic perspective. We will consider k different colored balls, identical physically except for their color, which have counts \(N_{1}, \dots, N_{k}\) (there are \(N_{j}\) balls of color \(j\)). Suppose further that for each color \(j\) there are \(K_{j}\in\{0,1,\dots,N_{j}\}\) balls which are "striped" and \(N_{j}-K_{j}\) balls which are "solid" (think: billiards). The striped balls are analogous to our candidate's supporters, the solid balls do not support our candidate.

We sometimes have information about the number of striped balls drawn from a sample, though more often polls report the number of striped balls drawn without reference to color.

The meta-question guiding us here (i.e., the real interesting thing which we're trying to use to guide constructing exercises and worked examples) is when we have a multivariate hypergeometric distribution ("many colored balls") which can be collapsed into a hypergeometric distribution ("solids and stripes"), under what circumstances does the multivariate distribution distort the univariate distribution.

For concrete numbers, consider the following table:

ColorNumber StripedNumber SolidTotal Number Balls (N)
\(C_{1}\) 641751,575,667
\(C_{2}\)112 263,860,969
\(C_{3}\)37412524,657,774
\(C_{4}\)161112???
Total71143839,842,421

If we tried using an exact Binomial test of the samples drawn against \(p\approx 711/1149\), only \(C_{4}\) fails to be significantly different with \(\alpha = 0.05\) (the p-values for the first three colors are on the order of \(10^{-10}\) or so, for those curious). The keen reader will realize this is because it's the numbers from exercise 4, i.e., from a pooled sample.

The index of dispersion for this data is approximately the ratio of the sample variance of the striped counts to the sample mean, i.e., approximately 105.1228 ≫ 1, which indicates it is quite overdispersed. None of this should be surprising, since it comes from samples from a quite heterogeneous population.

Exercise 6. How can we estimate the number of striped balls \(K_{j}\) for each color \(j\)?

Isn't this a repeat of exercise 3, but with slightly different data? Arguably, yes. (That's why it's exercise 3, because it's now a tool in our toolkit!) The maximum likelihood estimator suggests that 61.88% of all balls are striped. Let's see if the Bayesian approach will be as informative with the samples drawn.

If we tried to estimate the proportion of the colors which are striped with 90% credible intervals, Bayesian methods tell us for \(C_{1}\) we'd expect 26.77% ± 4.5%, for \(C_{2}\) we'd expect 81.16% ± 5.4% striped, and for \(C_{3}\) we'd expect between 69.% and 78.1% (centered around 74.95%) striped. We can plot the densities for the proportions \(C_{1}\) in red, \(C_{2}\) in blue, \(C_{3}\) in green:

Estimates using the figures given above, divided through by the total number of balls to estimate the proportion of balls striped.

The maximum likelihood estimates tell us \(C_{1}\) has about 26.78% striped, \(C_{2}\) has about 81.1% striped, and \(C_{3}\) has 74.95% striped. These differ from Bayesian estimates around the 8th digit after the decimal place.

Exercise 7. How do these Bayesian credibility intervals compare to the confidence intervals around the most likely number of striped balls?

Exercise 8. Using the values of \(b=711\), \(n-b=438\), and \(N=39842421\), compute the credibility interval for the conjugate prior \(B\sim\operatorname{BetaBin}(N,b,n-b)\). How does it compare to our results from the first part of this blog entry? How does it compare to the estimates for individual subpopulations? [Answer: the credibility interval for \(B/N\) with 90% of the probability is about 61.88% ± 2.35%]

An observation that we can make: balls colored \(C_{1}\) seem to be significantly different than the other balls, and it skews the overall estimation if we bundled them in with the others.

Concluding Remarks

So far, we have assumed a perfect sampling method, and have attempted to extract information from the samples given. We've used one basic trick. Working through the exercises grills it into the reader's mind.

Next time, we will discuss sampling methods (including nonresponse error) and how it impacts the sample reported. Although it impacts polling results, viewed differently, this serves as a model for voter turnout, as well.

If there were more time...

This post has gone on long enough. Had I more time, I would have discussed posterior predictive checking the Bayesian models we've set up. (Because that's as important as washing your hands after using the bathroom.)

I would have also liked to examine Clinton's polling numbers among Hispanics using these methods. This would give us some benchmarks to work against.

Further, as noted, not everyone polled will vote. It would be another fertile grounds for discussion to investigate "likely voter models".

There are a number of straightforward questions we can ask about using the hypergeometric distribution for polling results, and how it modifies the calculations we made related to the polling results. An example:

Homework. Given a hypergeometrically distributed random variable \(X\sim\operatorname{Hypergeometric}(N, B, n)\) with \(p=B/N\) show the variance \(\operatorname{Var}[X] = np(1-p)(\text{something})\). The puzzle is to see how this extra factor (the parenthetic "something") impacts the naive margin-of-error calculation for polls.