Skip to content

About

Design-based survey estimation with weights as the interface

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

designweights

Design-based survey estimation with weights as the interface.

CI Docs License: BSD-3-Clause Python

designweights is a Python library for estimating finite-population parameters from survey data. It is built for survey methodologists at national statistical offices and research organizations, and for anyone who needs design-based inference that they can read, check, and trust.

The design thesis is in the name. An estimator is a function of the data and a weight vector. Everything that accounts for the sampling design, for nonresponse, or for known population totals does its work by transforming the weights. Variance estimation is the same estimator applied to replicate weights. One idea, carried all the way through.

Status: version 0. The library is pre-alpha. The API below is a seed for review, not a stable surface. Follow the roadmap to see what lands next.

Quickstart

import designweights as dw

# Estimates are plain functions of data and weights.
total = dw.total(y, weights=w)
mean = dw.mean(y, weights=w)
rate = dw.ratio(y, x, weights=w)

Install from source while the library is pre-release:

pip install git+https://github.com/hananather/designweights

Principles

  1. Plain data between layers. Functions take and return NumPy arrays and small frozen dataclasses. No framework, no global state, no hidden caches. Every intermediate quantity can be inspected.
  2. Weights are the interface. Design, nonresponse, follow-up, and calibration adjustments transform weights. Estimators never change.
  3. Formulas are readable against the literature. Each function computes one estimator and its docstring states the formula and the reference.
  4. Randomness is named. Every draw comes from a named stream, so any replication reruns alone and parallel equals serial.
  5. Exactness is tested, not asserted. Closed forms against brute-force enumeration, replicate variances against analytic ones, unbiasedness in Monte Carlo.

Where this is going

The near-term arc, in order: a Sample object carrying design information, a Weights object carrying replicate weights through a weighting pipeline, statistic-agnostic replication variance, calibration, and model-assisted estimation that composes with scikit-learn learners. Later: conformal prediction for finite-population inference. The full picture is in the roadmap.

Documentation

The documentation lives at hananather.github.io/designweights.

Contributing

Contributions are welcome, and the bar is quality over volume. Read CONTRIBUTING.md for the development setup, the testing rules, and how pull requests are reviewed.

License

BSD 3-Clause, the license family of NumPy, pandas, and scikit-learn.

About

Design-based survey estimation with weights as the interface

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages