1. Introduction

This document presents an analysis of wage, state, and demographic data. The aim is to explore trends, compare union vs. nonunion wages, and understand employment patterns across different states.

2. Loading Data

Dataset origin: https://github.com/rfordatascience/tidytuesday/blob/master/data/2023/2023-09-05/readme.md

Description of dataset: The datasets “demographics.csv,” “wages.csv,” and “states.csv” offer comprehensive insights into union membership and wage patterns in the United States from 1973 to 2022, with a gap in 1982. Sourced primarily from the Current Population Survey (CPS) and its Outgoing Rotation Group (ORG) Earnings Files, these datasets reflect changes in union membership definitions post-1977. “Demographics.csv” and “states.csv” track union membership, coverage by collective bargaining agreements, and employment metrics in the U.S., broken down by various demographic and state sectors. Key variables include the year, sample size, employment figures, union membership, coverage percentages, and specific sector or demographic group data. In contrast, “wages.csv” delves into wage analysis, providing information on mean hourly earnings, the wage cap, and the union wage premium (both raw and adjusted). This dataset includes detailed variables such as sample size, wages, union and nonunion wage comparisons, and adjustments for worker and job characteristics, excluding imputed earners for accuracy. Each dataset utilizes a double or character class for variables like year, sample size, employment, and state names or abbreviations, offering a robust framework for analyzing union influence on wages and employment across different sectors and demographics in the U.S.

2.1 Loading demographics dataset

demographics <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/demographics.csv')
## Rows: 1327 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): facet
## dbl (7): year, sample_size, employment, members, covered, p_members, p_covered
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

2.2 Loading wages dataset

wages <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/wages.csv')
## Rows: 1247 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): facet
## dbl (8): year, sample_size, wage, at_cap, union_wage, nonunion_wage, union_w...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

2.3 Loading states dataset

states <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/states.csv')
## Rows: 10200 Columns: 11
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): state, sector, state_abbreviation
## dbl (8): state_census_code, observations, employment, members, covered, p_me...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

3. Filtering datasets

Here we will create two filtered datasets by date:

wages: Year greater than 2000

States: Year greater than 2000

filtered_wages <- wages[wages$year >= 2000, ]
filtered_states <- states[states$year >= 2000, ]
filtered_demographics <- demographics[demographics$year >= 2000, ]

4. Merging datasets

We will merge the states and wages as these make the most sense for merging in terms of relation.

merged_data <- merge(states, wages, by = "year", all.x = TRUE)

5. Ensuring tables are in data.table format

We set the created filtered tables to ‘data.table’ format in order to be able to use them in ggplot.

setDT(filtered_wages)
setDT(filtered_states)
setDT(filtered_demographics)

6. Creating aggregations for graphs

6.1 Calculating mean wages

wage_trends <- filtered_wages[, list(mean_union_wage = mean(union_wage, na.rm = TRUE),
                            mean_nonunion_wage = mean(nonunion_wage, na.rm = TRUE)), by = list(year)]

6.2 Calculating union wage premium

union_wage_premium <- filtered_wages[, list(raw_premium = mean(union_wage_premium_raw, na.rm = TRUE),
                                adjusted_premium = mean(union_wage_premium_adjusted, na.rm = TRUE)), by = year]

6.4 Rescaling Merged Members Column

# rescaling 'members' columns
merged_data$members_scaled <- merged_data$members * 100

6.5 Average Wage Per Year Column

average_wage_by_year <- filtered_wages[, list(average_wage = (mean(union_wage, na.rm = TRUE) + 
                                                      mean(nonunion_wage, na.rm = TRUE)) / 2), 
                               by = list(year)]

7. Creating graphs

7.2 Union Wages Comparison by Year

ggplot(filtered_wages, aes(x = factor(year), y = union_wage)) +
  geom_boxplot() +
  labs(title = "Union Wages Comparison by Year", x = "Year", y = "Union Wage") +
  theme_minimal()

