Raking Explained: Bringing Survey Weights Back in Line With the Population

When your youngest respondents fall 11.5% short of their population target, raking pulls the weights back into balance. Learn how to set up a raking run, read its convergence cycle by cycle, and confirm the final weights are safe to use.

Weighting and Design

Raking adjusts survey weights until the weighted sample matches known population totals on several variables at once, one variable at a time, in turns. This guide sets up a raking run, reads its convergence, and runs the diagnostics that tell you whether the weights are safe to use. In the worked example, five cycles bring all nine margin levels within one part in a million of their targets. The volunteering estimate moves from 33.2% unweighted to 33.1% raked, against a true value of 32.8%.

When to use this, and when not to

Use raking when you know population totals for several variables separately, but not their joint distribution. A census gives you the age mix, the sex mix, and the education mix of a city. It rarely gives you the full cross of all three for your exact population, and raking needs only the separate totals, called margins.

Use raking when the variables are categorical, or can be grouped into categories without losing much. Age in years cannot be a margin until it is banded. Income cannot be raked as a continuous variable at all. A method that calibrates on continuous variables exists, and the next guide in this series, on GREG and calibration weighting, covers it.

Do not rake to margins you cannot trust. Every target is treated as exact, so a margin from an old census or a different population pulls the weights toward the wrong totals. The worked example below shows what that costs, with a margin set drawn from an older count.

Do not rake when a margin level has no respondents, or almost none. Raking cannot create representation for a group that is missing from the sample. It can only hand the group a larger and larger share of weight through its few members, and the diagnostics section shows how that looks.

What you need

ItemRequirement
Data shapeOne row per respondent, carrying the starting weights from the design and nonresponse stages
Margin variablesTwo or more categorical variables, recorded for every respondent, with no missing values
Population marginsA target total for every level of every margin variable, from one source and one reference date
Margin totalsEvery margin must sum to the same population total, or to the total the starting weights sum to
Minimum sizeRespondents in every level of every margin, and enough in each joint cell that no handful of people carries a whole group

The method rests on two assumptions: the population margins are correct for the population and the date your survey describes, and, within any group the margins do not separate, respondents resemble the people who did not respond, on the outcomes you measure. Raking fixes the mix on the variables you give it. It does nothing for a variable you leave out.

The worked example

The dataset is simulated, and the package includes the script that generated it, so every number below can be checked. You surveyed adults in a city of 120,000 people. You sampled 250 adults per age group, the same number in each of the four groups, and 588 of the 1,000 sampled adults responded, a response rate of 58.8%. You measured two outcomes: whether the respondent volunteered in the past year, and hours of sleep on a typical night.

The respondents arrive with starting weights, built by the two stages the earlier guides in this series cover. A base weight undoes the equal allocation, so a respondent aged 18 to 29 starts at 96 and a respondent aged 45 to 64 starts at 153.6. A nonresponse adjustment by weighting classes, sex crossed with education, then scales each respondent by the response record of their class. The starting weights sum to 120,000, the city population, to the rounding of the printed column.

Because the example is simulated, the truth is known and printed. In the full population of 120,000 adults, 32.8% volunteered in the past year, and mean sleep is 7.24 hours on a typical night. Every stage below is judged against those two numbers.

One disclosure about the draw itself: it was chosen under a selection rule stated in the verification package, the smallest seed at or after 20261127 for which the raked volunteering estimate lands within 0.008 of the truth, the smallest three-way respondent cell holds between 8 and 22 people, raking takes between four and eight cycles, and the response rate falls between 0.56 and 0.68. Judge the method by the repeated-draw evidence later in this guide, not by this one draw.

Setup: choosing the margins and checking them before you run

You rake on three variables: age group, sex, and education. Each one is tied both to who responds and to the outcomes, which is what a margin variable has to be. Age and education drive the volunteering rate in this population, and sex and education drive response. A variable tied to neither changes no estimate and only adds noise to the weights.

The targets come from the population register, the same source for all three margins, with one reference date. Read Table 1 before any run. It puts each target next to the total the starting weights already give that level, and the gap between the two is the work the raking has to do.

