ce_mean | R Documentation |
Calculate a weighted mean using the method used to produce official CE estimates.
ce_mean(ce_data)
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. |
A 1-row dataframe containing the following columns:
agg_exp - The estimated aggregate expenditure
mean_exp - The estimated mean expenditure
se - The estimated standard error of the estimated mean expenditure
cv - The coefficient of variation of the estimated mean expenditure
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
ce_quantiles()
ce_prepdata()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.