Go to IPUMS USA, and create an account if you don’t already have one.
!. Perform an extract of the 2019 5 Year ACS data.
Select the PUMA variable from the Houshold Geographic variables.
Select the MIGRATE1 variable from the Person>Migration variables.
Select cases that only include the state of California.
Using these data, create estimates for Californian PUMAs of the % of the population that lived in the same house last year.
Produce a map of these estimates, and publish the map to Rpubs and submit the link to the site.
#downloading geo data for CA pumas
options(tigris_class = "sf")
pumas = pumas(state = "CA",
year = "2019",
cb = T)
This short report presents estimates for California PUMAs of the percentage of the population that remained in the same house in 2018 based on 2019 American Community Survey 5-year estimates.
plot(pumas["GEOID10"],
main="Public Use Mircrodata Areas in California")
mapview::mapview(pumas, zcol="GEOID10")
data$pwt = data$perwt
data$hwt = data$hhwt
#recode outcome variable
data$migrate = as.numeric(data$migrate1) %>%
Recode(data$migrate1, recodes = "1='same house';
2='moved within state';
3='moved between states';
4='moved abroad';
else=NA")
## Warning in if (as.factor) {: the condition has length > 1 and only the first
## element will be used
#generate survey design object
des = svydesign(ids = ~cluster,
strata = ~strata,
weights = ~pwt,
data = data)
#perform survey estimation for pumas
puma_est_migrate = svyby(formula = ~migrate,
by = ~puma,
design = des,
FUN = svymean,
na.rm = T)
head(puma_est_migrate)
According to the map, residents living within PUMAs in SW California and coastal West PUMAs reported a higher percentage of living in the same home in 2018 compared to other California residents.
#join to geography
pumas$puma = as.numeric(pumas$PUMACE10)
geo_ca = left_join(pumas, puma_est_migrate, by=c("puma"="puma"))
head(geo_ca)
tmap_mode("view")
## tmap mode set to interactive viewing
map = geo_ca %>%
tm_shape()+
tm_polygons("migratesame house",
style = "kmeans",
n = 7,
legend.hist = T)+
tm_layout(legend.outside = T,
title = "Percentage of California Residents Who Remained in the Same House in 2018, California PUMAs \n 2014-2019")