Table 1. The margins, and where the starting weights stand.

Margin levelPopulation targetRespondentsStarting weighted totalOff by
Age 18-2924,00013121,251-11.5%
Age 30-4433,60015333,864+0.8%
Age 45-6438,40015840,941+6.6%
Age 65+24,00014623,944-0.2%
Female62,57432161,786-1.3%
Male57,42626758,214+1.4%
High school or less44,09619942,048-4.6%
Some college34,03817537,075+8.9%
Degree or more41,86621440,877-2.4%

Two checks happen at this stage, before any iteration. First, the totals: each margin sums to 120,000, the same population the starting weights sum to. A margin that sums to anything else is not a rounding issue. It is a different population, and the run below on conflicting margins shows the cost of missing it.

Second, the gaps themselves. The youngest age group stands 11.5% under its target, and the some-college group stands 8.9% over its target. Those are the corrections the raking must make, and they are large enough to matter for the estimates. A setup whose largest gap is a fraction of a percent needs no raking at all, and the honest report says so.

The raking run: one cycle, then convergence

One pass adjusts one margin. Take the first pass of the first cycle, the age margin, and check it by hand: the starting weights give the 18 to 29 group a total of 21,251.16 against a target of 24,000. The pass multiplies every weight in that group by 24,000 / 21,251.16 = 1.1293. A respondent in that group with a starting weight of 182.268, case 107 in the data file, comes out of the pass at 205.84.

The four age factors in that pass are 1.1293 for ages 18 to 29, 0.9922 for ages 30 to 44, 0.9379 for ages 45 to 64, and 1.0023 for ages 65 and over. The sex pass and the education pass then adjust their margins the same way. Adjusting education disturbs the age totals the first pass just set, which is why the passes repeat. One full cycle is one pass over each margin, in the order age, sex, and education.

Convergence is judged after each full cycle, on the worst level still off target. The measure is the relative deviation: the gap between a level's weighted total and its target, divided by the target. The run stops when every level sits below the tolerance in force. Table 2 gives the trace for this example.

Table 2. Convergence: the largest relative deviation after each cycle.

CycleLargest relative deviation
10.019894
20.001377
30.000108
40.0000086
50.00000068

The default tolerance in Analysis Studio is a relative deviation of 0.000001, one part in a million, on every level. This run reaches it in five cycles. The tolerance is a default with a reason, recorded once for the method: a pinned value keeps the guide, the verification package, and the module from drifting apart on a closer case, where stopping a cycle earlier or later could move a printed figure.

Looser tolerances stop sooner, and the trace prices each one. A tolerance of 1% or of 0.5% stops after two cycles. A tolerance of 0.1% stops after three cycles, and 0.01% stops after four. The module offers those four looser settings and prints the tolerance used in its report, so a loosened run is a loosened run on the record.

Speed is not the reason to loosen it. Five cycles on 588 respondents take no time worth saving. The reason the settings exist is the trim-and-recalibrate loop described below, where a looser delivery tolerance keeps a trimmed run from chasing a precision the trimming itself undoes.

Diagnostics: what to check before you trust the weights

Start with the margin check, because it is the one result raking guarantees. After five cycles, every level of every margin sits within 0.00007% of its target. The largest remaining gap in absolute terms is the 65 and over group, at 24,000.02 against a target of 24,000. The education levels land on their targets to the printed precision, because education is the last margin adjusted in the final cycle.

Next, read the weight distribution, in Table 3. Raking moved the smallest weight from 137.13 to 139.52 and the largest from 291.63 to 285.65. The spread narrowed a little: the largest weight is 2.05 times the smallest after raking, against 2.13 times before. That direction is not a rule: raking moves weights toward the margins, and the spread goes wherever the margins push it.

Table 3. The weight distribution and the effective sample size.

Weight setSumSmallestLargestCVKish design effectEffective n
Starting weights120,000137.13291.630.22021.0485561
Raked weights120,000139.52285.650.18271.0334569

