Calibration adjusts respondent weights so weighted totals match trusted frame totals for variables measured on the same population.
Survey calibration to known population margins
Identify trustworthy controls
The support frame gives 800 standard and 400 partner cases, plus 720 email and 480 phone cases. After a queue-level response adjustment, the weighted respondent data may already match the queue totals but show 600 email and 600 phone. Those channel margins are known independently from the frame and refer to the same 1,200 eligible cases. They can be calibration controls. A margin from a different period or a different case definition cannot be imposed without creating a false match.
Iterate proportional adjustments
Raking alternates between queue and channel margins. Within a margin, multiply each current cell weight by target total divided by current weighted total. Repeat until both sets of margins are close enough. The process does not create missing queue-channel combinations; if a population cell has no responding support, a numerical algorithm cannot supply its survey answers. Positivity remains a prerequisite.
Monitor convergence and extreme factors
Four positive weighted cells start at standard-email 500, standard-phone 300, partner-email 100 and partner-phone 300. Raking them toward the two sets of target margins changes each cell, not just the overall total. Stop when residual errors fall below a declared tolerance and record the iteration count. Oscillation, a large factor or nonconvergence can signal incompatible controls, sparse support or a poor cell structure.
State what calibration cannot repair
Matching known queue and channel counts helps with imbalance on those variables. It does not prove handoff clarity is independent of response within each queue-channel cell. Nor does it correct biased item wording. Compare weighted and unweighted estimates, report the variables used, and inspect whether one respondent dominates a subgroup. The item definition remains unchanged by weight calibration.
Preserve final totals and variance inputs
Save base, response-adjusted and calibrated weights separately. Recompute each control margin from released weights and document any residual. The weights alone are insufficient for a design-based interval when invitations were stratified or clustered; preserve strata, draw probabilities and any replicate weights. Weight dispersion is an additional diagnostic, not a replacement for the survey design.
Implementation
def rake_cells(cells, targets, passes=100, tolerance=1e-8):
adjusted = [dict(cell) for cell in cells]
if sum(targets["queue"].values()) != sum(targets["channel"].values()):
raise ValueError("control totals disagree")
for _ in range(passes):
for dimension in ("queue", "channel"):
for category, target in targets[dimension].items():
members = [cell for cell in adjusted if cell[dimension] == category]
current = sum(cell["weight"] for cell in members)
if current <= 0 or target < 0:
raise ValueError("unsupported or invalid margin")
factor = target / current
for cell in members:
cell["weight"] *= factor
errors = [abs(sum(cell["weight"] for cell in adjusted
if cell[dimension] == category) - target)
for dimension in targets for category, target in targets[dimension].items()]
if max(errors) < tolerance:
return adjusted
raise ValueError("raking did not converge")
cells = [{"queue": "standard", "channel": "email", "weight": 500.0},
{"queue": "standard", "channel": "phone", "weight": 300.0},
{"queue": "partner", "channel": "email", "weight": 100.0},
{"queue": "partner", "channel": "phone", "weight": 300.0}]
targets = {"queue": {"standard": 800, "partner": 400},
"channel": {"email": 720, "phone": 480}}
calibrated = rake_cells(cells, targets)
assert round(sum(cell["weight"] for cell in calibrated if cell["channel"] == "email")) == 720Performance and operating cost
For I passes, N populated cells and K control categories, this direct implementation costs O(IKN) time and O(N) output space. Production systems use sparse matrices and design-aware calibration routines. Check residuals and weight extremes after convergence.
Common Mistakes
- Do not calibrate to margins from a different eligible population.
- Do not assume raking can fill a cell with no respondent data.
- Do not discard the original design variables once final weights exist.
