Skip to contents

Bring Crash Investigation Sampling System (CISS) data into the current environment, whether by downloading it anew or by using pre-existing files.

Usage

get_ciss(
  years = 2019:2024,
  source = "nhtsa",
  proceed = FALSE,
  dir = NULL,
  cache = NULL
)

Arguments

years

Years to be downloaded, in yyyy (character or numeric formats, defaults to all available years, 2019-2024).

source

The source of the data. Currently only 'nhtsa' is supported, which pulls the raw SAS files from NHTSA's FTP site and prepares them on your machine.

proceed

Logical, whether or not to proceed with downloading files without asking for user permission (defaults to FALSE, thus asking permission)

dir

Directory in which to search for or save a 'CISS data' folder. If NULL (the default), files are downloaded and unzipped to temporary directories and prepared in memory. Required if cache is specified.

cache

The name of an RDS file to save or use (e.g., 'myCISS.rds'). If the file exists in 'dir', it will be returned directly. If not, data will be downloaded and an RDS file of this name will be saved in 'dir'. Requires 'dir' to be specified.

Value

A CISS data object: a list of tibbles with class 'CISS'. It contains flat, codebook, and one tibble for each CISS data table (e.g., crash, gv, occ, airbag, injury).

Details

CISS is a nationally representative probability sample of police-reported crashes involving at least one passenger vehicle towed due to damage. NHTSA crash investigators collect detailed data on the crash scene, vehicles (including event data recorders), occupants, and injuries. This function downloads the annual SAS files from NHTSA, decodes their values using the accompanying SAS formats, and stacks the requested years.

If no directory (dir) is specified, SAS files are downloaded into a tempdir(), where they are also prepared, combined, and then brought into the current environment. If you specify a directory (dir), the function will look there for a 'CISS data' folder. If not found, it will be created and populated with raw SAS and prepared RDS files, otherwise the function makes sure all requested years are present and asks permission to download any missing years.

The object returned is a list with class 'CISS'. It contains:

  • flat: a wide-formatted tibble at the occupant level, joining the crash, general vehicle (gv), and occupant (occ) tables. Vehicles without occupant records are retained. The driver's race and ethnicity from the gv table are renamed dr_race and dr_ethnicity. Non-motorists (2024 onward) are not included; see the nonmotorist and nm* tables.

  • codebook: a searchable codebook built from the SAS formats.

  • One tibble for each CISS table (e.g., crash, gv, occ, event, cdc, injury, edrprecrash), named as NHTSA names the files. Tables that do not exist in every year (e.g., vinderived in 2019, vpicdecode from 2020, and the non-motorist tables from 2024) are included when any requested year contains them.

All tables include year and caseid, which uniquely identifies a case across years. Lower-level tables also carry the applicable keys (vehno, occno, eventno, injno, seatloc, nmno). The survey design variables (psu, psustrat, casewgt, caseno, casenumber, category, version) are kept only on the crash table (and therefore in flat); join them to other tables by caseid.

CISS is a weighted sample: unweighted counts do not represent national totals. Use casewgt for point estimates, and the jackknife replicate weights in jkwgt with the coefficients in jkcoeff for variance estimation (see example below). The number of replicate weights differs by year, so estimate variances for one year at a time.

Please review the CISS Analytical User's Manual.

Examples


  if (FALSE) { # \dontrun{
    # Get all available years
    myCISS <- get_ciss()

    # Get one year and save it for later use
    myCISS <- get_ciss(2024, dir = getwd(), cache = "myCISS.rds")

    # Weighted estimate with jackknife replicate weights (one year).
    # The number of replicates differs by year (32 for 2019-2023, 40 for
    # 2024), so take the replicate columns listed in jkcoeff for that year.
    y <- 2024

    jk <-
      myCISS$jkcoeff %>%
      dplyr::filter(year == y) %>%
      dplyr::arrange(replicate)

    repwts <- paste0("jkwgt", jk$replicate)

    occ_y <-
      myCISS$occ %>%
      dplyr::filter(year == y) %>%
      dplyr::left_join(
        dplyr::select(myCISS$jkwgt, caseid, dplyr::all_of(repwts)),
        by = "caseid") %>%
      dplyr::left_join(
        dplyr::select(myCISS$crash, caseid, casewgt),
        by = "caseid")

    des <- survey::svrepdesign(
      data       = occ_y,
      weights    = ~casewgt,
      repweights = occ_y[, repwts],
      type       = "other",
      scale      = 1,
      rscales    = jk$jkcoefficient,
      mse        = TRUE)

    survey::svymean(~sex, des, na.rm = TRUE)
  } # }