The effective sample size turns the spread into a cost you can state. Kish's approximation reads the coefficient of variation of the weights and returns a design effect. The starting weights cost 27 of your 588 respondents, an effective sample of 561, and raking hands eight of them back, an effective sample of 569, because it narrowed the spread in this example. A raking run that widens the spread charges more, and the charge is the number to report.

Then look inside the cells the margins do not control. Raking matches age, sex, and education one variable at a time and says nothing about their crosses, and the crosses are where thin ice hides. The twelve age-by-education cells in this sample hold between 29 and 80 respondents. The 24 three-way cells, age by sex by education, hold between 10 and 47.

The smallest three-way cell is men aged 65 and over with some college: ten respondents. Their mean final weight is 146.9, well under the overall mean of 204.1, so they carry less than an average share each. That is a cell to note, not a cell in trouble. Trouble has the opposite shape: a small cell whose mean weight runs far over the overall mean, because a few people are carrying a whole group.

The average final weight across the twelve age-by-education cells runs from 145.1 to 275.0. No cell average is double the overall mean. Read together, the cell counts and the cell weights say the margins are not leaning on any handful of respondents. When they do lean, the remedies are to collapse a margin level into its neighbour, or to drop the weakest margin, and to rerun and compare the headline estimates.

When margins fight: the run that never converges

Now replace the education margin with targets from an older census of the same city. The levels are 43,508 with high school or less, 33,584 with some college, and 41,308 with a degree or more. They look like the right margin. They sum to 118,400, not 120,000, and that one fact decides the run before it starts.

Table 4. The conflicting run: the largest relative deviation after each cycle.

CycleLargest relative deviation
10.024541
20.013960
30.013385
50.013334
100.013333
2000.013333

The deviation falls for three cycles and then stops falling, at 0.013333, for good. Two hundred cycles change nothing after the tenth. That stall is the diagnostic: a deviation that levels off well above the tolerance is not slow convergence. It is a contradiction in the inputs, and more cycles will not cure it.

That stall is the diagnostic: a deviation that levels off well above the tolerance is not slow convergence.

The stall value is the contradiction measured. The two margin sets disagree about the size of the population by 1,600 people, which is 1.333% of 120,000. Each education pass pulls the weight total down to 118,400, and each age and sex pass pulls it back up to 120,000. The worst level can never sit closer than the disagreement itself, so the trace parks at 0.013333 and waits for you to fix the inputs.

The fix happens before the run, not during it: take every margin from one source with one reference date, and check the totals against each other at setup. Where two sources genuinely cannot be reconciled, rescale one margin to the common total on purpose, in the open, and record the choice. The module offers a match-the-first-margin option that rescales the rest silently. Leave it off unless you have already made that decision yourself, because it removes the stall that warns you.

Trimming: a follow-up decision, priced

Trimming caps the largest weights after calibration, to buy back effective sample size, and it is a follow-up decision, not a default step. This example shows how to price it, starting with the check that decides whether trimming is even a candidate. The largest raked weight is 285.65, which is 1.40 times the mean weight of 204.08. A cap at three times the mean, a common production rule, sits at 612.24 and touches no weight at all.

Price a cap that does bite. Capping the final weights at their 95th percentile, 265.48, caps 24 respondents. Raking the capped weights back to the same tolerance takes five cycles, and the largest weight climbs back to 271.86 in the process. Recalibration hands some of the trimmed weight back, because the margins still have to be met by somebody.

The purchase, priced: the coefficient of variation moves from 0.1827 to 0.1825, and the effective sample size moves from 569.0 to 569.1. The volunteering estimate moves from 0.3312 to 0.3308. In plain terms, the trim buys nothing here, because the spread was never wide enough to cost anything. The weight-trimming guide in this series takes up the cases where the spread is wide and the trade is real.

Estimates: what the stages do to the answers

Table 5 puts the two outcomes under each weighting stage, with the truth beside them. Read the volunteering column first. The unweighted figure is 0.3316 and the starting weights give 0.3321. Raking gives 0.3312, and the trimmed set gives 0.3308. The truth is 0.3276, so every stage overshoots in this draw, and raking closes about a fifth of the remaining gap.

Table 5. Estimates under each weighting stage.

