ce_mean {cepumd}R Documentation

Calculate a CE weighted mean

Description

Calculate a weighted mean using the method used to produce official CE estimates.

Usage

ce_mean(ce_data)

Arguments

ce_data

A data frame containing at least a finlwt21 column, 44 replicate weight columns (wtrep01-44), a cost column, and a survey indicator column. All but the survey column must be numeric.

Value

A 1-row dataframe containing the following columns:

Note

Estimates produced using PUMD, which is topcoded by the CE and has some records suppressed to protect respondent confidentiality, will not match the published estimates released by the CE in most cases. The CE's published estimates are based on confidential data that are not topcoded nor have records suppressed. You can learn more at CE Protection of Respondent Confidentiality

See Also

ce_quantiles() ce_prepdata()

Examples


# Download the HG file keeping the section for expenditures on utilities
## Not run: 
utils_hg <- ce_hg(2017, interview) |>
  ce_uccs("Utilities, fuels, and public services", uccs_only = FALSE)

## End(Not run)

# Download and prepare interview data
## Not run: 
utils_interview <- ce_prepdata(
  2017,
  interview,
  uccs = ce_uccs(utils_hg, "Utilities, fuels, and public services"),
  zp = NULL,
  integrate_data = FALSE,
  hg = utils_hg,
  bls_urbn
)

## End(Not run)

# Calculate the mean expenditure on utilities
## Not run: ce_mean(utils_interview)

# Calculate the mean expenditure on utilities by urbanicity
## Not run: 
utils_interview |>
  tidyr::nest(-bls_urbn) |>
  mutate(mean_utils = purrr::map(data, ce_mean)) |>
  select(-data) |>
  unnest(mean_utils)

## End(Not run)


[Package cepumd version 2.1.0 Index]