Living in New York can be expensive, and an increase in hourly earnings does not necessarily mean that workers can afford more. I chose this topic to understand the difference between nominal wage growth and actual purchasing power using public economic data. This project follows the OSEMN workflow: obtain, scrub, explore, model, and interpret.
Research question: Have average private sector hourly earnings in the New York metropolitan area kept pace with consumer price inflation between 2015 and 2025?
The analysis compares annual wage growth with inflation and measures how much purchasing power has changed since 2015. Housing costs are included in the broad consumer price index, but housing affordability is not measured separately.
The first source is the FRED
annual average hourly earnings series, originally produced by the
Bureau of Labor Statistics (BLS) Current Employment Statistics program.
The second is the BLS public
API, which provides the not seasonally adjusted all-items CPI-U
series CUURS12ASA0 for the New York area. These are two
acquisition formats: CSV and JSON API. Both originate from BLS programs,
but measure different economic quantities.
Both datasets represent the New York-Newark-Jersey City metropolitan area rather than the five boroughs of New York City alone. The wage data measure average hourly earnings of private-sector employees, while the CPI data measure changes in consumer prices experienced by urban consumers. Although the datasets represent the same general metropolitan region, differences in geographic boundaries and population coverage may affect their comparability.
wage_file <- "SMU36356200500000003A.csv"
wage_url <- "https://fred.stlouisfed.org/graph/fredgraph.csv?id=SMU36356200500000003A"
if (!file.exists(wage_file)) {
download.file(wage_url, wage_file, mode = "wb")
}
wage_raw <- read_csv(wage_file, show_col_types = FALSE)
head(wage_raw)
## # A tibble: 6 Ă— 2
## observation_date SMU36356200500000003A
## <date> <dbl>
## 1 2011-01-01 28.1
## 2 2012-01-01 28.5
## 3 2013-01-01 28.8
## 4 2014-01-01 29.0
## 5 2015-01-01 30.0
## 6 2016-01-01 30.4
The API is queried in blocks of no more than ten years, which avoids the need for a registration key. Raw responses are saved locally so the analysis can be reproduced without another API request.
get_cpi <- function(start, end) {
path <- paste0("bls_cpi_", start, "_", end, ".json")
if (!file.exists(path)) {
response <- POST(
"https://api.bls.gov/publicAPI/v2/timeseries/data/",
config = httr::config(http_version = 2L),
body = list(
seriesid = list("CUURS12ASA0"),
startyear = as.character(start),
endyear = as.character(end)
),
encode = "json",
timeout(60)
)
stop_for_status(response)
raw <- content(response, as = "text", encoding = "UTF-8")
check <- fromJSON(raw)
if (check$status != "REQUEST_SUCCEEDED" ||
length(check$Results$series$data) == 0 ||
nrow(check$Results$series$data[[1]]) == 0) {
stop(paste("BLS request failed:",
paste(check$message, collapse = "; ")))
}
writeLines(raw, path, useBytes = TRUE)
}
parsed <- fromJSON(path)
stopifnot(parsed$status == "REQUEST_SUCCEEDED")
as_tibble(parsed$Results$series$data[[1]])
}
cpi_raw <- bind_rows(
get_cpi(2015, 2024),
get_cpi(2025, 2025)
)
head(cpi_raw %>% select(year, period, value))
## # A tibble: 6 Ă— 3
## year period value
## <chr> <chr> <chr>
## 1 2024 M12 338.610
## 2 2024 M11 338.535
## 3 2024 M10 338.166
## 4 2024 M09 337.889
## 5 2024 M08 336.534
## 6 2024 M07 335.642
While retrieving CPI data through the BLS API, I encountered an
HTTP/2 framing error caused by an invalid response header. To resolve
this issue, I modified the API request to use HTTP/1.1 through the
httr package. This allowed me to successfully retrieve the
JSON data. I also saved the API responses as local JSON files to improve
reproducibility and avoid unnecessary API requests when rerunning the
analysis.
The wage series is already annual. CPI is reported monthly, so I calculate annual means from monthly observations and use an official annual average (M13) if supplied by BLS. Incomplete years without an official annual average are excluded from the primary analysis rather than silently treating missing months as zero or as a complete year.
wages <- wage_raw %>%
transmute(
year = year(observation_date),
wage = SMU36356200500000003A
) %>%
filter(between(year, 2015, 2025), !is.na(wage))
cpi_clean <- cpi_raw %>%
transmute(year = as.integer(year), period, cpi = as.numeric(value)) %>%
filter(between(year, 2015, 2025), !is.na(cpi)) %>%
distinct(year, period, .keep_all = TRUE)
cpi_monthly <- cpi_clean %>% filter(period %in% sprintf("M%02d", 1:12))
cpi_annual <- cpi_monthly %>%
group_by(year) %>%
summarise(
months = n(),
monthly_mean = mean(cpi),
.groups = "drop"
) %>%
left_join(
cpi_clean %>%
filter(period == "M13") %>%
select(year, official_cpi = cpi),
by = "year"
) %>%
mutate(
# Official 2025 annual CPI published by BLS
# https://www.bls.gov/regions/northeast/data/xg-tables/ro2xgcpiny.htm
official_cpi = if_else(
year == 2025,
coalesce(official_cpi, 345.511),
official_cpi
),
cpi = coalesce(
official_cpi,
if_else(months == 12, monthly_mean, NA_real_)
)
)
knitr::kable(
cpi_annual,
digits = 2,
caption = "CPI coverage and annual averages"
)
| year | months | monthly_mean | official_cpi | cpi |
|---|---|---|---|---|
| 2015 | 12 | 260.56 | NA | 260.56 |
| 2016 | 12 | 263.36 | NA | 263.36 |
| 2017 | 12 | 268.52 | NA | 268.52 |
| 2018 | 12 | 273.64 | NA | 273.64 |
| 2019 | 12 | 278.16 | NA | 278.16 |
| 2020 | 12 | 282.92 | NA | 282.92 |
| 2021 | 12 | 292.30 | NA | 292.30 |
| 2022 | 12 | 310.14 | NA | 310.14 |
| 2023 | 12 | 322.00 | NA | 322.00 |
| 2024 | 12 | 334.21 | NA | 334.21 |
| 2025 | 11 | 345.51 | 345.51 | 345.51 |
During the data cleaning process, I identified that 2025 contained only 11 monthly CPI observations. Further investigation revealed that October CPI data were unavailable due to a lapse in federal appropriations. However, the Bureau of Labor Statistics published an official annual CPI average of 345.511 for the New York-Newark-Jersey City metropolitan area. I incorporated this published value to retain 2025 in the analysis without imputing the missing monthly observation. This illustrates the importance of investigating missing data before excluding observations from an analysis.
stopifnot(!anyDuplicated(wages$year), !anyDuplicated(cpi_annual$year))
coverage <- full_join(wages, cpi_annual, by = "year") %>% arrange(year)
knitr::kable(coverage %>% select(year, wage, months, cpi), digits = 2)
| year | wage | months | cpi |
|---|---|---|---|
| 2015 | 30.02 | 12 | 260.56 |
| 2016 | 30.43 | 12 | 263.36 |
| 2017 | 31.35 | 12 | 268.52 |
| 2018 | 32.27 | 12 | 273.64 |
| 2019 | 33.25 | 12 | 278.16 |
| 2020 | 34.75 | 12 | 282.92 |
| 2021 | 36.19 | 12 | 292.30 |
| 2022 | 36.99 | 12 | 310.14 |
| 2023 | 37.49 | 12 | 322.00 |
| 2024 | 38.23 | 12 | 334.21 |
| 2025 | 39.81 | 11 | 345.51 |
econ <- coverage %>% filter(!is.na(wage), !is.na(cpi)) %>% arrange(year)
stopifnot(nrow(econ) >= 8, first(econ$year) == 2015,
all(diff(econ$year) == 1), all(econ$wage > 0), all(econ$cpi > 0))
econ <- econ %>% mutate(
wage_index = 100 * wage / first(wage),
price_index = 100 * cpi / first(cpi),
real_wage = wage * first(cpi) / cpi,
wage_growth = 100 * (wage / lag(wage) - 1),
inflation = 100 * (cpi / lag(cpi) - 1),
growth_gap = wage_growth - inflation,
real_growth = 100 * (real_wage / lag(real_wage) - 1))
growth <- econ %>% filter(!is.na(growth_gap))
last_year <- max(econ$year)
nominal_change <- last(econ$wage_index) - 100
price_change <- last(econ$price_index) - 100
real_change <- 100 * (last(econ$real_wage) / first(econ$real_wage) - 1)
The usable analysis period is 2015–2025. Both series have usable annual values through 2025. Real wages are expressed in 2015 dollars. The wage growth gap is measured in percentage points, while real wage growth is calculated directly from inflation adjusted earnings.
knitr::kable(econ %>% select(year, wage, cpi, real_wage, wage_growth, inflation, growth_gap), digits = 2)
| year | wage | cpi | real_wage | wage_growth | inflation | growth_gap |
|---|---|---|---|---|---|---|
| 2015 | 30.02 | 260.56 | 30.02 | NA | NA | NA |
| 2016 | 30.43 | 263.36 | 30.11 | 1.37 | 1.08 | 0.29 |
| 2017 | 31.35 | 268.52 | 30.42 | 3.02 | 1.96 | 1.07 |
| 2018 | 32.27 | 273.64 | 30.73 | 2.93 | 1.91 | 1.03 |
| 2019 | 33.25 | 278.16 | 31.15 | 3.04 | 1.65 | 1.38 |
| 2020 | 34.75 | 282.92 | 32.00 | 4.51 | 1.71 | 2.80 |
| 2021 | 36.19 | 292.30 | 32.26 | 4.14 | 3.32 | 0.83 |
| 2022 | 36.99 | 310.14 | 31.08 | 2.21 | 6.10 | -3.89 |
| 2023 | 37.49 | 322.00 | 30.34 | 1.35 | 3.82 | -2.47 |
| 2024 | 38.23 | 334.21 | 29.81 | 1.97 | 3.79 | -1.82 |
| 2025 | 39.81 | 345.51 | 30.02 | 4.13 | 3.38 | 0.75 |
knitr::kable(growth %>% summarise(across(c(wage_growth, inflation, growth_gap),
list(mean = mean, sd = sd, min = min, max = max))), digits = 2)
| wage_growth_mean | wage_growth_sd | wage_growth_min | wage_growth_max | inflation_mean | inflation_sd | inflation_min | inflation_max | growth_gap_mean | growth_gap_sd | growth_gap_min | growth_gap_max |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 2.87 | 1.14 | 1.35 | 4.51 | 2.87 | 1.51 | 1.08 | 6.1 | 0 | 2.05 | -3.89 | 2.8 |
econ %>% select(year, `Hourly earnings` = wage_index, `Consumer prices` = price_index) %>%
pivot_longer(-year, names_to = "series", values_to = "index") %>%
ggplot(aes(year, index, color = series)) +
geom_line(linewidth = 1.2) + geom_point(size = 2) +
scale_color_manual(values = c("Hourly earnings" = "#176B87", "Consumer prices" = "#B65D28")) +
scale_x_continuous(breaks = econ$year) +
labs(title = "Nominal Wage Growth and Consumer Prices",
subtitle = "Both series indexed to 100 in 2015", x = NULL, y = "Index", color = NULL) +
theme(legend.position = "bottom")
Indexing puts wages and prices on the same scale without using a misleading dual axis. Over the observed period, nominal wages changed by 32.6% and consumer prices by 32.6%.
growth %>%
ggplot(aes(year, growth_gap, fill = growth_gap >= 0)) +
geom_col(width = .7) +
geom_hline(yintercept = 0, color = "grey35") +
scale_fill_manual(
values = c("TRUE" = "#176B87", "FALSE" = "#B65D28"),
guide = "none"
) +
scale_x_continuous(breaks = growth$year) +
labs(
title = "Inflation Outpaced Wage Growth From 2022 to 2024",
subtitle = "Negative values indicate that prices grew faster than wages",
x = NULL,
y = "Wage growth minus inflation (percentage points)"
)
Wage growth fell below inflation in 3 of 10 observed annual comparisons. The largest shortfall occurred in 2022, when wage growth fell behind inflation by 3.89 percentage points.
The consecutive negative growth gaps from 2022 through 2024 indicate that the decline in purchasing power was not limited to a single year. Although wage growth exceeded inflation again in 2025, this improvement did not fully restore the purchasing power lost during the previous three years. These findings demonstrate that rising nominal wages do not necessarily translate into greater purchasing power.
ggplot(econ, aes(year, real_wage)) +
geom_hline(yintercept = first(econ$real_wage), linetype = "dashed", color = "grey50") +
geom_line(color = "#176B87", linewidth = 1.2) + geom_point(color = "#176B87", size = 2.5) +
scale_x_continuous(breaks = econ$year) + scale_y_continuous(labels = label_dollar()) +
labs(title = "Purchasing Power Remains Below Its 2021 Peak",
subtitle = "Dashed line represents purchasing power in 2015",
x = NULL, y = "Hourly earnings in 2015 dollars")
Adjusting hourly earnings for inflation provides a more meaningful representation of workers’ purchasing power. Real hourly earnings increased from $30.02 in 2015 to approximately $32.26 in 2021. However, rising consumer prices subsequently reduced these gains, bringing purchasing power close to its original level by 2024. Although real earnings began to recover in 2025, they remained below their 2021 peak. This suggests that increases in nominal earnings have not consistently translated into improvements in purchasing power.
change_summary <- tibble(
Measure = c(
"Nominal hourly earnings",
"Consumer prices",
"Real hourly earnings"
),
`Cumulative change (%)` = c(
nominal_change,
price_change,
real_change
)
)
knitr::kable(
change_summary,
digits = 2,
caption = "Cumulative Economic Changes, 2015–2025"
)
| Measure | Cumulative change (%) |
|---|---|
| Nominal hourly earnings | 32.61 |
| Consumer prices | 32.60 |
| Real hourly earnings | 0.01 |
I use a paired t-test because wage growth and inflation are observed for the same years. The null hypothesis is that the mean annual growth gap is zero; the alternative is that it differs from zero. The significance level is 0.05. This is an exploratory test because consecutive annual observations may not be independent and the sample is small.
paired_test <- t.test(growth$wage_growth, growth$inflation, paired = TRUE)
paired_test
##
## Paired t-test
##
## data: growth$wage_growth and growth$inflation
## t = -0.0055186, df = 9, p-value = 0.9957
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -1.470620 1.463462
## sample estimates:
## mean difference
## -0.003578876
The mean gap is 0 percentage points, with a 95% confidence interval of -1.47 to 1.46 percentage points. The p-value is 0.996. At the 5% level, I fail to reject the null hypothesis under the test assumptions. Failure to reject does not establish that wage growth and inflation are equal.
trend_model <- lm(real_wage ~ I(year - 2015), data = econ)
summary(trend_model)
##
## Call:
## lm(formula = real_wage ~ I(year - 2015), data = econ)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.9284 -0.6423 -0.2897 0.3891 1.5362
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30.703461 0.488629 62.84 3.3e-13 ***
## I(year - 2015) 0.003339 0.082593 0.04 0.969
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.8662 on 9 degrees of freedom
## Multiple R-squared: 0.0001816, Adjusted R-squared: -0.1109
## F-statistic: 0.001634 on 1 and 9 DF, p-value: 0.9686
confint(trend_model)
## 2.5 % 97.5 %
## (Intercept) 29.5981065 31.808816
## I(year - 2015) -0.1835001 0.190178
The estimated annual change in real hourly earnings is 0.003 dollars per year. This describes a linear trend rather than a causal effect or a forecast.
Although linear regression provides an estimate of the overall trend in real wages, purchasing power did not change consistently throughout the study period. The descriptive analysis reveals distinct periods of growth and decline that a single linear trend may not adequately capture.
Time series observations may be related to earlier observations. I use an autocorrelation function (ACF) to examine whether regression residuals are correlated across years. This is an additional technique beyond ordinary regression and helps assess whether standard independence assumptions are reasonable.
acf(residuals(trend_model), lag.max = min(4, nrow(econ) - 1),
main = "Autocorrelation of real wage trend residuals")
lag_one <- as.numeric(acf(residuals(trend_model), lag.max = 1, plot = FALSE)$acf[2])
lag_one
## [1] 0.6718085
The lag one residual autocorrelation is 0.67. The dashed bounds are approximate reference limits. With so few annual observations, the diagnostic has limited power; neither the regression nor the paired test should be treated as definitive evidence of a long-run population relationship.
Between 2015 and 2025, nominal hourly earnings changed by 32.6% while consumer prices changed by 32.6%. After adjusting for inflation, purchasing power increased by 0%. This indicates that average hourly earnings outpaced consumer prices over the full observed period. However, the annual growth-gap chart shows why the overall change should not be interpreted as a uniform experience across years.
The statistical comparison produced a p-value of 0.996. The descriptive change in purchasing power is the main finding; the statistical results provide additional context subject to the small sample and time-series assumptions.
Although nominal hourly earnings increased considerably over the study period, rising consumer prices offset much of this increase. The annual trends reveal that purchasing power initially improved through 2021 before declining during the following years. This highlights the difference between earning more money and being able to afford more goods and services. Overall, this analysis demonstrates the importance of evaluating wage growth alongside inflation. These findings can help policymakers, employers, and workers better understand economic conditions, compensation growth, and changes in purchasing power across the New York metropolitan area.
Average private-sector hourly earnings are not median wages, household income, or take-home pay. Changes in the composition of employment can influence the average. CPI-U represents a broad consumer basket and does not capture every household’s spending pattern. The wage and CPI metropolitan boundaries may differ, and annual aggregation hides monthly changes. The analysis does not establish causation or measure housing affordability separately.
The two sources have different structures and frequencies: annual CSV observations and nested monthly JSON records. I addressed this by extracting the API records, checking monthly coverage, converting CPI to annual values, and validating the year-level join. This also avoids silently using an incomplete year. The saved raw files allow the analysis to be reproduced even when the API is unavailable.
The report uses relative file paths and public data. The R Markdown file, wage CSV, and both cached JSON responses should be committed together to GitHub.
sessionInfo()
## R version 4.5.3 (2026-03-11)
## Platform: aarch64-apple-darwin20
## Running under: macOS Sequoia 15.6.1
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: America/New_York
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] scales_1.4.0 jsonlite_2.0.0 httr_1.4.8 lubridate_1.9.5
## [5] forcats_1.0.1 stringr_1.6.0 dplyr_1.2.1 purrr_1.2.2
## [9] readr_2.2.0 tidyr_1.3.2 tibble_3.3.1 ggplot2_4.0.3
## [13] tidyverse_2.0.0
##
## loaded via a namespace (and not attached):
## [1] bit_4.6.0 gtable_0.3.6 crayon_1.5.3 compiler_4.5.3
## [5] tidyselect_1.2.1 parallel_4.5.3 jquerylib_0.1.4 yaml_2.3.12
## [9] fastmap_1.2.0 R6_2.6.1 labeling_0.4.3 generics_0.1.4
## [13] knitr_1.51 bslib_0.12.0 pillar_1.11.1 RColorBrewer_1.1-3
## [17] tzdb_0.5.0 rlang_1.3.0 utf8_1.2.6 stringi_1.8.9
## [21] cachem_1.1.0 xfun_0.60 sass_0.4.10 S7_0.2.2
## [25] bit64_4.8.4 otel_0.2.0 timechange_0.4.0 cli_3.6.6
## [29] withr_3.0.3 magrittr_2.0.5 digest_0.6.39 grid_4.5.3
## [33] vroom_1.7.1 rstudioapi_0.18.0 hms_1.1.4 lifecycle_1.0.5
## [37] vctrs_0.7.3 evaluate_1.0.5 glue_1.8.1 farver_2.1.2
## [41] rmarkdown_2.31 tools_4.5.3 pkgconfig_2.0.3 htmltools_0.5.9