EstimateUnweightedStarting weightsRakedRaked and trimmedPopulation truth
Volunteered in the past year0.33160.33210.33120.33080.3276
Mean hours of sleep7.24717.22767.22347.22367.2401

Sleep moves the other way. The unweighted mean is 7.2471 hours, the starting weights give 7.2276, and raking gives 7.2234, against a truth of 7.2401. The starting weights land closest in this draw. That is not a verdict on the stages: it is one draw, and the next paragraph prices the stages over many draws instead.

With the raked weights, the volunteering estimate is 33.1%, with a standard error of 0.0196 and a 95% confidence interval of 0.2927 to 0.3698. Mean sleep is 7.22 hours, with a standard error of 0.0462 and an interval of 7.1326 to 7.3141. Both intervals cover their true values in this draw. The standard errors are calibration-aware: they credit the raking for the variation the margins explain, by working on the residuals from a regression of the outcome on the margin variables.

The credit here is small, and the guide says so plainly. Treating the raked weights as fixed gives a standard error of 0.0198 for volunteering, against 0.0196 calibration-aware. The margins predict volunteering weakly in this population, so there is little variation for the calibration to explain. Where a margin variable separates the outcome sharply, the credit grows, and the first guide in this series shows a case at about 11%.

The repeated-draw evidence sits in the verification package. Over 500 draws from this same population, the unweighted volunteering estimate averages 0.0008 over the truth, the starting weights average 0.0034 over, and the raked weights average 0.0001 over. For sleep, the averages are 0.0178 hours over unweighted, 0.0006 over with the starting weights, and 0.0016 under raked. The 95% intervals cover the truth 93% to 96% of the time, and raking takes 4.35 cycles on average, six at most.

Doing it in Analysis Studio

Work through the run in the Survey Weighting and Raking module. The figures to compare against are Table 1 for the setup, Table 2 for the run, and Tables 3 and 5 for the results. Take the steps in order, and stop at any step whose figure disagrees with the tables.

  1. Open the Survey Weighting and Raking module. It opens on the weighting it is given, with the example survey preloaded; use Clear survey for your own data, then Upload data and choose your file. The data preview shows the first rows of the respondent file, one row per respondent.
  2. In the weighting card, set the base weight to the column that carries your starting weights, start_wt in this example. The card shows its sum and range; the sum should read 120,000. Set the calibration method to Raking (iterative proportional fitting). The nonresponse adjustment method is already inside your starting weights, so leave it at None for this run.
  3. In the margins card, add the three margins with the targets from Table 1. Enter age group first, then sex, then education, and the levels in the order shown. The card totals each margin as you enter it; each one must total 120,000 before you run.
  4. Leave Match the first margin's total unticked. Ticking it rescales the other margins to the first margin's total, which hides exactly the conflict the section above teaches you to catch. Set the convergence tolerance to the module default, a relative deviation of 1e-6; the looser settings, 0.01%, 0.1%, 0.5%, and 1%, are there for trim-and-recalibrate work.
  5. Set the key variable to volunteered, then run the calibration. The report opens with the margin check, where every level should show its target met. Below it, the report gives the cycles taken, five in this run, and the tolerance used.
  6. Read the weight diagnostics in the same report. The smallest and largest final weights, the coefficient of variation, the design effect, and the effective sample size should match Table 3. If a figure disagrees with your own reference run, stop and find the difference before you analyse anything.
  7. Run the margin check against your own totals, not only the module's. Add the final weights inside each margin level in your spreadsheet or statistics program, and compare against Table 1. Raking's one guarantee is the margins, so verify the guarantee on a second path.
  8. Under the report, choose Use this dataset now. The dataset carries weight_final forward, so the rest of the Studio analyses with the raked weights. Choose the trimmed-and-recalibrated weight instead only if your diagnostics priced the trim and found it worth buying; in this example it was not.
  9. Open the Survey design card under Data & design and declare the design once: standard errors Taylor, weight weight_final, strata age_group. Every analysis after this reads the same design, so declare it before you run anything else, and leave it in place for the rest of the session.

Reading the output

