library(ipumsr)
library(tidyverse)
library(writexl)DREAM Act Fact Sheet 2025 Update (using CPS data)
DREAM Act Fact Sheet 2025 Update - CPS Data
Using CPS data from IPUMS to see if numbers are closer to what Kimberly got in her analysis.
I filtered the data for Texas (fips=48) before downloading the extract.
Data Prep
# Load CPS data extract (years 2019-2024)
ddi <- read_ipums_ddi("cps_00027.xml")
data <- read_ipums_micro(ddi, data_file = "cps_00027.dat", verbose = FALSE)
data <- rename_with(data, tolower)
print(data)# A tibble: 58,960 × 17
year serial month cpsid asecflag asecwth statefip pernum cpsidp cpsidv
<dbl> <dbl> <int+l> <dbl> <int+lb> <dbl> <int+lb> <dbl> <dbl> <dbl>
1 2019 64127 3 [Mar… 2.02e13 1 [ASEC] 3485. 48 [Tex… 1 2.02e13 2.02e14
2 2019 64127 3 [Mar… 2.02e13 1 [ASEC] 3485. 48 [Tex… 2 2.02e13 2.02e14
3 2019 64128 3 [Mar… 2.02e13 1 [ASEC] 3415. 48 [Tex… 1 2.02e13 2.02e14
4 2019 64128 3 [Mar… 2.02e13 1 [ASEC] 3415. 48 [Tex… 2 2.02e13 2.02e14
5 2019 64130 3 [Mar… 2.02e13 1 [ASEC] 1524. 48 [Tex… 1 2.02e13 2.02e14
6 2019 64130 3 [Mar… 2.02e13 1 [ASEC] 1524. 48 [Tex… 2 2.02e13 2.02e14
7 2019 64132 3 [Mar… 2.02e13 1 [ASEC] 3264. 48 [Tex… 1 2.02e13 2.02e14
8 2019 64132 3 [Mar… 2.02e13 1 [ASEC] 3264. 48 [Tex… 2 2.02e13 2.02e14
9 2019 64133 3 [Mar… 2.02e13 1 [ASEC] 3597. 48 [Tex… 1 2.02e13 2.02e14
10 2019 64134 3 [Mar… 2.02e13 1 [ASEC] 1707. 48 [Tex… 1 2.02e13 2.02e14
# ℹ 58,950 more rows
# ℹ 7 more variables: asecwt <dbl>, age <int+lbl>, citizen <int+lbl>,
# uhrswork1 <int+lbl>, educ <int+lbl>, wkswork1 <dbl>, incwage <dbl+lbl>
EDUC Educational attainment recode
073 High school diploma or equivalent
081 Some college but no degree
091 Associate's degree, occupational/vocational program
092 Associate's degree, academic program
111 Bachelor's degree
123 Master's degree
124 Professional school degree
125 Doctorate degree
CITIZEN Citizenship status
1 Born in U.S
2 Born in U.S. outlying
3 Born abroad of American parents
4 Naturalized citizen
5 Not a citizen
data <- data %>%
mutate(
educ_c = case_when(
educ == 073 ~ "1. High school diploma or equivalent",
educ == 081 ~ "2. Some college",
educ %in% c (091, 092) ~ "3. Associate's degree",
educ %in% c (111, 123, 124, 125) ~ "4. Bachelor's degree or higher",
TRUE ~ NA_character_),
incwage = as.numeric(incwage)
) %>%
filter(
citizen %in% c (4, 5), # filter for immigrants
age >=25,
uhrswork1 >= 35, # worked full-time (Census defines FT as 35+ hours)
wkswork1 >= 50, # worked year-round (Census defines YR as 50-52 weeks)
)
print(data)# A tibble: 5,360 × 18
year serial month cpsid asecflag asecwth statefip pernum cpsidp cpsidv
<dbl> <dbl> <int+l> <dbl> <int+lb> <dbl> <int+lb> <dbl> <dbl> <dbl>
1 2019 64143 3 [Mar… 2.02e13 1 [ASEC] 1825. 48 [Tex… 1 2.02e13 2.02e14
2 2019 64143 3 [Mar… 2.02e13 1 [ASEC] 1825. 48 [Tex… 2 2.02e13 2.02e14
3 2019 64179 3 [Mar… 0 1 [ASEC] 1559. 48 [Tex… 2 0 0
4 2019 64229 3 [Mar… 2.02e13 1 [ASEC] 1816. 48 [Tex… 2 2.02e13 2.02e14
5 2019 64240 3 [Mar… 0 1 [ASEC] 1715. 48 [Tex… 1 0 0
6 2019 64241 3 [Mar… 0 1 [ASEC] 1908. 48 [Tex… 2 0 0
7 2019 64249 3 [Mar… 2.02e13 1 [ASEC] 1705. 48 [Tex… 1 2.02e13 2.02e14
8 2019 64281 3 [Mar… 0 1 [ASEC] 1748. 48 [Tex… 1 0 0
9 2019 64281 3 [Mar… 0 1 [ASEC] 1748. 48 [Tex… 2 0 0
10 2019 64283 3 [Mar… 0 1 [ASEC] 2012. 48 [Tex… 1 0 0
# ℹ 5,350 more rows
# ℹ 8 more variables: asecwt <dbl>, age <int+lbl>, citizen <int+lbl>,
# uhrswork1 <int+lbl>, educ <int+lbl>, wkswork1 <dbl>, incwage <dbl>,
# educ_c <chr>
Option 1: Average Income (what Kimberly used)
library(survey)Loading required package: grid
Loading required package: Matrix
Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':
expand, pack, unpack
Loading required package: survival
Attaching package: 'survey'
The following object is masked from 'package:graphics':
dotchart
design <- svydesign(
ids = ~1,
weights = ~asecwt,
data = data
)
# calculate weighted mean by educational attainment
average_income <- svyby(~incwage, ~educ_c + year, design, svymean, na.rm = TRUE)
print(average_income) educ_c
1. High school diploma or equivalent.2019 1. High school diploma or equivalent
2. Some college.2019 2. Some college
3. Associate's degree.2019 3. Associate's degree
4. Bachelor's degree or higher.2019 4. Bachelor's degree or higher
1. High school diploma or equivalent.2020 1. High school diploma or equivalent
2. Some college.2020 2. Some college
3. Associate's degree.2020 3. Associate's degree
4. Bachelor's degree or higher.2020 4. Bachelor's degree or higher
1. High school diploma or equivalent.2021 1. High school diploma or equivalent
2. Some college.2021 2. Some college
3. Associate's degree.2021 3. Associate's degree
4. Bachelor's degree or higher.2021 4. Bachelor's degree or higher
1. High school diploma or equivalent.2022 1. High school diploma or equivalent
2. Some college.2022 2. Some college
3. Associate's degree.2022 3. Associate's degree
4. Bachelor's degree or higher.2022 4. Bachelor's degree or higher
1. High school diploma or equivalent.2023 1. High school diploma or equivalent
2. Some college.2023 2. Some college
3. Associate's degree.2023 3. Associate's degree
4. Bachelor's degree or higher.2023 4. Bachelor's degree or higher
1. High school diploma or equivalent.2024 1. High school diploma or equivalent
2. Some college.2024 2. Some college
3. Associate's degree.2024 3. Associate's degree
4. Bachelor's degree or higher.2024 4. Bachelor's degree or higher
year incwage se
1. High school diploma or equivalent.2019 2019 46167.81 6732.727
2. Some college.2019 2019 46009.78 3067.162
3. Associate's degree.2019 2019 43589.52 4287.221
4. Bachelor's degree or higher.2019 2019 82119.83 4419.044
1. High school diploma or equivalent.2020 2020 36702.92 1861.480
2. Some college.2020 2020 41063.23 3680.318
3. Associate's degree.2020 2020 45339.94 4241.864
4. Bachelor's degree or higher.2020 2020 104424.33 7648.128
1. High school diploma or equivalent.2021 2021 44214.51 6328.302
2. Some college.2021 2021 50098.03 5643.370
3. Associate's degree.2021 2021 77939.58 32668.293
4. Bachelor's degree or higher.2021 2021 86801.07 3647.039
1. High school diploma or equivalent.2022 2022 41627.89 4846.614
2. Some college.2022 2022 43841.53 3884.273
3. Associate's degree.2022 2022 50368.95 4391.154
4. Bachelor's degree or higher.2022 2022 100612.55 5359.303
1. High school diploma or equivalent.2023 2023 45918.62 4540.013
2. Some college.2023 2023 47232.27 3625.138
3. Associate's degree.2023 2023 49202.60 3453.008
4. Bachelor's degree or higher.2023 2023 104816.87 4938.660
1. High school diploma or equivalent.2024 2024 37628.31 1684.611
2. Some college.2024 2024 48950.00 3115.310
3. Associate's degree.2024 2024 56542.01 4834.798
4. Bachelor's degree or higher.2024 2024 103363.44 6069.699
View(average_income)Option 2: Median Income (my recommendation)
library(matrixStats)Warning: package 'matrixStats' was built under R version 4.2.3
Attaching package: 'matrixStats'
The following object is masked from 'package:dplyr':
count
# calculate weighted mean by educational attainment
median_income_data <- do.call(rbind, lapply(split(data, list(data$educ_c, data$year)), function(subset_data) {
if (nrow(subset_data) > 0) {
median_value <- weightedMedian(subset_data$incwage, subset_data$asecwt, na.rm = TRUE)
data.frame(educd_c = unique(subset_data$educ_c), year = unique(subset_data$year), median_income = median_value)
}
}))
print(median_income_data) educd_c
1. High school diploma or equivalent.2019 1. High school diploma or equivalent
2. Some college.2019 2. Some college
3. Associate's degree.2019 3. Associate's degree
4. Bachelor's degree or higher.2019 4. Bachelor's degree or higher
1. High school diploma or equivalent.2020 1. High school diploma or equivalent
2. Some college.2020 2. Some college
3. Associate's degree.2020 3. Associate's degree
4. Bachelor's degree or higher.2020 4. Bachelor's degree or higher
1. High school diploma or equivalent.2021 1. High school diploma or equivalent
2. Some college.2021 2. Some college
3. Associate's degree.2021 3. Associate's degree
4. Bachelor's degree or higher.2021 4. Bachelor's degree or higher
1. High school diploma or equivalent.2022 1. High school diploma or equivalent
2. Some college.2022 2. Some college
3. Associate's degree.2022 3. Associate's degree
4. Bachelor's degree or higher.2022 4. Bachelor's degree or higher
1. High school diploma or equivalent.2023 1. High school diploma or equivalent
2. Some college.2023 2. Some college
3. Associate's degree.2023 3. Associate's degree
4. Bachelor's degree or higher.2023 4. Bachelor's degree or higher
1. High school diploma or equivalent.2024 1. High school diploma or equivalent
2. Some college.2024 2. Some college
3. Associate's degree.2024 3. Associate's degree
4. Bachelor's degree or higher.2024 4. Bachelor's degree or higher
year median_income
1. High school diploma or equivalent.2019 2019 32830.89
2. Some college.2019 2019 40000.00
3. Associate's degree.2019 2019 36000.00
4. Bachelor's degree or higher.2019 2019 65000.00
1. High school diploma or equivalent.2020 2020 31869.04
2. Some college.2020 2020 31525.19
3. Associate's degree.2020 2020 36951.03
4. Bachelor's degree or higher.2020 2020 80000.00
1. High school diploma or equivalent.2021 2021 30000.00
2. Some college.2021 2021 41128.03
3. Associate's degree.2021 2021 40000.00
4. Bachelor's degree or higher.2021 2021 72000.00
1. High school diploma or equivalent.2022 2022 31315.38
2. Some college.2022 2022 43304.36
3. Associate's degree.2022 2022 45000.00
4. Bachelor's degree or higher.2022 2022 80000.00
1. High school diploma or equivalent.2023 2023 35000.00
2. Some college.2023 2023 39836.47
3. Associate's degree.2023 2023 48925.72
4. Bachelor's degree or higher.2023 2023 87688.89
1. High school diploma or equivalent.2024 2024 35000.00
2. Some college.2024 2024 46509.52
3. Associate's degree.2024 2024 50000.00
4. Bachelor's degree or higher.2024 2024 80000.00
View(median_income_data)# Save to excel
write_xlsx(list(Sheet1 = median_income_data, Sheet2 = average_income), "immigrant_inc_CPS_FT.xlsx")