Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: tool-rake
kind: tool
description: Compute survey weights (rim or cell weighting to inline target shares) and write them as a weight field of a new cohort.
type: reference
applies_to: mcp

When to use

CALL TO COMPUTE SURVEY WEIGHTS THAT MAKE A SAMPLE MATCH KNOWN POPULATION SHARES. A weight must be a schema field, so pulse_rake writes it to a new cohort; point the next request at out with {"weight": {"field": "rake_weight"}}.

Input

  • cohort, out (strings, required): source path and NEW .pulse path, relative to the data directory (cohort is a path here, not a {filename} object).
  • margins (array, required): {field, targets: {category: share}} (rim) or {fields: [..], cells: [{values: [..], target}]} (cell weighting); targets_as shares (sum 1 or 100) or counts.
  • weight_field (default rake_weight), by (rake each group, e.g. a wave), base_weight, missing (refuse / base), min_weight / max_weight (relative to the mean), max_iter, tol, total, overwrite.

Output

The report (no envelope): target, records, weight_field, iterations, converged, residual, margins (observed / target / achieved share per category), groups (under by), efficiency (n_eff, deff_kish, efficiency_pct, weight range, n_capped), warnings, invalidated_sidecars.

Gotchas

  • Shares must sum to 1 (or 100): else PULSE_RAKE_INVALID (reason: targets_sum). Every category a record holds needs a target (PULSE_RAKE_UNTARGETED_CATEGORY); a target the field cannot hold is PULSE_RAKE_UNKNOWN_CATEGORY; a malformed request is PULSE_RAKE_INVALID (details.reason).
  • Not converging still writes, with PULSE_RAKE_NOT_CONVERGED; caps trade fit for efficiency.
  • The weights are PROBABILITY weights. deff_kish is the unequal-weighting design effect only.
  • Existing out without overwrite → SERVICE_VALIDATION; every refusal happens before anything is written. An SPSS metadata sidecar is carried onto out; other source sidecars are not.

See

  • survey-weights — targets, by, caps, convergence and the efficiency report.
  • weighting — using the field as a request weight.