Skip to content

Instantly share code, notes, and snippets.

@floswald
Created November 11, 2024 13:11
Show Gist options
  • Save floswald/8de85ad3a36c4e3fd4a3483867a5d197 to your computer and use it in GitHub Desktop.
Save floswald/8de85ad3a36c4e3fd4a3483867a5d197 to your computer and use it in GitHub Desktop.
ASEP example
library(srvyr)
library(ggplot2)
library(dplyr)
# https://data.aussda.at/dataverse/asep
AUT = readRDS("~/Downloads/dataverse_files-2/data/10871_da01_en_v1_0.RDS")
design <- AUT %>%
as_survey_design(strata = bl, fpc = nh_bl, weights = ind_cal_weight)
codes = data.frame(code = as.numeric(attr(AUT$savingmo_rec,"set_codes")),
label = attr(AUT$savingmo_rec,"set_levels"))
savedist = design %>%
mutate(save_numeric = as.numeric(as.character(AUT$savingmo_rec))) %>%
filter(save_numeric > 0,save_numeric < 14) %>%
group_by(save_numeric) %>%
summarize(proportion = survey_mean(vartype = "ci")) %>%
left_join(codes, by = join_by(save_numeric == code ))
savedist$label = factor(savedist$save_numeric, labels = savedist$label)
ggplot(savedist, aes(x = label, y = proportion,
ymax = proportion_upp, ymin = proportion_low)) +
geom_col(fill = "gold",color = "black") +
geom_errorbar(width = 0.3, color = "red") + coord_flip() +
scale_x_discrete(name = "") +
theme_bw() + labs(title = "Household Monthly Savings",subtitle = "Austrian Socio-Economic Panel (ASEP), 2024", caption = "ASEP Pilot Wave 1 (2023) (SUF edition), https://doi.org/10.11587/UBAALC, AUSSDA, V1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment