title: "Final Project - Report" subtitle: "Effect of Poverty on Housing Affordability" author: "Your Name" output: html_document # ioslides_presentation --- # 1. Introduction ## Overview {.smaller} ***I will be analyzing the amount of population that is Hispanic in the county. I am interested in this topic because I am also Hispanic and I'm interested to see whether ethnicity plays a role in housing prices and affordability when analyzing minorities. ***
## Hypothesis Development {.smaller} ***Does a relationship exist between the Hispanic population and the affordability of housing in the county? Null Hypothesis: The average Hispanic population has NO effect on median house prices at the county level. Alternative Hypothesis: The average Hispanic population DOES have an effect on the median house prices at the county level.***
# 2. Empirical Framework ```{r, message=F, warning=F, echo=F} #Load in libraries library(tidycensus) library(tidyverse) library(plyr) library(stargazer) library(corrplot) library(purrr) ``` ```{r echo=F, message=F, quietly=T} library(tidycensus) census_key <- "8eab9b16f44cb26460ecbde164482194b7052772" census_api_key(census_key) ``` ```{r, message=F, warning=F, echo=F} #Create your list of variables variables = c( HousePrice = 'B25077_001', # Median Value of Housing Units HHIncome = 'B19013_001', # Median household Income #Explanatory Variables Below below_poverty = 'B05010_002', total_pop ='B01001_001', pop_white = 'B01001H_001', # not hispanic pop_black = 'B01001B_001', pop_hispanic = 'B01001I_001', speak_english = 'B06007_002', speak_spanish = 'B06007_003', bachelors = 'B06008_002', married = 'B06008_003', no_hs = 'B06009_002', hs = 'B06009_003', bach_degree = 'B06009_005', grad_degree = 'B06009_006') ``` ```{r, message=F, warning=F, echo=F} #Load in census data CensusDF <- get_acs(geography="county", year=2017, survey="acs5", variables= variables, geometry=F) ``` ```{r, message=F, warning=F, echo=F} CensusDF <- CensusDF %>% select(-moe) %>% #Removes MOE variable spread(variable, estimate) %>% #Converts data from long to wide mutate( # Creates new variable Home_Affordability = HousePrice/HHIncome, # Dependent Variable below_poverty = below_poverty/ total_pop, bach_degree = bach_degree / total_pop, bachelors = bachelors / total_pop, grad_degree = grad_degree / total_pop, hs = hs / total_pop, married = married / total_pop, no_hs = no_hs / total_pop, pop_black = pop_black / total_pop, pop_hispanic = pop_hispanic / total_pop, pop_white = pop_white / total_pop, speak_english = speak_english / total_pop, speak_spanish = speak_spanish / total_pop) ``` ## Data Description {.smaller} ***EDIT ME***
## View Data {.smaller} ```{r, message=F, warning=F, echo=F} head(CensusDF[,c("Home_Affordability","below_poverty")]) ```
***EDIT ME***
# 3. Descriptive Results {.smaller} ```{r,message=F, warning=F, echo=F} CensusDF<-as.data.frame(CensusDF) ReportThese<-c("Home_Affordability","below_poverty", "no_hs","hs","bach_degree","bachelors","grad_degree", "pop_hispanic","pop_white","pop_black", "speak_english","speak_spanish","married") ``` ## 5-point summary {.smaller} ```{r, results='asis',message=F, warning=F, fig.width = 9,fig.align='center', echo=F } #Visualize 5-point summary stargazer(CensusDF[,ReportThese], omit.summary.stat = c("p25", "p75"), nobs=F, type="html") # For a pdf document, replace html with latex ```
***EDIT ME***
## Histogram {.smaller} ```{r,message=F, warning=F, echo=F} #Histogram CensusDF %>% keep(is.numeric) %>% gather() %>% ggplot(aes(value)) + facet_wrap(~ key, scales = "free") + geom_histogram() ```
***EDIT ME***
## Histogram after Log-Transformation {.smaller} ```{r,message=F, warning=F, echo=F} #Log transformation CensusDF %>% keep(is.numeric) %>% gather() %>% ggplot(aes(log(value+1))) + facet_wrap(~ key, scales = "free") + geom_histogram() ```
***EDIT ME***
## Correlation Plot {.smaller} ```{r, message=F, warning=F, echo=F} #Remove NAs CensusDF<-na.omit(CensusDF) ##save correlations in train_cor train_cor <- cor(CensusDF[,ReportThese ]) ##Correlation Plot corrplot(train_cor, type='lower') ```
***EDIT ME***
# 4. Map Results {.smaller} ## ```{r, message=F, warning=F, quietly=T, results='hide', echo=F} #Create your list of variables variablesNew = c( HousePrice = 'B25077_001', # Median Value of Housing Units HHIncome = 'B19013_001' # Median household Income ) #Load in census data CensusSp <- get_acs(geography="county", year=2017, survey="acs5", variables= variablesNew, geometry=T, shift_geo = T) #Data Wrangling CensusSp <- CensusSp %>% select(-moe) %>% #Removes MOE variable spread(variable, estimate) %>% #Converts data from long to wide mutate( # Creates new variable Home_Affordability = HousePrice/HHIncome) # Dependent Variable #Map MapFig<-ggplot(CensusSp, aes(fill=Home_Affordability)) + geom_sf(color="white") + theme_void() + theme(panel.grid.major = element_line(colour = 'transparent')) + scale_fill_distiller(palette="Reds", direction=1, name="House Price to Income Ratio") + labs(title="Home_Affordability in US counties", caption="Source: US Census/ACS5 2017") MapFig ```
***EDIT ME***
# 5. Regression Model Results ## {.smaller} ```{r, results='asis',message=F, warning=F, echo=F, fig.align='center'} reg1<-lm(log(Home_Affordability+1) ~ log(below_poverty+1) , data=CensusDF) reg2<-lm(log(Home_Affordability+1) ~ log(below_poverty+1) + log(no_hs+1) + log(hs+1) + log(bachelors+1) , data=CensusDF) reg3<-lm(log(Home_Affordability+1) ~ log(below_poverty+1) + log(no_hs+1) + log(hs+1) + log(bachelors+1) + log(married+1) + log(pop_black+1) + log(pop_hispanic+1) + log(pop_white+1) , data=CensusDF) #present results with stargazer library(stargazer) stargazer(reg1, reg2, reg3, title="Effect of Local Poverty on Housing Affordability",type='html',align=TRUE) # For a pdf document, replace html with latex ```
## Summary of Main Findings {.smaller} ***EDIT ME***
# Conclusion ## Summary of Findings and Policy Implications ***EDIT ME***
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme