#load processed survey data
load("C:/Users/court/Google Drive/Research/SRHS/landlord_survey_w_weights.RData")
# keep original data just in case
land_0 <- land
land <- land %>%
mutate(ll_size = case_when(
q7 >= 1 & q7 <=4 ~ "small (1-4 units)",
q7 >= 5 ~ "big (5+ units)")) %>%
set_variable_labels(ll_size = "Landlord size") %>%
mutate(land, ll_size = factor(ll_size, levels = c("small (1-4 units)", "big (5+ units)")))
land <- land %>%
mutate(ll_size_b = case_when(
ll_size == "small (1-4 units)" ~ 0,
ll_size == "big (5+ units)" ~ 1)) %>%
set_variable_labels(ll_size = "Landlord size")
# new 4-cat ll_size measure including single family home ownership
land <- land %>%
mutate(ll_size2 = case_when(
ll_size == "small (1-4 units)" &
q7==1 &
tot_bldgs== "1 Building" &
q70!="0 bedroom (studio/efficiency)" ~ "small (1 single-fam home)",
ll_size == "small (1-4 units)" ~ "small (1-4 other units)",
ll_size == "big (5+ units)" ~ "big (5+ units)"))
land <- land %>% mutate(
ll_size2 =
factor(ll_size2, levels =
c("small (1 single-fam home)",
"small (1-4 other units)",
"big (5+ units)")))
# extract zip codes to different columns without other text
# reg expression didn't work below - commment out, try other approach
# df <- zipcodes %>%
# mutate(zcodes=str_remove_all(zcodes, text_pattern))%>%
# separate(zcodes, paste0("zip",1:20), sep = c(',|;|:|\\.|&|/')) %>%
# mutate(across(where(is.character), ~str_trim(.)))
# extract 5-digit numbers to new column, then separate into many columns
land <- land %>%
mutate(zcodes = str_extract_all(q22, "\\b\\d{5}\\b") %>%
map_chr(toString)) %>%
separate(zcodes, paste0("zip",1:20), sep = c(',')) %>%
mutate(across(where(is.character), ~str_trim(.)))
# create zip code categories based on Kyle Crowder's organization of zip codes
zip_1_list <- c("98101|98102|98104|98109|98112|98113|98119|98121|98134|98139|98164|98199")
zip_2_list <- c("98103|98105|98115|98125|98133|98195")
zip_3_list <- c("98108|98118|98122|98144|98178")
zip_4_list <- c("98107|98117|98177")
zip_5_list <- c("98106|98116|98126|98136|98146")
zip_6_list <- c("98012|98020|98155")
zip_7_list <- c("98148|98168|98188|98198")
zip_8_list <- c("98009|98011|98033|98034|98052")
zip_9_list <- c("94537|95125|97125|99105|99118|99350,99507")
zip_NA_list <- c("98016|98128|98137")
land <- land %>%
mutate(
zip_region1 = case_when(str_detect(q22, zip_1_list) ~ 1),
zip_region2 = case_when(str_detect(q22, zip_2_list) ~ 1),
zip_region3 = case_when(str_detect(q22, zip_3_list) ~ 1),
zip_region4 = case_when(str_detect(q22, zip_4_list) ~ 1),
zip_region5 = case_when(str_detect(q22, zip_5_list) ~ 1),
zip_region6 = case_when(str_detect(q22, zip_6_list) ~ 1),
zip_region7 = case_when(str_detect(q22, zip_7_list) ~ 1),
zip_region8 = case_when(str_detect(q22, zip_8_list) ~ 1),
zip_region9 = case_when(str_detect(q22, zip_9_list) ~ 1),
zip_regionNA = case_when(str_detect(q22, zip_NA_list) ~ 1))
land <- land %>%
mutate(zip_region_sum =
rowSums(select(., contains("zip_region")), na.rm=TRUE))
land <- land %>%
mutate(zip_region = case_when(
zip_region_sum >1 ~ 10,
str_detect(q22, zip_1_list) ~ 1,
str_detect(q22, zip_2_list) ~ 2,
str_detect(q22, zip_3_list) ~ 3,
str_detect(q22, zip_4_list) ~ 4,
str_detect(q22, zip_5_list) ~ 5,
str_detect(q22, zip_6_list) ~ 6,
str_detect(q22, zip_7_list) ~ 7,
str_detect(q22, zip_8_list) ~ 8,
str_detect(q22, zip_9_list) ~ 9,
str_detect(q22, zip_NA_list) ~ NA_real_))
#zip code regions, but there were no 8s, or 9s (they were multiple)
# 1 "central",
# 2 "northcentral",
# 3 "southcentral",
# 4 "northwest",
# 5 "southwest",
# 6 "far north",
# 7 "far south",
# 8 "eastside",
# 9 "outside Seattle",
# 10 "multiple"
zip_region_level <- c("central",
"northcentral",
"southcentral",
"northwest",
"southwest",
"far north",
"far south",
"multiple")
land <- land %>%
mutate(zip_region = factor(zip_region,
labels = zip_region_level))
#
## Business Practices
# make binary for logistic regression
# tenant_income
land <- land %>%
mutate(tenant_income_b = case_when(
tenant_income == "Less than $25,000 per year" ~ 0,
tenant_income == "$25,000-50,000 per year" ~ 0,
TRUE ~ 1
)) %>%
set_value_labels(tenant_income_b = c("> $50,000" = 1, "<= $50,000" = 0)) %>%
set_variable_labels(tenant_income_b = "Avg tenant income")
# rent_screen
land <- land %>%
mutate(rent_screen_b = case_when(
rent_screen == "Yes" ~ 1,
TRUE ~ 0)) %>%
set_value_labels(rent_screen_b = c("yes" = 1, "no" = 0)) %>%
set_variable_labels(rent_screen_b = "Screening service")
# flex_decision = q26
land <- land %>%
mutate(flex_decision_b = case_when(
flex_decision == "Strongly agree" ~ 1,
flex_decision == "Agree" ~ 1,
flex_decision == "Neither agree nor disagree" ~ 0,
flex_decision == "Disagree" ~ 0,
flex_decision == "Strongly agree" ~ 0,
flex_decision == "Refused" ~ 0)) %>%
set_value_labels(flex_decision_b = c("agree" = 1, "disagree/neutral" = 0)) %>%
set_variable_labels(flex_decision_b = "Flexible decisions")
# rent_voucher = q57
land <- land %>%
mutate(rent_voucher_b = case_when(
rent_voucher == "Yes" ~ 1,
TRUE ~ 0)) %>%
set_value_labels(rent_voucher_b = c("yes" = 1, "no, dk, missing" = 0)) %>%
set_variable_labels(rent_voucher_b = "Rented to voucher")
# rent_monthly = q72
# NOTE - googled avg monthly rent in seattle: ~ $2000
# 214 missing (NA), 52 refused
land <- land %>%
mutate(rent_monthly_b = case_when(
rent_monthly == "Less than $500" ~ 0,
rent_monthly == "$500-1,000" ~ 0,
rent_monthly == "$1,001-1,500" ~ 0,
rent_monthly == "Refused" ~ NA_real_,
TRUE ~ 1)) %>%
set_value_labels(rent_monthly_b = c("> $1,500" = 1, "<= $1,500" = 0)) %>%
set_variable_labels(rent_monthly_b = "Avg. monthly rent")
# rent_raise = q85
# made quasi-numeric
land <- land %>%
mutate(rent_raise_b = case_when(
rent_raise == "0% (I have not raised the rent in a Seattle unit in the past year)" ~ 0,
rent_raise == "1-5%" ~ 1,
rent_raise == "6-10%" ~ 6,
rent_raise == "11-15%" ~ 11,
rent_raise == "16-25%" ~ 16,
rent_raise == "More than 25%" ~ 26,
rent_raise == "Refused" ~ NA_real_)) %>%
set_variable_labels(rent_raise_b = "Pct. raised rent")
land <- land %>%
mutate(rent_raise_market_b = case_when(
rent_raise_market == "No" ~ 0,
rent_raise_market == "Yes" ~ 1)) %>%
set_value_labels(rent_raise_market_b = c("yes" = 1, "no" = 0)) %>%
set_variable_labels(rent_raise_market_b = "Raise due to market")
# terminate_num = q67
land <- land %>%
mutate(terminate_num_b = case_when(
terminate_num == "0" ~ 0,
terminate_num == "Refused" ~ NA_real_,
TRUE ~ 1)) %>%
set_value_labels(terminate_num_b = c("none" = 0, "1 or more/dk" = 1)) %>%
set_variable_labels(terminate_num_b = "Number tenancies terminated")
# terminate_reason_pay = q68_1
land <- land %>%
mutate(terminate_reason_pay_b = case_when(
terminate_reason_pay == "Tenant(s) failed to pay rent or fees" ~ 1),
terminate_reason_pay_b = case_when(
terminate_reason_pay_b == 1 ~ 1,
terminate_num_b ==1 ~ 0)) %>%
set_value_labels(terminate_reason_pay_b = c("Failed to pay rent" = 1, "Other reason" = 0)) %>%
set_variable_labels(terminate_reason_pay_b = "Termination reason - pay rent")
# terminate_reason_paylate = q68_2
land <- land %>%
mutate(terminate_reason_paylate_b = case_when(
terminate_reason_paylate == "Tenant(s) consistently paid rent/fees late" ~ 1),
terminate_reason_paylate_b = case_when(
terminate_reason_paylate_b == 1 ~ 1,
terminate_num_b ==1 ~ 0)) %>%
set_value_labels(terminate_reason_paylate_b = c("Paid late" = 1, "Other reason" = 0)) %>%
set_variable_labels(terminate_reason_paylate_b = "Termination reason - late rent")
# terminate_reason_voucher = q68_3
land <- land %>%
mutate(terminate_reason_voucher_b = case_when(
terminate_reason_voucher == "Tenant lost their housing voucher" ~ 1),
terminate_reason_voucher_b = case_when(
terminate_reason_voucher_b == 1 ~ 1,
terminate_num_b ==1 ~ 0)) %>%
set_value_labels(terminate_reason_voucher_b = c("Lost voucher" = 1, "Other reason" = 0)) %>%
set_variable_labels(terminate_reason_voucher_b = "Termination reason - lost voucher")
# terminate_reason_rules = q68_4
land <- land %>%
mutate(terminate_reason_rules_b = case_when(
terminate_reason_rules == "Tenant(s) failed to comply with rules of rental agreement (other than regarding rent) " ~ 1),
terminate_reason_rules_b = case_when(
terminate_reason_rules_b == 1 ~ 1,
terminate_num_b ==1 ~ 0)) %>%
set_value_labels(terminate_reason_rules_b = c("Broke rules" = 1, "Other reason" = 0)) %>%
set_variable_labels(terminate_reason_rules_b = "Termination reason - rules")
# terminate_reason_occupy = q68_5
land <- land %>%
mutate(terminate_reason_occupy_b = case_when(
terminate_reason_occupy == "So that you or a family member could occupy the unit" ~ 1),
terminate_reason_occupy_b = case_when(
terminate_reason_occupy_b == 1 ~ 1,
terminate_num_b ==1 ~ 0)) %>%
set_value_labels(terminate_reason_occupy_b = c("LL occupy unit" = 1, "Other reason" = 0)) %>%
set_variable_labels(terminate_reason_occupy_b = "Termination reason - occupy unit")
# terminate_reason_sell = q68_6
land <- land %>%
mutate(terminate_reason_sell_b = case_when(
terminate_reason_sell == "So that you could sell the unit" ~ 1),
terminate_reason_sell_b = case_when(
terminate_reason_sell_b == 1 ~ 1,
terminate_num_b ==1 ~ 0)) %>%
set_value_labels(terminate_reason_sell_b = c("Sell unit" = 1, "Other reason" = 0)) %>%
set_variable_labels(terminate_reason_sell_b = "Termination reason - sell")
# terminate_reason_other = q68_7
land <- land %>%
mutate(terminate_reason_other_b = case_when(
terminate_reason_other == "Other" ~ 1),
terminate_reason_other_b = case_when(
terminate_reason_other_b == 1 ~ 1,
terminate_num_b ==1 ~ 0)) %>%
set_value_labels(terminate_reason_other_b = c("Other reason" = 1, "One of specific reasons" = 0)) %>%
set_variable_labels(terminate_reason_other_b = "Termination reason - other")
# terminate_court = q69
land <- land %>%
mutate(terminate_court_b = case_when(
terminate_court == " Always directly with the tenant" ~ 0,
terminate_court == "Through the courts and directly with the tenant, but more often directly with the tenant" ~ 0,
terminate_court == "Refulsed" ~ NA_real_,
TRUE ~ 1)) %>%
set_value_labels(terminate_court_b = c("with tenant" = 0, "with courts" = 1)) %>%
set_variable_labels(terminate_reason_other_b = "Termination within court")
# new 4-cat ll_size measure including single family home ownership
New landlord category that separates landlords with 1 unit that is a single family home (at least larger than a studio).
waffle_data1 <- c(`Small Landlords, 1 single-fam home` = (1650),
`Small Landlords, 1-4 other units` =(1296),
`Large Landlords (5+ units)`=890)
# # weighted
# waffle_data2 <- c(`Small Landlords (1-4 units)`=(3235),
# `Large Landlords (5+ units)`=601)
w1 <- waffle(waffle_data1/180, rows=5, size=1, colors=c("pink", "red", "maroon"),
title="43% of respondents are small landlords with 1 single family home (unweighted)",
xlab="One square ~ 180 landlords")
# w2 <- waffle(waffle_data2/100, rows=5, size=1, colors=c("pink", "red"),
# title="weighted: 84% of respondents are small landlords",
# xlab="One square ~ 100 landlords")
grid.arrange(w1)
# PIE CHART - DIFFICULT TO FIGURE OUT ....
# land %>% ggplot(aes(x="",
# y=ll_size,
# fill=ll_size)) +
# geom_bar(stat="identity", width=1) +
# coord_polar("y", start=0) +
# theme_void() +
# labs(title = "Landlord size and financial role",
# fill = "Landlord Size")
land %>% ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(tenant_income))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and tenant income",
fill = "Tenant Income") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(as.factor(tenant_income_b)))) +
geom_bar(position="fill") +
labs(y = "Prop",
x = "Landlord size",
title = "Binary tenant income (above and below %50,000)",
fill = "Tenant Income") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(rent_screen))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and screening service",
fill = "Screening Service") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(as.factor(rent_screen_b)))) +
geom_bar(position="fill") +
labs(y = "Prop",
x = "Landlord size",
title = "Binary rent screen (no and yes)",
fill = "Screening Service") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(flex_decision))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and flexible decisions",
fill = "Flexible Decisions") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% filter(!is.na(flex_decision_b)) %>%
ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(as.factor(flex_decision_b)))) +
geom_bar(position="fill") +
labs(y = "Prop",
x = "Landlord size",
title = "Binary flex decisions (disagree or agree)",
fill = "Flexible Decisions") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(rent_voucher))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and voucher holders",
fill = "Rent to Voucher Holders") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
Note in the figure below, the average monthly rent for units was asked before landlords reported which type of unit was their most common unit.
# create means to plot
# mean1 <- aggregate( ~l tenure, land, mean)
# median1 <- aggregate(q7 ~ tenure, land, median)
land %>% select(rent_monthly, ll_size2, q70) %>% na.omit() %>%
ggplot(aes(x=q70,
y=rent_monthly,
color=ll_size2)) +
geom_point() +
geom_jitter(height = 0.3, alpha=0.3) +
geom_hline(yintercept=3.5,
color = "red", size=0.7) +
labs(y = "Monthly Rent",
x = "Most Common Unit",
title = "Landlord size, monthly rent, and most common unit",
subtitle = "Red line indicates binary cutoff >$1,500*") +
theme(axis.text.x = element_text(angle = 15, vjust = 0.9, hjust=1)) +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(rent_raise))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and raised rent",
fill = "Amount raised rent") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% filter(!is.na(rent_raise_market)) %>%
ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(rent_raise_market))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and raised rent due to market",
fill = "Amount raised rent due to market") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% filter(!is.na(terminate_num)) %>%
ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(terminate_num))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and num. of terminations",
fill = "Tenancies Terminated") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% filter(!is.na(terminate_court)) %>%
ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(terminate_court))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and terminate in court",
fill = "Terminate in Court") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 2, label.position = "top", reverse=TRUE))
land %>% filter(!is.na(terminate_court_b)) %>%
ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(as.factor(terminate_court_b)))) +
geom_bar(position="fill") +
labs(y = "Prop",
x = "Landlord size",
title = "Binary terminate in court (w/ court or w/tenant)",
fill = "Terminate in Court") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE))
land %>% ggplot(aes(x=ll_size2,
fill=forcats::fct_rev(zip_region))) +
geom_bar(position='fill') +
labs(y = "Prop",
x = "Landlord size",
title = "Landlord size and terminate in court",
fill = "Terminate in Court") +
coord_flip() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 2, label.position = "top", reverse=TRUE))