Read the report in the order the module prints it, and stop at the first section that fails. The margin check comes first, because every later number inherits it. Then the convergence line, which tells you the run finished rather than stalled. Then the weight diagnostics, which price the weights, and the estimates come last.

In plain language, the headline result reads like this. An estimated 33.1% of adults in the city volunteered in the past year (95% CI: 29.3% to 37.0%), based on 588 respondents weighted to the city population of 120,000. Adults in the city averaged 7.22 hours of sleep a night (95% CI: 7.13 to 7.31).

The design effect line needs one distinction kept straight. The Kish figure in Table 3, 1.0334, prices the weight spread alone and gives an effective sample of 569. The design-based figure for the volunteering estimate is 1.0222, which corresponds to about 575 respondents. The two answer different questions: the first grades the weights, and the second grades this estimate under the declared design.

Checks and pitfalls

  • Margins that sum to different totals. The run stalls at the size of the disagreement and never converges. Check every margin total at setup, against the population and against each other. The stall is the warning; a rescale option that silences it is not a fix.
  • A margin level with no respondents. Raking has nobody to weight up, so the level can never reach its target. Check the respondent count in every level before you run. Collapse the level into a neighbour, or drop the margin, and say which you did.
  • A thin cell carrying a whole group. The margins can match perfectly while ten people carry a joint cell at several times the average weight. Read the cell counts and the cell mean weights, not only the margin check. A cell mean near double the overall mean is the warning shape.
  • Treating the raked weights as fixed. The standard errors then skip the credit for the variation the margins explain, and read wider than they should. Declare the calibration in the design, so the standard errors are computed on the calibration residuals.
  • Raking on a variable tied to nothing. A margin variable unrelated to response and to the outcomes changes no estimate and only adds spread. Each margin has to earn its place, tied to who responds or to what you measure.
  • Trimming by habit. A cap that touches no weight changes nothing, and a cap that bites buys back only what the spread was costing. Price the trim first: the largest weight against the mean, and the effective sample size before and after.
  • Reporting the raked point estimate without its interval. The estimate moved by a tenth of a point in this example, and the interval is four points wide on each side. The weighting stages refine the estimate. They do not shrink the sampling uncertainty that dominates it.

Verify it yourself

The verification package carries the respondent data, the generator that built the population, and two reference implementations. Run the Python reference script and it checks 146 figures from this guide against its own computation, printing PASS or FAIL for each one. The R script mirrors it in base R. The Monte Carlo script repeats the whole design 500 times and reports the bias and the interval coverage quoted above.

The package also carries the margins, the convergence traces, the conflicting-margins run, and the trimming run, each as a printed figure with its location in this guide. Change the tolerance in the reference script and the cycle counts move the way Table 2 prices them. Change the education margin to the older census figures and the stall appears on cue. The dataset is simulated and carries no real respondents, so it can be shared and rerun freely.

Package: Download it from the verification package page.

Related guides

  • The unweighted number is the wrong number: survey weighting in Analysis Studio sets up the design this guide starts from: strata, base weights, and the weighting stages in order. Read it first if the stages themselves are new to you.
  • The Silent Participants: Understanding Base Weights and Nonresponse builds the starting weights used here, base weights first and then the weighting-class nonresponse adjustment. Its worked example ends where this one begins, with the same discipline of printed checks at every stage.
  • GREG and calibration weighting calibrates on continuous variables as well as categories, and relaxes the exact-fit discipline raking imposes. It is the method to reach for when a margin like income cannot be banded without losing what it measures.
  • Weight trimming and the design effect takes up the trimming decision in full: where to cap, what the cap costs in bias, and when the trade is worth making. This guide prices one trim; that one prices the policy.

Tool release: Analysis Studio production 5ff5cb2e (November 24, 2026). Data as of: simulated dataset generated November 2026 (no real respondents). Last verified: November 24, 2026. Corrections: corrections policy.

The Investor Stats Cheat Sheet

A free three-page PDF: breakeven win rates, stop-loss sizing, volatility drag, reverse valuation, and how to tell a real track record from noise. Plus new tools as they ship.