library(tidyverse)
library(here)
library(epiextractr)
Historical state union density
Contact: dperez@epi.org
This script uses Current Population Survey (CPS) microdata extracts from https://microdata.epi.org/ to calculate union density from 1983-Present.
Load CPS data using epiextractr
<- load_basic(1983:2022, year, month, statefips, basicwgt, union, unmem, age, emp, selfemp, selfinc) %>%
basic filter(age>=16, emp==1) %>%
#remove self-employed and self-incorporated workers from sample
mutate(selfemp0 = ifelse(selfemp==1 & !is.na(selfemp), yes=1, no=0),
selfinc0 = ifelse(selfinc==1 & !is.na(selfinc), yes=1, no=0)) %>%
filter(selfemp0==0, selfinc0==0)
Using EPI CPS Basic Monthly Extracts, Version 1.0.59
Calculate US union density 1983–2022
#US union members and union represented by year, 1983-2022
<- basic %>%
density_us group_by(year) %>%
summarise(represented_share = weighted.mean(union, w=basicwgt/12, na.rm=TRUE),
rep_n = sum(union, na.rm=TRUE),
member_share = weighted.mean(unmem, w=basicwgt/12, na.rm=TRUE),
memb_n = sum(unmem, na.rm=TRUE),
wgt_memb = sum(unmem * basicwgt/12, na.rm=TRUE))
density_us
# A tibble: 40 × 6
year represented_share rep_n member_share memb_n wgt_memb
<int> <dbl> <int> <dbl> <int> <dbl>
1 1983 NaN 0 0.201 34258 4422628.
2 1984 0.216 38008 0.188 32921 4328307.
3 1985 0.205 36788 0.180 32185 4236957.
4 1986 0.199 35321 0.175 31013 4230555.
5 1987 0.192 34505 0.170 30488 4221013.
6 1988 0.190 32242 0.168 28406 4241194.
7 1989 0.186 32079 0.164 28261 4235755.
8 1990 0.182 34110 0.160 29898 4192916.
9 1991 0.181 32920 0.160 29051 4152415.
10 1992 0.177 31725 0.157 28022 4098902.
# ℹ 30 more rows
Calculate state level union representation, 1983–2022
#Union representation by year and state, 1983–Present
<- basic %>%
density_state summarise(represented_share = weighted.mean(union, w=basicwgt/12, na.rm=TRUE),
.by = c(year, statefips)) %>%
#Turn statefips labels into strings
mutate(statefips = haven::as_factor(statefips)) %>%
#sort by year and state
arrange(year, statefips) %>%
#reshape data
pivot_wider(id_cols = year, names_from = statefips, values_from = represented_share)
density_state
# A tibble: 40 × 52
year AL AK AZ AR CA CO CT DE
<int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1983 NaN NaN NaN NaN NaN NaN NaN NaN
2 1984 0.179 0.279 0.120 0.120 0.248 0.146 0.222 0.193
3 1985 0.177 0.280 0.121 0.133 0.239 0.137 0.222 0.185
4 1986 0.181 0.267 0.109 0.123 0.231 0.148 0.207 0.190
5 1987 0.155 0.256 0.0825 0.133 0.223 0.138 0.200 0.180
6 1988 0.161 0.268 0.0863 0.117 0.216 0.124 0.205 0.167
7 1989 0.157 0.249 0.0877 0.121 0.218 0.113 0.193 0.173
8 1990 0.145 0.258 0.0941 0.121 0.209 0.120 0.196 0.168
9 1991 0.155 0.239 0.0979 0.125 0.206 0.118 0.200 0.185
10 1992 0.162 0.221 0.0952 0.110 0.209 0.120 0.189 0.184
# ℹ 30 more rows
# ℹ 43 more variables: DC <dbl>, FL <dbl>, GA <dbl>, HI <dbl>, ID <dbl>,
# IL <dbl>, IN <dbl>, IA <dbl>, KS <dbl>, KY <dbl>, LA <dbl>, ME <dbl>,
# MD <dbl>, MA <dbl>, MI <dbl>, MN <dbl>, MS <dbl>, MO <dbl>, MT <dbl>,
# NE <dbl>, NV <dbl>, NH <dbl>, NJ <dbl>, NM <dbl>, NY <dbl>, NC <dbl>,
# ND <dbl>, OH <dbl>, OK <dbl>, OR <dbl>, PA <dbl>, RI <dbl>, SC <dbl>,
# SD <dbl>, TN <dbl>, TX <dbl>, UT <dbl>, VT <dbl>, VA <dbl>, WA <dbl>, …