Alignment Data Quality and Rater Populations › A Target-Weighted Estimand with Subgroup Uncertainty
Language AI HandbookAll chapters In this experiment the group counts are fixed by design. In each bootstrap replicate, sample observations with replacement from the observed votes for group . Compute all the estimands from the resulting group fractions. Using the same draw within a replicate for each aggregation rule preserves the relationships among the estimates. If you want an interval for a difference between two rules, take their difference within each replicate and compute percentiles of those differences.
One can also see the dependence on recruitment mix directly. In this example, use for the G1 share and for G2. The population probability for Y at this share is
The quantity starts at when the target is entirely G2. It rises to when the target is entirely G1. The majority threshold for Y is therefore reached at . A mixture above that threshold favors Y in the generating model. This threshold describes two fixed subgroup probabilities and a binary comparison. In observed data, the subgroup estimates in the formula also carry sampling uncertainty.
The design question is whether a wave's observed G1 share is the weight you want. We fixed that share at 0.90 in Wave 1 and 0.10 in Wave 2 to illustrate recruitment changes. For an analysis with fixed target weights , same-wave sampling variability comes from estimating the subgroup means. To see what changes if those weights were estimated, consider an external user survey that estimates the G1 share. Replacing by a survey estimate introduces another uncertain input. Our within-wave bootstrap holds fixed, so it cannot reflect that survey's variability. Report the design that generated the weights and use an uncertainty method that includes it if it matters to the decision.
For the fixed-weight case, let denote the variance of the group estimate. When the group estimates are independent, the variance of their weighted sum is . Squaring the weights follows from for a constant . This shows why a group receiving half the target weight can drive much of the uncertainty when its estimated fraction rests on a small sample. If the groups share an item sample and the analysis treats items as random, the estimates can co-vary. The sum of squared-weight terms alone then misses covariance terms.
Use the direct observed estimate for the point reported in the table. Averaging the simulated bootstrap points can introduce a small Monte Carlo difference even when the same statistical estimator is being illustrated. The simulated distribution is useful for the interval. The empirical 2.5th and 97.5th percentiles give a nominal 95% interval from the replicate estimates. Actual coverage is the fraction of repeated samples from the stated design whose intervals include the target. The percentile procedure can fall short of 95%, especially for small or near-boundary groups. It does not assign 95% probability to a fixed unknown group rate in this one experiment.
The percentile interval here is a demonstration for fixed group counts and binary outcomes. It does not calibrate the reliability of an individual rater. If all observed votes in a group equal zero or all equal one, every ordinary replacement resample from that group gives the same estimate. Its percentile interval collapses at that endpoint even when the population rate lies between zero and one. Report the subgroup sample sizes alongside an interval, and check whether an alternative interval or a more informative collection design would change the decision.
Choose the population or policy mix before interpreting the weighted estimate. The example sets each group share to 0.5 for a transparent comparison. An analysis of a specified population can estimate that population's shares from a survey. Include that uncertainty when it matters to the decision.
The bootstrap computes 2,000 draws. Each person contributes one vote here, so resampling vote rows within a group also resamples people. If you independently sample people who cast multiple votes and hold the item list fixed, resample whole people with their judgments attached. To generalize over new sampled items or recruitment clusters, include those sources of variation in your uncertainty method.
PythonIn [10]Expand
# Target population weights. These are a *decision* about the deployment
# population, not an estimate. Here we choose 50/50 to illustrate mechanics.
target_weights = {"G1": 0.5, "G2": 0.5}
def bootstrap_estimates(df, target_weights, B=2000, seed=7):
"""Resample the observed strata, then calculate both weighted totals."""
validate_vote_rows(df)
rng = np.random.default_rng(seed)
group_arrays = {
group: frame["vote_prefer_Y"].to_numpy()
for group, frame in df.groupby("group", observed=True)
}
requested_weights = {
group: float(weight) for group, weight in target_weights.items()
}
if any(
not np.isfinite(weight) or weight < 0
for weight in requested_weights.values()
) or not np.isclose(sum(requested_weights.values()), 1, rtol=0, atol=1e-12):
raise ValueError(
"Target weights must be finite, nonnegative, and sum to one."
)
if any(
weight > 0 and group not in group_arrays
for group, weight in requested_weights.items()
):
raise ValueError(
"Every group with positive target weight needs observations."
)
weights = {
group: requested_weights.get(group, 0.0) for group in group_arrays
}
group_samples = {group: [] for group in group_arrays}
pooled_samples = []
target_samples = []
for _ in range(B):
group_means = {}
pooled_pool = []
for group, arr in group_arrays.items():
idx = rng.integers(0, len(arr), size=len(arr))
resampled = arr[idx]
group_means[group] = resampled.mean()
group_samples[group].append(group_means[group])
pooled_pool.append(resampled)
pooled_samples.append(np.concatenate(pooled_pool).mean())
target_samples.append(sum(weights[g] * group_means[g] for g in weights))
samples = {
"pooled": np.asarray(pooled_samples),
"target": np.asarray(target_samples),
**{
f"group_{g}": np.asarray(values)
for g, values in group_samples.items()
},
}
return samples, weights
boot_w1 = bootstrap_estimates(df1, target_weights)
boot_w2 = bootstrap_estimates(df2, target_weights)The pooled calculation includes every observed group even if the target gives some groups zero weight. You can leave an observed zero-weight group out of the target mapping. The report uses the recorded target weights from the same bootstrap.
PythonIn [11]Expand
def bootstrap_interval(arr, alpha=0.05):
lo = np.percentile(arr, 100 * alpha / 2)
hi = np.percentile(arr, 100 * (1 - alpha / 2))
return lo, hi
def summarize_report(bootstrap, group_rates, pooled, label):
samples, weights = bootstrap
point_estimates = {
**{f"group_{g}": rate for g, rate in group_rates.items()},
"pooled": pooled,
"target": sum(weight * group_rates[g] for g, weight in weights.items()),
}
rows = []
for quantity, estimate in point_estimates.items():
lo, hi = bootstrap_interval(samples[quantity])
rows.append(
{
"quantity": quantity,
"estimate": estimate,
"ci_low": lo,
"ci_high": hi,
"wave": label,
}
)
return pd.DataFrame(rows)
report_w1 = summarize_report(boot_w1, group_w1, pooled_w1, "W1")
report_w2 = summarize_report(boot_w2, group_w2, pooled_w2, "W2")
report = pd.concat([report_w1, report_w2], ignore_index=True)
wave_weights = {"W1": boot_w1[1], "W2": boot_w2[1]}ConsoleOut [12]Expand
Reported quantity meanings: group_G1 = within-group P(prefer Y) for G1 (population target: G1) group_G2 = within-group P(prefer Y) for G2 (population target: G2) pooled = sample-weighted mean of both groups target = 0.5*P(prefer Y | G1) + 0.5*P(prefer Y | G2) under the stated target weights quantity estimate ci_low ci_high wave group_G1 0.699 0.670 0.729 W1 group_G2 0.380 0.290 0.480 W1 pooled 0.667 0.639 0.695 W1 target 0.539 0.491 0.591 W1 group_G1 0.710 0.620 0.800 W2 group_G2 0.403 0.371 0.437 W2 pooled 0.434 0.403 0.465 W2 target 0.557 0.508 0.603 W2
The direct equal-weight estimates are 0.539 in Wave 1 and 0.557 in Wave 2. With the fixed seeds and equal target weights above, the Wave 1 percentile interval includes 0.5. A point estimate above 0.5 therefore does not establish majority preference under that equal-weight target in Wave 1. Test the decision threshold against the interval, and report the target explicitly.
VisualizationOut [13]Expand

The plot shows two kinds of variation. The pooled estimate moves sharply between waves as the sample mix changes. The equal-weight estimate moves less in this run. Within each wave, the estimate from the smaller group has a wider interval than the estimate from the larger group. With fixed group weights, the variance of a weighted sum of independent group estimates uses the squared weights. For the weighted interval, take percentiles after combining the subgroup estimates within each draw. Averaging the subgroup interval endpoints generally gives different results.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!