CUNY · QUEENS COLLEGE · DEPT. OF SOCIOLOGY

40.74° N · 73.82° W

Joseph Nathan Cohen

Sociologist at Queens College in the City University of New York

Posts

/

Introducing the R package `scf`

A package that facilitates analysis of the Survey of Consumer Finances

This post introduces the R package scf.

The Survey of Consumer Finances is among the highest-quality and most tractable household-finance surveys available. But its many affordances come at the cost of complexity. Two features in particular — a complex sampling design and multiple imputation to handle missing data — each introduces complications that discourage generalists from engaging with the data.

Those complications are subtle enough to be dangerous. Students who hand the whole task to AI routinely fail to catch a model’s quiet “bug fixes” — buried somewhere in hundreds of lines of code — that invalidate a test or the entire analysis.

These problems are unnecessary because much of SCF analysis is highly routinized. It can be scripted into simple functions that are easy to learn and easy to drive with AI. Today I am happy to announce the release of the R package scf, which offers a data-management system and a functional grammar that make valid analysis of SCF microdata easy enough for an intermediate analyst — someone comfortable with basic wrangling and with analytical operations up to generalized linear models.

What it does

The scf package builds on Lumley’s survey package and Anthony Damico’s asdfree project. It constructs a complex data-design object that carries the survey design, the five implicates, and the replicate weights together. A library of wrangling, analytical, and visualization operations then works against that object to produce results that follow best practice — as defined both by the SCF and by the general analyst community.

The package is validated against the Federal Reserve’s own published figures: given the same inputs, it reproduces the official statistics.

Getting started

Install from CRAN, load a survey year, and you are one call away from a real estimate:

library(scf)

scf2022 <- scf_load(2022)
scf_mean(scf2022, ~networth, ~race1)

The result comes back as a tidy table — an estimate, a standard error, and a range for each group — with the imputation and replicate-weight arithmetic handled for you. That is the whole idea: a grouped estimate, with a correct standard error, in one call.

To install:

install.packages("scf")

Update — May 2026

Percentile-based grouping is a commonplace operation, but the SCF’s design makes it easy to get subtly wrong. It now has its own function, scf_pctile_sum(), and its own note. The function offers two workflows: an implicate-wise, imputation-aware approach for ordinary analysis, and a stacked approach that reproduces the Federal Reserve’s official percentile-category convention.

The stacked workflow reproduces the Fed’s published top-decile figure almost exactly — $7,771,163 against the Fed’s published $7,771,290:

scf2022 <- scf_load(2022)

scf_pctile_sum(scf2022, ~networth,
               probs    = c(0, 0.9, 1),
               labels   = c("bottom90", "top10"),
               method   = "stack",
               stat     = "mean",
               stat_var = ~networth)
#>      group variable  estimate
#> 1 bottom90 networth  313517.2
#> 2    top10 networth 7771163.1

Further reading

The package is on CRAN at cran.r-project.org/package=scf; source lives on GitHub. The software page has a fuller worked example.

Share / Cite

Joseph Nathan Cohen Avatar

Associate Professor of Sociology at Queens College, CUNY. Writes about household finance, culture, and the tools social scientists use to measure economic life.