Skip to contents

Consolidated single-Rust-call entry point. All heavy work — spine column access, participant selection, provider/practice pool generation, year loop, per-year chunked claim generation, and parquet writes — lives inside generate_mbs_full__. The R wrapper is a thin facade that loads the item lookup (cached CSV) and the spine column vectors, then makes a single Rust call.

Usage

generate_mbs(
  spine = NULL,
  seed = 42L,
  years = 2006L:2025L,
  output_dir = NULL,
  format = c("parquet", "csv"),
  return_data = FALSE,
  chunk_size = 100000L
)

Arguments

spine

Data.frame from generate_spine() or NULL to load from the run directory.

seed

Integer random seed for MBS generation.

years

Integer vector of calendar years to generate.

output_dir

Character or NULL. Base output directory.

format

Character. "parquet" (default) or "csv".

return_data

Logical. If TRUE, reads back the written parquet files and returns a named list keyed by year. Default FALSE (stream to disk only, return metadata).

chunk_size

Integer. Persons per streaming write batch. Default 100000. Peak memory per year is bounded by this.

Value

If return_data = TRUE: named list keyed by year, each a data.frame of claims. If FALSE: metadata with per-year counts.

Details

Year-level parallelism: generate_mbs_full__ uses rayon::par_iter across years, so multiple years are generated concurrently. Each year uses a streaming ArrowWriter that flushes per-chunk RecordBatches, bounding memory to chunk_size persons' worth.

Dataset and variable information

MBS Online gives information about this dataset. Use dataset_info("MBS") for dataset information. Use variable_info("MBS") for variables, sources, value support, and topic tags.