There is a general upward trend in the median of union wages over the years, as indicated by the median line within each box shifting upwards. The increasing height of the boxes and the lengthening of the whiskers over time suggest that the range and the variability of the wages are also increasing. Outliers are present in several years, showing that there were wages that deviated significantly from the rest.

7.5 Union Wage Premium Over Time

ggplot() +
  geom_point(data = wages, aes(x = year, y = union_wage_premium_raw), color = "orange") +
  geom_smooth(data = wages, aes(x = year, y = union_wage_premium_adjusted), method = "loess", color = "purple") +
  labs(title = "Union Wage Premium Over Time", x = "Year", y = "Wage Premium") +
  theme_minimal() +
  scale_color_brewer(palette = "Dark2")
## `geom_smooth()` using formula = 'y ~ x'

The graph “Union Wage Premium Over Time” depicts the wage premium, which is likely the percentage difference in wages between union and nonunion workers from 1980 through 2020. The data points are scattered, suggesting variability in the union wage premium across different times and possibly different sectors or regions. The segment 2010-2020 shows a slight downward trend indicating that Union Wage Premiums may be slowly, but surely diminishing, give this trend continues into the future, however it is important to note that if this where to happen, given the current trajectory that would be may years down the line.

7.7 Employment in Different Sectors Over Time

ggplot(states, aes(x = year, y = employment, fill = sector)) +
  geom_bar(stat = "identity", position = "stack") +
  labs(title = "Employment in Different Sectors Over Time", x = "Year", y = "Employment") +
  theme_minimal() +
  scale_fill_brewer(palette = "Spectral")

The chart shows the distribution and trends of employment across various sectors from 1990 to around 2020. Private sector jobs, excluding construction and manufacturing, appear to have experienced the most significant growth, showing a consistent upward trend. In contrast, employment in the private manufacturing sector has either remained relatively stable or declined slightly, as evidenced by the shrinking proportion of this sector in the total employment stack over time. Private construction employment shows cyclical patterns, possibly correlating with economic booms and busts, and while it is a smaller segment compared to the other sectors, it also demonstrates growth in the latter years. The public sector employment is represented as well, indicating a steady, modest increase over the decades, although it constitutes a smaller slice of the overall employment pie compared to the private sector.

8. Analysis and Summary of results

The analysis of various labor market trends over the past few decades presents a multifaceted picture of the changes in employment, wages, and union representation in the United States.

Starting with wages, there is a consistent rise in average wages between 2000 and 2020, suggesting a healthy wage growth across the board. This increase is mirrored in the specific analysis of union wages, where both the median wage and the variability in wages have been climbing. This could be indicative of an overall improvement in labor market conditions, possibly driven by economic growth, inflation adjustments, and productivity increases.

However, the stability of the wage gap between union and nonunion workers from 1980 onwards implies that the benefits of union representation in terms of wage levels have persisted, providing union members with a wage premium over nonunion workers. Although there is some scatter in the data, with fluctuations that may reflect sector-specific or regional economic conditions, the wage premium has shown a slight decrease in the last decade, which, if continued, could reduce the financial advantage of being in a union.

The union membership trends offer a more concerning narrative, with a significant and almost linear decline in union membership as a percentage of the workforce from the 1980s to 2020. Starting from levels above 20%, membership has dwindled to around 5% by 2020. This decline is symptomatic of deep structural changes within the economy, such as the shift from manufacturing to services, globalization, competitive pressures, and perhaps changing labor policies and worker sentiment towards unionization.

Employment trends by sector from 1990 to 2020 show a significant increase in private non-manufacturing and non-construction jobs, suggesting a shift towards a service-driven economy. Manufacturing employment has either stabilized or decreased slightly, while construction employment has fluctuated with economic cycles. Public sector employment, although smaller compared to the private sector, has seen a steady increase.

In summary, the labor market has seen positive trends in wage growth but a concerning decline in union representation. The persistent wage gap between union and nonunion workers, alongside the overall increase in employment, particularly in the private service sector, outlines an evolving economy. The gradual decline in the union wage premium and the sharp decrease in union membership may have far-reaching implications for the labor market, potentially affecting wage negotiations, worker rights, and the overall dynamics between employers and employees.