Residential segregation and income inequality

r = getOption("repos")
r["CRAN"] = "http://cran.us.r-project.org"
options(repos = r)

install.packages("tidyverse")
## Installing package into 'C:/Users/canda/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'tidyverse' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\canda\AppData\Local\Temp\RtmpE13hFf\downloaded_packages
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
library(stats)
library(car)
## Loading required package: carData
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:car':
## 
##     recode
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
library(lavaan)
## Warning: package 'lavaan' was built under R version 4.3.2
## This is lavaan 0.6-17
## lavaan is FREE software! Please report any bugs.
cities <- read.csv('C:/Users/canda/DEM Dissertation Data/citiesALLYRS.csv', na.strings=c("NA"))
cities <- cities %>% mutate_if(is.character, as.numeric)
## Warning: There were 25 warnings in `mutate()`.
## The first warning was:
## ℹ In argument: `cityname = .Primitive("as.double")(cityname)`.
## Caused by warning:
## ! NAs introduced by coercion
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 24 remaining warnings.
cities$Proximity<-as.factor(ifelse(cities$Proximity==1, "In Proximity", "Not in Prox"))
stargazer(cities, header=FALSE, type='text', title="Descriptive Statistics",digits=2, out="Descript.htm")
## 
## Descriptive Statistics
## ===================================================
## Statistic  N    Mean     St. Dev.   Min      Max   
## ---------------------------------------------------
## Miles     114   6.50       5.53     0.00    21.00  
## gini_20   262   0.42       0.05     0.29    0.54   
## gini_10   264   0.42       0.06     0.26    0.57   
## pboo_20   262   8.42      10.61     0.00    67.12  
## pboo_10   240   8.58      11.03     0.05    65.63  
## pboo_00   256   7.07       9.08     0.00    61.00  
## pboo_90   257   6.45       8.59     0.00    60.64  
## pboo_80   241   5.32       7.07     0.00    33.94  
## chg_t20   235 10,355.00 24,403.75  -3,487  205,129 
## chg_pb20  235   1.08       2.36    -8.59    15.95  
## t_20      261 75,666.40 207,759.00 10,070 2,304,580
## pb_20     261   12.15     11.86     0.03    71.27  
## dbw_20    261   25.38     12.07     0.00    69.14  
## chg_t10   204 12,128.63 26,631.64  -9,504  206,512 
## chg_pb10  204   1.36       3.65    -8.32    23.16  
## t_10      240 70,884.63 194,929.20 10,127 2,099,451
## pb_10     240   11.39     12.10     0.03    69.35  
## dbw_10    240   27.19     14.07     0.00    82.22  
## chg_t00   174 13,749.87 36,706.30  -2,072  323,078 
## chg_pb00  174   1.23       3.85    -5.08    25.02  
## t_00      204 68,784.74 190,685.10 10,302 1,953,631
## pb_00     204   10.19     10.99     0.03    57.26  
## dbw_00    204   30.84     15.98     0.00    75.64  
## chg_t90   153 9,878.79  22,303.25  -4,247  150,053 
## chg_pb90  153   1.49       4.02    -5.08    24.12  
## t_90      180 62,714.99 167,886.90 10,023 1,630,553
## pb_90     180   9.46      10.45     0.00    60.56  
## dbw_90    180   34.40     18.49     0.00    80.76  
## t_80      154 60,676.74 165,936.10 10,197 1,595,138
## pb_80     154   8.62       9.85     0.01    40.12  
## dbw_80    154   43.36     22.13     0.00    93.17  
## ---------------------------------------------------
stargazer(cities[c("pboo_20","t_20","pb_20","dbw_20")], header=FALSE, type='text', 
          title="Descriptive Statistics", digits=2,
          covariate.labels=c("Black Homeownership","City Population","Percent Black Population","B-W Dissimilarity"),
          out="Desc20.htm"
          )
## 
## Descriptive Statistics
## ==================================================================
## Statistic                 N    Mean     St. Dev.   Min      Max   
## ------------------------------------------------------------------
## Black Homeownership      262   8.42      10.61     0.00    67.12  
## City Population          261 75,666.40 207,759.00 10,070 2,304,580
## Percent Black Population 261   12.15     11.86     0.03    71.27  
## B-W Dissimilarity        261   25.38     12.07     0.00    69.14  
## ------------------------------------------------------------------
stargazer(cities[c("pboo_10","t_10","pb_10","dbw_10")], header=FALSE, type='text', 
          title="Descriptive Statistics 2010", digits=2,
          covariate.labels=c("Black Homeownership","City Population","Percent Black Population","B-W Dissimilarity"),
          out="Desc 2010.htm"
          )
## 
## Descriptive Statistics 2010
## ==================================================================
## Statistic                 N    Mean     St. Dev.   Min      Max   
## ------------------------------------------------------------------
## Black Homeownership      240   8.58      11.03     0.05    65.63  
## City Population          240 70,884.63 194,929.20 10,127 2,099,451
## Percent Black Population 240   11.39     12.10     0.03    69.35  
## B-W Dissimilarity        240   27.19     14.07     0.00    82.22  
## ------------------------------------------------------------------
stargazer(cities[c("pboo_00","t_00","pb_00","dbw_00")], header=FALSE, type='text', 
          title="Descriptive Statistics 2000", digits=2,
          covariate.labels=c("Black Homeownership","City Population","Percent Black Population","B-W Dissimilarity")
          )
## 
## Descriptive Statistics 2000
## ==================================================================
## Statistic                 N    Mean     St. Dev.   Min      Max   
## ------------------------------------------------------------------
## Black Homeownership      256   7.07       9.08     0.00    61.00  
## City Population          204 68,784.74 190,685.10 10,302 1,953,631
## Percent Black Population 204   10.19     10.99     0.03    57.26  
## B-W Dissimilarity        204   30.84     15.98     0.00    75.64  
## ------------------------------------------------------------------
stargazer(cities[c("pboo_90","t_90","pb_90","dbw_90")], header=FALSE, type='text', 
          title="Descriptive Statistics 1990", digits=2,
          covariate.labels=c("Black Homeownership","City Population","Percent Black Population","B-W Dissimilarity")
          )
## 
## Descriptive Statistics 1990
## ==================================================================
## Statistic                 N    Mean     St. Dev.   Min      Max   
## ------------------------------------------------------------------
## Black Homeownership      257   6.45       8.59     0.00    60.64  
## City Population          180 62,714.99 167,886.90 10,023 1,630,553
## Percent Black Population 180   9.46      10.45     0.00    60.56  
## B-W Dissimilarity        180   34.40     18.49     0.00    80.76  
## ------------------------------------------------------------------
stargazer(cities[c("pboo_80","t_80","pb_80","dbw_80")], header=FALSE, type='text', 
          title="Descriptive Statistics 1980", digits=2,
         covariate.labels=c("Black Homeownership","City Population","Percent Black Population","B-W Dissimilarity")
          )
## 
## Descriptive Statistics 1980
## ==================================================================
## Statistic                 N    Mean     St. Dev.   Min      Max   
## ------------------------------------------------------------------
## Black Homeownership      241   5.32       7.07     0.00    33.94  
## City Population          154 60,676.74 165,936.10 10,197 1,595,138
## Percent Black Population 154   8.62       9.85     0.01    40.12  
## B-W Dissimilarity        154   43.36     22.13     0.00    93.17  
## ------------------------------------------------------------------
object <- sapply(cities, function(x) sum(is.na(x)))


#Cities In Proximity = 1, Cities Not in Proximity = 0

cities$Proximity <- factor(cities$Proximity, ordered = FALSE )# Make "Not in Proximity" the reference category
cities$Proximity <- relevel(cities$Proximity, ref = "Not in Prox")
table(cities$Proximity)
## 
##  Not in Prox In Proximity 
##          162          107
Count of missing values of Percent Black Homeownership for cities 2020 (pboo_20) = 11, 2010 (pboo_10) = 31, 2000 (pboo_00) = 14, 1990 (pboo_90) = 90, 1980 (pboo_80) = 115

#log total population due to outliers

hist(cities$t_20)

hist(log(cities$t_20+1), breaks=50)

hist(cities$t_10)

hist(log(cities$t_10+1), breaks=50)

hist(cities$t_00)

hist(log(cities$t_00+1), breaks=50)

hist(cities$t_90)

hist(log(cities$t_90+1), breaks=50)

hist(cities$t_80)

hist(log(cities$t_80+1), breaks=50)

## Racial residential segregation and proximity to freedom colonies

#The correlation between segregation and Black home ownership yielded a weak positive association in all years with a coefficient of 0.0363 in 2020, 0.0815 in 2010, and 0.2355 in 2000.

cor.test(cities$dbw_20,cities$pboo_20)
## 
##  Pearson's product-moment correlation
## 
## data:  cities$dbw_20 and cities$pboo_20
## t = 0.50531, df = 259, p-value = 0.6138
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.09038165  0.15222271
## sample estimates:
##        cor 
## 0.03138275
plot(cities$dbw_20,cities$pboo_20,pch=20,
     xlab='D index',ylab='Percent Black Homeowners',
     main='Cities by Residential Segregation and Black Homeownership in 2020')

cor.test(cities$dbw_10,cities$pboo_10)
## 
##  Pearson's product-moment correlation
## 
## data:  cities$dbw_10 and cities$pboo_10
## t = 1.3949, df = 238, p-value = 0.1644
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.03700425  0.21423467
## sample estimates:
##        cor 
## 0.09004761
plot(cities$dbw_10,cities$pboo_10,pch=20,
     xlab='D index',ylab='Percent Black Homeowners',
     main='Cities by Residential Segregation and Black Homeownership in 2010')

cor.test(cities$dbw_00,cities$pboo_00)
## 
##  Pearson's product-moment correlation
## 
## data:  cities$dbw_00 and cities$pboo_00
## t = 4.093, df = 198, p-value = 6.198e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1462256 0.4024463
## sample estimates:
##       cor 
## 0.2793003
plot(cities$dbw_00,cities$pboo_00,pch=20,
     xlab='D index',ylab='Percent Black Homeowners',
     main='Cities by Residential Segregation and Black Homeownership in 2000')

cor.test(cities$dbw_90,cities$pboo_90)
## 
##  Pearson's product-moment correlation
## 
## data:  cities$dbw_90 and cities$pboo_90
## t = 5.3203, df = 177, p-value = 3.103e-07
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2375754 0.4912287
## sample estimates:
##       cor 
## 0.3713092
plot(cities$dbw_90,cities$pboo_90,pch=20,
     xlab='D index',ylab='Percent Black Homeowners',
     main='Cities by Residential Segregation and Black Homeownership in 1990')

cor.test(cities$dbw_80,cities$pboo_80)
## 
##  Pearson's product-moment correlation
## 
## data:  cities$dbw_80 and cities$pboo_80
## t = 5.1751, df = 152, p-value = 7.102e-07
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2438040 0.5137519
## sample estimates:
##       cor 
## 0.3870404
plot(cities$dbw_80,cities$pboo_80,pch=20,
     xlab='D index',ylab='Percent Black Homeowners',
     main='Cities by Residential Segregation and Black Homeownership in 1980')

#The list of cities from the Diversity and Disparities project available for years 1980 - 2020 was used to conduct a binomial regression analysis. Of these cities, 107 were identified as being in proximity to a freedom colony and 165 were not.

table(cities$Proximity)
## 
##  Not in Prox In Proximity 
##          162          107

#The results showed that proximity to freedom colonies INCREASED residential segregation by points in 2020. The results were statistically significant in 2000, but not in 2020, 2010, 1990, or 1980.

fit20=lm(dbw_20 ~ Proximity,cities)
summary(fit20)
## 
## Call:
## lm(formula = dbw_20 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -25.847  -9.357  -0.886   8.475  44.775 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             24.364      0.951  25.618   <2e-16 ***
## ProximityIn Proximity    2.625      1.529   1.717   0.0872 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.03 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.01125,    Adjusted R-squared:  0.007434 
## F-statistic: 2.947 on 1 and 259 DF,  p-value: 0.08722
fit10=lm(dbw_10 ~ Proximity,cities)
summary(fit10)
## 
## Call:
## lm(formula = dbw_10 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -28.626 -10.226  -1.895   8.190  56.010 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             26.206      1.179  22.233   <2e-16 ***
## ProximityIn Proximity    2.420      1.845   1.312    0.191    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.05 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.00718,    Adjusted R-squared:  0.003008 
## F-statistic: 1.721 on 1 and 238 DF,  p-value: 0.1908
fit00=lm(dbw_00 ~ Proximity,cities)
summary(fit00)
## 
## Call:
## lm(formula = dbw_00 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -30.194 -11.511  -1.039  10.575  41.698 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             28.809      1.426  20.197   <2e-16 ***
## ProximityIn Proximity    5.128      2.264   2.265   0.0246 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.82 on 202 degrees of freedom
##   (65 observations deleted due to missingness)
## Multiple R-squared:  0.02478,    Adjusted R-squared:  0.01995 
## F-statistic: 5.132 on 1 and 202 DF,  p-value: 0.02455
fit90=lm(dbw_90 ~ Proximity,cities)
summary(fit90)
## 
## Call:
## lm(formula = dbw_90 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -36.428 -13.894  -0.428  16.099  43.493 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             32.584      1.754  18.578   <2e-16 ***
## ProximityIn Proximity    4.681      2.812   1.664   0.0978 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 18.39 on 178 degrees of freedom
##   (89 observations deleted due to missingness)
## Multiple R-squared:  0.01532,    Adjusted R-squared:  0.009793 
## F-statistic:  2.77 on 1 and 178 DF,  p-value: 0.09779
fit80=lm(dbw_80 ~ Proximity,cities)
summary(fit80)
## 
## Call:
## lm(formula = dbw_80 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -41.083 -13.257  -0.672  13.301  49.413 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             41.083      2.271  18.094   <2e-16 ***
## ProximityIn Proximity    5.835      3.638   1.604    0.111    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 22.01 on 152 degrees of freedom
##   (115 observations deleted due to missingness)
## Multiple R-squared:  0.01665,    Adjusted R-squared:  0.01018 
## F-statistic: 2.573 on 1 and 152 DF,  p-value: 0.1108

#Alternatively, I used Proximity as the dependent (outcome) variable. The results showed that residential segregation INCREASED proximity by 0.0224 points in 2020. The results were statistically significant. The results were statistically significant in 2020 and 2000, but not in 2010.

model20 = glm(Proximity ~ dbw_20,
            data = cities,
            family = binomial(link="logit"))
model10 = glm(Proximity ~ dbw_10,
            data = cities,
            family = binomial(link="logit"))
model00 = glm(Proximity ~ dbw_00,
            data = cities,
            family = binomial(link="logit"))
model90 = glm(Proximity ~ dbw_90,
            data = cities,
            family = binomial(link="logit"))
model80 = glm(Proximity ~ dbw_80,
            data = cities,
            family = binomial(link="logit"))
summary(model20)
## 
## Call:
## glm(formula = Proximity ~ dbw_20, family = binomial(link = "logit"), 
##     data = cities)
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)   
## (Intercept) -0.92335    0.30305  -3.047  0.00231 **
## dbw_20       0.01806    0.01061   1.702  0.08877 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 348.37  on 260  degrees of freedom
## Residual deviance: 345.44  on 259  degrees of freedom
##   (8 observations deleted due to missingness)
## AIC: 349.44
## 
## Number of Fisher Scoring iterations: 4
summary(model10)
## 
## Call:
## glm(formula = Proximity ~ dbw_10, family = binomial(link = "logit"), 
##     data = cities)
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)  
## (Intercept) -0.706519   0.290099  -2.435   0.0149 *
## dbw_10       0.012254   0.009374   1.307   0.1912  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 324.60  on 239  degrees of freedom
## Residual deviance: 322.88  on 238  degrees of freedom
##   (29 observations deleted due to missingness)
## AIC: 326.88
## 
## Number of Fisher Scoring iterations: 4
summary(model00)
## 
## Call:
## glm(formula = Proximity ~ dbw_00, family = binomial(link = "logit"), 
##     data = cities)
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)   
## (Intercept) -1.055615   0.324821  -3.250  0.00115 **
## dbw_00       0.020365   0.009159   2.224  0.02618 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 274.09  on 203  degrees of freedom
## Residual deviance: 269.03  on 202  degrees of freedom
##   (65 observations deleted due to missingness)
## AIC: 273.03
## 
## Number of Fisher Scoring iterations: 4
summary(model90)
## 
## Call:
## glm(formula = Proximity ~ dbw_90, family = binomial(link = "logit"), 
##     data = cities)
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)   
## (Intercept) -0.936893   0.335291  -2.794   0.0052 **
## dbw_90       0.013888   0.008409   1.651   0.0986 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 240.57  on 179  degrees of freedom
## Residual deviance: 237.80  on 178  degrees of freedom
##   (89 observations deleted due to missingness)
## AIC: 241.8
## 
## Number of Fisher Scoring iterations: 4
summary(model80)
## 
## Call:
## glm(formula = Proximity ~ dbw_80, family = binomial(link = "logit"), 
##     data = cities)
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)   
## (Intercept) -0.983357   0.379342  -2.592  0.00953 **
## dbw_80       0.012146   0.007637   1.590  0.11172   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 205.92  on 153  degrees of freedom
## Residual deviance: 203.34  on 152  degrees of freedom
##   (115 observations deleted due to missingness)
## AIC: 207.34
## 
## Number of Fisher Scoring iterations: 4
Anova(model20,
      type="II",
      test="LR")
## Analysis of Deviance Table (Type II tests)
## 
## Response: Proximity
##        LR Chisq Df Pr(>Chisq)  
## dbw_20    2.929  1      0.087 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(model10,
      type="II",
      test="LR")
## Analysis of Deviance Table (Type II tests)
## 
## Response: Proximity
##        LR Chisq Df Pr(>Chisq)
## dbw_10   1.7182  1     0.1899
Anova(model00,
      type="II",
      test="LR")
## Analysis of Deviance Table (Type II tests)
## 
## Response: Proximity
##        LR Chisq Df Pr(>Chisq)  
## dbw_00   5.0661  1     0.0244 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(model90,
      type="II",
      test="LR")
## Analysis of Deviance Table (Type II tests)
## 
## Response: Proximity
##        LR Chisq Df Pr(>Chisq)  
## dbw_90   2.7681  1    0.09616 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(model80,
      type="II",
      test="LR")
## Analysis of Deviance Table (Type II tests)
## 
## Response: Proximity
##        LR Chisq Df Pr(>Chisq)
## dbw_80   2.5792  1     0.1083

Proximity to freedom colonies and homeownership

install.packages("ggcorrplot")
## Installing package into 'C:/Users/canda/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'ggcorrplot' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\canda\AppData\Local\Temp\RtmpE13hFf\downloaded_packages
library(ggcorrplot)
## Warning: package 'ggcorrplot' was built under R version 4.3.2
library(ggplot2)

#Change proximity to numeric to run correlation matrix

cities <- cities %>% mutate_if(is.character, as.numeric)
cities <- cities %>% mutate_if(is.integer, as.numeric)
cities <- cities %>% mutate_if(is.factor, as.numeric)
cities$t_20 <- log(cities$t_20)

cor_matrix <- cor(cities, use = "pairwise.complete.obs", method = "pearson") %>% 
  ggcorrplot(show.diag=FALSE, type="lower", lab=TRUE, lab_size=2)

print(cor_matrix)

df <- data.frame(cities)

sel20_vars <- c("pboo_20", "t_20","pb_20", "dbw_20")
df_select20 <- df[sel20_vars]

cor_matrix20 <- cor(df_select20, use = "pairwise.complete.obs", method = "pearson") %>% 
  ggcorrplot(show.diag=FALSE, type="lower", lab=TRUE, lab_size=4)

print(cor_matrix20)

df <- data.frame(cities)

sel80_vars <- c("pboo_80", "t_80","pb_80", "dbw_80")
df_select80 <- df[sel80_vars]

cor_matrix80 <- cor(df_select80, use = "pairwise.complete.obs", method = "pearson") %>% 
  ggcorrplot(show.diag=FALSE, type="lower", lab=TRUE, lab_size=4)

print(cor_matrix80)

#Run regression with Logged Total city population on Dissimilarity Index/segregation. Significance in all years.

tpop20Bw<- lm(cities$dbw_20 ~ log(cities$t_20))
summary(tpop20Bw)
## 
## Call:
## lm(formula = cities$dbw_20 ~ log(cities$t_20))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -21.249  -8.383  -1.475   7.285  47.127 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       -88.616     17.436  -5.082 7.15e-07 ***
## log(cities$t_20)   48.757      7.452   6.543 3.21e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.21 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.1418, Adjusted R-squared:  0.1385 
## F-statistic: 42.81 on 1 and 259 DF,  p-value: 3.206e-10
coef(tpop20Bw)["log(cities$t_20)"]/100
## log(cities$t_20) 
##        0.4875671
tpop10Bw<- lm(cities$dbw_10 ~ log(cities$t_10))
summary(tpop10Bw)
## 
## Call:
## lm(formula = cities$dbw_10 ~ log(cities$t_10))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -23.292 -10.468  -1.869   9.094  59.568 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      -22.0642     8.8422  -2.495   0.0133 *  
## log(cities$t_10)   4.7609     0.8506   5.597 5.98e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.25 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.1163, Adjusted R-squared:  0.1126 
## F-statistic: 31.33 on 1 and 238 DF,  p-value: 5.984e-08
coef(tpop10Bw)["log(cities$t_10)"]/100
## log(cities$t_10) 
##       0.04760936
tpop00Bw<- lm(cities$dbw_00 ~ log(cities$t_00))
summary(tpop00Bw)
## 
## Call:
## lm(formula = cities$dbw_00 ~ log(cities$t_00))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -26.161 -12.766  -0.462  11.450  48.520 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       -17.146     11.352  -1.510    0.133    
## log(cities$t_00)    4.650      1.095   4.247 3.31e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.35 on 202 degrees of freedom
##   (65 observations deleted due to missingness)
## Multiple R-squared:  0.08196,    Adjusted R-squared:  0.07741 
## F-statistic: 18.03 on 1 and 202 DF,  p-value: 3.31e-05
coef(tpop00Bw)["log(cities$t_00)"]/100
## log(cities$t_00) 
##       0.04650091
tpop90Bw<- lm(cities$dbw_90 ~ log(cities$t_90))
summary(tpop90Bw)
## 
## Call:
## lm(formula = cities$dbw_90 ~ log(cities$t_90))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -32.940 -14.795  -1.112  12.803  50.992 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       -24.070     14.039  -1.714   0.0882 .  
## log(cities$t_90)    5.707      1.364   4.184  4.5e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 17.69 on 178 degrees of freedom
##   (89 observations deleted due to missingness)
## Multiple R-squared:  0.08952,    Adjusted R-squared:  0.08441 
## F-statistic:  17.5 on 1 and 178 DF,  p-value: 4.501e-05
coef(tpop90Bw)["log(cities$t_90)"]/100
## log(cities$t_90) 
##       0.05707379
tpop80Bw<- lm(cities$dbw_80 ~ log(cities$t_80))
summary(tpop80Bw)
## 
## Call:
## lm(formula = cities$dbw_80 ~ log(cities$t_80))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -35.822 -15.178  -0.748  13.757  56.499 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       -53.636     17.075  -3.141  0.00202 ** 
## log(cities$t_80)    9.516      1.668   5.706 5.86e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 20.15 on 152 degrees of freedom
##   (115 observations deleted due to missingness)
## Multiple R-squared:  0.1764, Adjusted R-squared:  0.171 
## F-statistic: 32.56 on 1 and 152 DF,  p-value: 5.862e-08
coef(tpop80Bw)["log(cities$t_80)"]/100
## log(cities$t_80) 
##       0.09515862

#Run regression with percent Black population on dissimilarity. Significance 2000 1990 1980

dbwpb20<- lm(dbw_20~pb_20,data=cities)
dbwpb10<- lm(dbw_10~pb_10,data=cities)
dbwpb00<- lm(dbw_00~pb_00,data=cities)
dbwpb90<- lm(dbw_90~pb_90,data=cities)
dbwpb80<- lm(dbw_80~pb_80,data=cities)
summary(dbwpb20)
## 
## Call:
## lm(formula = dbw_20 ~ pb_20, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -24.846  -9.002  -1.198   8.473  44.769 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 24.36207    1.06964  22.776   <2e-16 ***
## pb_20        0.08374    0.06307   1.328    0.185    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.06 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.006759,   Adjusted R-squared:  0.002924 
## F-statistic: 1.763 on 1 and 259 DF,  p-value: 0.1855
summary(dbwpb10)
## 
## Call:
## lm(formula = dbw_10 ~ pb_10, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -28.356 -10.320  -1.567   8.283  56.869 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 25.34306    1.23814  20.469   <2e-16 ***
## pb_10        0.16254    0.07459   2.179   0.0303 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.96 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.01956,    Adjusted R-squared:  0.01544 
## F-statistic: 4.749 on 1 and 238 DF,  p-value: 0.0303
summary(dbwpb00)
## 
## Call:
## lm(formula = dbw_00 ~ pb_00, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -32.280 -10.620  -0.125   9.506  43.200 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 26.04976    1.44882  17.980  < 2e-16 ***
## pb_00        0.47047    0.09678   4.861 2.34e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.16 on 202 degrees of freedom
##   (65 observations deleted due to missingness)
## Multiple R-squared:  0.1047, Adjusted R-squared:  0.1003 
## F-statistic: 23.63 on 1 and 202 DF,  p-value: 2.339e-06
summary(dbwpb90)
## 
## Call:
## lm(formula = dbw_90 ~ pb_90, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -44.682 -13.477   0.299  12.288  34.532 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  28.0713     1.7271  16.254  < 2e-16 ***
## pb_90         0.6695     0.1227   5.456 1.61e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 17.16 on 178 degrees of freedom
##   (89 observations deleted due to missingness)
## Multiple R-squared:  0.1433, Adjusted R-squared:  0.1385 
## F-statistic: 29.77 on 1 and 178 DF,  p-value: 1.611e-07
summary(dbwpb80)
## 
## Call:
## lm(formula = dbw_80 ~ pb_80, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -52.393 -12.383   0.966  13.764  54.446 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  35.6242     2.1831  16.318  < 2e-16 ***
## pb_80         0.8968     0.1671   5.367 2.94e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 20.35 on 152 degrees of freedom
##   (115 observations deleted due to missingness)
## Multiple R-squared:  0.1593, Adjusted R-squared:  0.1538 
## F-statistic:  28.8 on 1 and 152 DF,  p-value: 2.939e-07

#Run regression with dissimilarity on percent Black population. Significance 2000 1990 1980

pbw20=lm(pb_20 ~ dbw_20,cities)
summary(pbw20)
## 
## Call:
## lm(formula = pb_20 ~ dbw_20, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -15.580  -8.156  -3.711   5.042  59.449 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 10.09991    1.70821   5.913 1.06e-08 ***
## dbw_20       0.08072    0.06080   1.328    0.185    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.84 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.006759,   Adjusted R-squared:  0.002924 
## F-statistic: 1.763 on 1 and 259 DF,  p-value: 0.1855
pbw10=lm(pb_10 ~ dbw_10,cities)
summary(pbw10)
## 
## Call:
## lm(formula = pb_10 ~ dbw_10, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -17.984  -7.739  -3.999   4.522  58.733 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  8.11335    1.69023   4.800  2.8e-06 ***
## dbw_10       0.12036    0.05523   2.179   0.0303 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.01 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.01956,    Adjusted R-squared:  0.01544 
## F-statistic: 4.749 on 1 and 238 DF,  p-value: 0.0303
pbw00=lm(pb_00 ~ dbw_00,cities)
summary(pbw00)
## 
## Call:
## lm(formula = pb_00 ~ dbw_00, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -18.679  -6.716  -2.667   3.797  47.517 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.32507    1.59001   2.091   0.0378 *  
## dbw_00       0.22262    0.04579   4.861 2.34e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.43 on 202 degrees of freedom
##   (65 observations deleted due to missingness)
## Multiple R-squared:  0.1047, Adjusted R-squared:  0.1003 
## F-statistic: 23.63 on 1 and 202 DF,  p-value: 2.339e-06
pbw90=lm(pb_90 ~ dbw_90,cities)
summary(pbw90)
## 
## Call:
## lm(formula = pb_90 ~ dbw_90, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -14.556  -6.398  -2.256   2.475  53.338 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.09644    1.53108   1.369    0.173    
## dbw_90       0.21403    0.03923   5.456 1.61e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.701 on 178 degrees of freedom
##   (89 observations deleted due to missingness)
## Multiple R-squared:  0.1433, Adjusted R-squared:  0.1385 
## F-statistic: 29.77 on 1 and 178 DF,  p-value: 1.611e-07
pbw80=lm(pb_80 ~ dbw_80,cities)
summary(pbw80)
## 
## Call:
## lm(formula = pb_80 ~ dbw_80, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -16.520  -5.913  -2.988   2.842  32.689 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.9204     1.6100   0.572    0.568    
## dbw_80        0.1776     0.0331   5.367 2.94e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.059 on 152 degrees of freedom
##   (115 observations deleted due to missingness)
## Multiple R-squared:  0.1593, Adjusted R-squared:  0.1538 
## F-statistic:  28.8 on 1 and 152 DF,  p-value: 2.939e-07
cities$Proximity<-as.factor(ifelse(cities$Proximity==1, "In Proximity", "Not in Prox"))
str(cities)
## 'data.frame':    269 obs. of  34 variables:
##  $ cityname : num  NA NA NA NA NA NA NA NA NA NA ...
##  $ Proximity: Factor w/ 2 levels "In Proximity",..: 1 2 1 1 1 1 2 1 1 1 ...
##  $ Miles    : num  NA 3 NA NA NA NA 13.7 NA NA NA ...
##  $ FC.name  : num  NA NA NA NA NA NA NA NA NA NA ...
##  $ gini_20  : num  0.45 0.395 0.461 0.423 0.471 0.39 0.456 0.417 0.469 0.44 ...
##  $ gini_10  : num  0.45 0.475 0.42 0.411 0.456 0.358 0.424 0.436 0.457 0.523 ...
##  $ pboo_20  : num  4.74 4.08 0.26 3.13 0.65 6.5 0.13 2.73 3.56 1.08 ...
##  $ pboo_10  : num  4.73 2.53 0.19 3.31 0.57 7.01 0.19 1.49 3.69 1.53 ...
##  $ pboo_00  : num  4.68 1.73 0 4.42 0.48 3.58 0 1.15 3.76 2.69 ...
##  $ pboo_90  : num  5.34 6.51 0 2.63 0.72 2.68 0 0.9 4.06 2.46 ...
##  $ pboo_80  : num  4.36 4.23 0 0.21 0.97 2.14 0 1.03 3.77 2.13 ...
##  $ chg_t20  : num  8119 3605 1140 130 -1213 ...
##  $ chg_pb20 : num  1.34343 5.30048 0.00392 -0.40411 0.14071 ...
##  $ t_20     : num  11.74 9.72 9.88 9.68 9.79 ...
##  $ pb_20    : num  11.36 17.364 0.2 2.406 0.732 ...
##  $ dbw_20   : num  28.7 25 35.3 32.8 38.2 ...
##  $ chg_t10  : num  1133 -1110 3593 1890 94 ...
##  $ chg_pb10 : num  0.925 2.265 0.081 -2.991 -0.15 ...
##  $ t_10     : num  117063 13056 18353 15869 19104 ...
##  $ pb_10    : num  10.017 12.063 0.196 2.811 0.591 ...
##  $ dbw_10   : num  34.8 21.4 55.3 36 27.6 ...
##  $ chg_t00  : num  9276 NA NA 2846 -778 ...
##  $ chg_pb00 : num  2.2753 NA NA 2.1368 -0.0416 ...
##  $ t_00     : num  115930 14166 14760 13979 19010 ...
##  $ pb_00    : num  9.092 9.798 0.115 5.802 0.742 ...
##  $ dbw_00   : num  37.7 38.8 23.4 28.7 27.4 ...
##  $ chg_t90  : num  8339 NA NA -1490 -1173 ...
##  $ chg_pb90 : num  0.2325 NA NA 1.5337 -0.0707 ...
##  $ t_90     : num  106654 NA NA 11133 19788 ...
##  $ pb_90    : num  6.816 NA NA 3.665 0.783 ...
##  $ dbw_90   : num  38.1 NA NA 24.7 41.2 ...
##  $ t_80     : num  98315 NA NA 12623 20961 ...
##  $ pb_80    : num  6.584 NA NA 2.131 0.854 ...
##  $ dbw_80   : num  48.2 NA NA 29.9 52.6 ...

##Logistic Regression

#The models indicate that there is a positive relationship between the percent of Black homeownership and whether the city is within proximity to a freedom colony. Cities with high percent of Black homeowners are more likely to be within proximity to a freedom colony for years 2000, 2010, and 2020.

#model 1 #A multiple regression was performed starting with proximity to freedom colonies (Table 4). This variable proved to yield statistically significant results. Proximity to freedom colonies provided an increase in Black homeownership by 7.935 percentage points.

model1_20<- lm(pboo_20~Proximity,data=cities)
summary(model1_20)
## 
## Call:
## lm(formula = pboo_20 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.791  -5.199  -2.581   2.164  54.199 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            5.6037     0.7887   7.105 1.16e-11 ***
## ProximityNot in Prox   7.3177     1.2703   5.760 2.36e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.01 on 260 degrees of freedom
##   (7 observations deleted due to missingness)
## Multiple R-squared:  0.1132, Adjusted R-squared:  0.1098 
## F-statistic: 33.18 on 1 and 260 DF,  p-value: 2.363e-08

#model 2 - add in total popualtion logged #When the logged variable of city population was introduced in Model 2, there was a slight increase in homeownership although population was not statistically significant. Proximity remained a significant factor.

model2_20 <- lm(pboo_20~Proximity+log(t_20),data=cities)
summary(model2_20)
## 
## Call:
## lm(formula = pboo_20 ~ Proximity + log(t_20), data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.924  -4.983  -2.568   2.154  53.931 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            -9.916     15.652  -0.634    0.527    
## ProximityNot in Prox    7.131      1.283   5.560 6.74e-08 ***
## log(t_20)               6.678      6.711   0.995    0.321    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.02 on 258 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.1155, Adjusted R-squared:  0.1087 
## F-statistic: 16.85 on 2 and 258 DF,  p-value: 1.327e-07

#As established, percent of Black population is highly correlated with Black homeownership. As expected, an initial regression with this variable yielded a significant result, but only a small increase in homeownership. Due to this high correlation, proximity lost its significance when percent of Black population was introduced to the model. Therefore, this variable was omitted from the regression.

citpb20=lm(pboo_20~pb_20,cities)
citpb10=lm(pboo_10~pb_10,cities)
citpb00=lm(pboo_00~pb_00,cities)
citpb90=lm(pboo_90~pb_90,cities)
citpb80=lm(pboo_80~pb_80,cities)
summary(citpb20)
## 
## Call:
## lm(formula = pboo_20 ~ pb_20, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -15.0194  -1.2180   0.5173   1.5513  12.6654 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.9730     0.2680  -7.362 2.41e-12 ***
## pb_20         0.8585     0.0158  54.322  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.021 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.9193, Adjusted R-squared:  0.919 
## F-statistic:  2951 on 1 and 259 DF,  p-value: < 2.2e-16
summary(citpb10)
## 
## Call:
## lm(formula = pboo_10 ~ pb_10, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13.6954  -1.2473   0.3532   1.4362  13.3214 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.4811     0.2406  -6.155 3.17e-09 ***
## pb_10         0.8834     0.0145  60.941  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.713 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.9398, Adjusted R-squared:  0.9395 
## F-statistic:  3714 on 1 and 238 DF,  p-value: < 2.2e-16
summary(citpb00)
## 
## Call:
## lm(formula = pboo_00 ~ pb_00, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -16.5147  -0.8487   0.2933   0.8873  14.6523 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.83415    0.23633   -3.53 0.000518 ***
## pb_00        0.82406    0.01565   52.64  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.441 on 198 degrees of freedom
##   (69 observations deleted due to missingness)
## Multiple R-squared:  0.9333, Adjusted R-squared:  0.933 
## F-statistic:  2771 on 1 and 198 DF,  p-value: < 2.2e-16
summary(citpb90)
## 
## Call:
## lm(formula = pboo_90 ~ pb_90, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -15.9046  -0.7423   0.2832   0.7728   8.9028 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.66915    0.20261  -3.303  0.00116 ** 
## pb_90        0.86542    0.01436  60.287  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.004 on 177 degrees of freedom
##   (90 observations deleted due to missingness)
## Multiple R-squared:  0.9536, Adjusted R-squared:  0.9533 
## F-statistic:  3634 on 1 and 177 DF,  p-value: < 2.2e-16
summary(citpb80)
## 
## Call:
## lm(formula = pboo_80 ~ pb_80, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.9313 -0.4940  0.0426  0.3423  5.6163 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.10014    0.13794  -0.726    0.469    
## pb_80        0.78014    0.01056  73.888   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.286 on 152 degrees of freedom
##   (115 observations deleted due to missingness)
## Multiple R-squared:  0.9729, Adjusted R-squared:  0.9727 
## F-statistic:  5459 on 1 and 152 DF,  p-value: < 2.2e-16

#model 3 add in segregation #In Model 3, the DI measure of residential segregation for each city was added to the regression. Residential segregation caused a decrease in homeownership by -0.029. This result was not statistically significant but provides a different outcome than the previous analysis comparing cities near and not near freedom colonies

m1a <- lm(pboo_20~Proximity,data=cities)
m2a <- lm(pboo_20~Proximity+log(t_20),data=cities)
m3a <- lm(pboo_20~Proximity+log(t_20)+dbw_20,data=cities)

stargazer(m1a, m2a, m3a,
          type="text", title="Regression Results",
          align=TRUE, dep.var.labels=c("Percent Black Homeownership 2020"),
          covariate.labels=c("Proximity","City Population 2020","Dissimilarity Index 2020"),out="main2020.htm")
## 
## Regression Results
## ================================================================================================
##                                                    Dependent variable:                          
##                          -----------------------------------------------------------------------
##                                             Percent Black Homeownership 2020                    
##                                    (1)                     (2)                     (3)          
## ------------------------------------------------------------------------------------------------
## Proximity                       7.318***                7.131***                7.172***        
##                                  (1.270)                 (1.283)                 (1.288)        
##                                                                                                 
## City Population 2020                                      6.678                   7.932         
##                                                          (6.711)                 (7.231)        
##                                                                                                 
## Dissimilarity Index 2020                                                         -0.026         
##                                                                                  (0.056)        
##                                                                                                 
## Constant                        5.604***                 -9.916                  -12.198        
##                                  (0.789)                (15.652)                (16.409)        
##                                                                                                 
## ------------------------------------------------------------------------------------------------
## Observations                       262                     261                     261          
## R2                                0.113                   0.116                   0.116         
## Adjusted R2                       0.110                   0.109                   0.106         
## Residual Std. Error         10.008 (df = 260)       10.021 (df = 258)       10.037 (df = 257)   
## F Statistic              33.183*** (df = 1; 260) 16.848*** (df = 2; 258) 11.272*** (df = 3; 257)
## ================================================================================================
## Note:                                                                *p<0.1; **p<0.05; ***p<0.01
m1a <- lm(pboo_20~Proximity,data=cities)
m2a <- lm(pboo_20~Proximity+log(t_20),data=cities)
m3a <- lm(pboo_20~Proximity+log(t_20)+dbw_20,data=cities)
summary(m1a)
## 
## Call:
## lm(formula = pboo_20 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.791  -5.199  -2.581   2.164  54.199 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            5.6037     0.7887   7.105 1.16e-11 ***
## ProximityNot in Prox   7.3177     1.2703   5.760 2.36e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.01 on 260 degrees of freedom
##   (7 observations deleted due to missingness)
## Multiple R-squared:  0.1132, Adjusted R-squared:  0.1098 
## F-statistic: 33.18 on 1 and 260 DF,  p-value: 2.363e-08
summary(m2a)
## 
## Call:
## lm(formula = pboo_20 ~ Proximity + log(t_20), data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.924  -4.983  -2.568   2.154  53.931 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            -9.916     15.652  -0.634    0.527    
## ProximityNot in Prox    7.131      1.283   5.560 6.74e-08 ***
## log(t_20)               6.678      6.711   0.995    0.321    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.02 on 258 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.1155, Adjusted R-squared:  0.1087 
## F-statistic: 16.85 on 2 and 258 DF,  p-value: 1.327e-07
summary(m3a)
## 
## Call:
## lm(formula = pboo_20 ~ Proximity + log(t_20) + dbw_20, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.866  -4.863  -2.590   2.276  53.731 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          -12.19763   16.40888  -0.743    0.458    
## ProximityNot in Prox   7.17174    1.28753   5.570 6.41e-08 ***
## log(t_20)              7.93160    7.23067   1.097    0.274    
## dbw_20                -0.02623    0.05577  -0.470    0.639    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.04 on 257 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.1163, Adjusted R-squared:  0.106 
## F-statistic: 11.27 on 3 and 257 DF,  p-value: 5.684e-07
m1b <- lm(pboo_10~Proximity,data=cities)
m2b <- lm(pboo_10~Proximity+log(t_10),data=cities)
m3b <- lm(pboo_10~Proximity+log(t_10)+dbw_10,data=cities)
summary(m1b)
## 
## Call:
## lm(formula = pboo_10 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.938  -5.166  -2.531   2.086  52.542 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            5.4656     0.8723   6.266 1.72e-09 ***
## ProximityNot in Prox   7.6226     1.3650   5.584 6.39e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.39 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.1158, Adjusted R-squared:  0.1121 
## F-statistic: 31.18 on 1 and 238 DF,  p-value: 6.385e-08
summary(m2b)
## 
## Call:
## lm(formula = pboo_10 ~ Proximity + log(t_10), data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.161  -4.841  -2.446   2.067  52.513 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -1.3310     6.9367  -0.192    0.848    
## ProximityNot in Prox   7.4978     1.3709   5.469 1.15e-07 ***
## log(t_10)              0.6618     0.6701   0.988    0.324    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.39 on 237 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.1195, Adjusted R-squared:  0.112 
## F-statistic: 16.08 on 2 and 237 DF,  p-value: 2.832e-07
summary(m3b)
## 
## Call:
## lm(formula = pboo_10 ~ Proximity + log(t_10) + dbw_10, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.692  -5.202  -2.409   1.831  52.696 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          -0.52764    7.03364  -0.075    0.940    
## ProximityNot in Prox  7.44166    1.37456   5.414 1.52e-07 ***
## log(t_10)             0.49032    0.71218   0.688    0.492    
## dbw_10                0.03656    0.05098   0.717    0.474    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.41 on 236 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.1214, Adjusted R-squared:  0.1102 
## F-statistic: 10.87 on 3 and 236 DF,  p-value: 1.03e-06
m1c <- lm(pboo_00~Proximity,data=cities)
m2c <- lm(pboo_00~Proximity+log(t_00),data=cities)
m3c <- lm(pboo_00~Proximity+log(t_00)+dbw_00,data=cities)
summary(m1c)
## 
## Call:
## lm(formula = pboo_00 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -11.406  -4.122  -1.990   1.631  49.594 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             4.290      0.673   6.374 8.63e-10 ***
## ProximityNot in Prox    7.116      1.077   6.609 2.27e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.406 on 254 degrees of freedom
##   (13 observations deleted due to missingness)
## Multiple R-squared:  0.1467, Adjusted R-squared:  0.1434 
## F-statistic: 43.67 on 1 and 254 DF,  p-value: 2.267e-10
summary(m2c)
## 
## Call:
## lm(formula = pboo_00 ~ Proximity + log(t_00), data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.294  -4.269  -2.274   1.733  49.544 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -0.8651     6.5636  -0.132    0.895    
## ProximityNot in Prox   7.0641     1.2818   5.511 1.11e-07 ***
## log(t_00)              0.5552     0.6374   0.871    0.385    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.765 on 197 degrees of freedom
##   (69 observations deleted due to missingness)
## Multiple R-squared:  0.1445, Adjusted R-squared:  0.1358 
## F-statistic: 16.63 on 2 and 197 DF,  p-value: 2.112e-07
summary(m3c)
## 
## Call:
## lm(formula = pboo_00 ~ Proximity + log(t_00) + dbw_00, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -11.381  -4.448  -2.252   1.847  49.708 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           1.173053   6.450149   0.182  0.85588    
## ProximityNot in Prox  6.444154   1.268515   5.080 8.76e-07 ***
## log(t_00)            -0.006646   0.648026  -0.010  0.99183    
## dbw_00                0.129736   0.040949   3.168  0.00178 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.57 on 196 degrees of freedom
##   (69 observations deleted due to missingness)
## Multiple R-squared:  0.1862, Adjusted R-squared:  0.1737 
## F-statistic: 14.94 on 3 and 196 DF,  p-value: 8.449e-09
m1d <- lm(pboo_90~Proximity,data=cities)
m2d <- lm(pboo_90~Proximity+log(t_90),data=cities)
m3d <- lm(pboo_90~Proximity+log(t_90)+dbw_90,data=cities)
summary(m1d)
## 
## Call:
## lm(formula = pboo_90 ~ Proximity, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.564  -3.830  -2.390   2.436  50.076 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            3.8299     0.6342   6.039 5.46e-09 ***
## ProximityNot in Prox   6.7342     1.0167   6.623 2.07e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.947 on 255 degrees of freedom
##   (12 observations deleted due to missingness)
## Multiple R-squared:  0.1468, Adjusted R-squared:  0.1434 
## F-statistic: 43.87 on 1 and 255 DF,  p-value: 2.069e-10
summary(m2d)
## 
## Call:
## lm(formula = pboo_90 ~ Proximity + log(t_90), data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.459  -4.348  -2.059   2.303  49.229 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -0.7818     6.8735  -0.114    0.910    
## ProximityNot in Prox   7.1279     1.3429   5.308 3.31e-07 ***
## log(t_90)              0.5418     0.6767   0.801    0.424    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.582 on 176 degrees of freedom
##   (90 observations deleted due to missingness)
## Multiple R-squared:  0.1534, Adjusted R-squared:  0.1438 
## F-statistic: 15.94 on 2 and 176 DF,  p-value: 4.331e-07
summary(m3d)
## 
## Call:
## lm(formula = pboo_90 ~ Proximity + log(t_90) + dbw_90, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.289  -4.693  -1.687   2.367  50.433 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           3.14686    6.49777   0.484    0.629    
## ProximityNot in Prox  6.73156    1.26268   5.331 2.98e-07 ***
## log(t_90)            -0.40265    0.66266  -0.608    0.544    
## dbw_90                0.17106    0.03429   4.988 1.46e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.053 on 175 degrees of freedom
##   (90 observations deleted due to missingness)
## Multiple R-squared:  0.2588, Adjusted R-squared:  0.2461 
## F-statistic: 20.36 on 3 and 175 DF,  p-value: 2.291e-11
m1e <- lm(pboo_80~Proximity,data=cities)
m2e <- lm(pboo_80~Proximity+log(t_80),data=cities)
m3e <- lm(pboo_80~Proximity+log(t_80)+dbw_80,data=cities)
summary(m1e)
## 
## Call:
## lm(formula = pboo_80 ~ Proximity, data = cities)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -8.199 -3.475 -2.315  2.175 29.635 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            3.4750     0.5519   6.296 1.45e-09 ***
## ProximityNot in Prox   4.7242     0.8837   5.346 2.10e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.691 on 239 degrees of freedom
##   (28 observations deleted due to missingness)
## Multiple R-squared:  0.1068, Adjusted R-squared:  0.1031 
## F-statistic: 28.58 on 1 and 239 DF,  p-value: 2.099e-07
summary(m2e)
## 
## Call:
## lm(formula = pboo_80 ~ Proximity + log(t_80), data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -11.256  -4.013  -2.072   3.440  28.003 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           -4.3137     6.1444  -0.702    0.484    
## ProximityNot in Prox   5.7188     1.2114   4.721 5.32e-06 ***
## log(t_80)              0.8547     0.6068   1.408    0.161    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.209 on 151 degrees of freedom
##   (115 observations deleted due to missingness)
## Multiple R-squared:  0.1546, Adjusted R-squared:  0.1434 
## F-statistic:  13.8 on 2 and 151 DF,  p-value: 3.125e-06
summary(m3e)
## 
## Call:
## lm(formula = pboo_80 ~ Proximity + log(t_80) + dbw_80, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -11.147  -4.408  -1.674   2.692  27.227 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           2.31953    5.93737   0.391    0.697    
## ProximityNot in Prox  5.40689    1.13826   4.750 4.71e-06 ***
## log(t_80)            -0.32359    0.62305  -0.519    0.604    
## dbw_80                0.12681    0.02727   4.650 7.22e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.762 on 150 degrees of freedom
##   (115 observations deleted due to missingness)
## Multiple R-squared:  0.2611, Adjusted R-squared:  0.2463 
## F-statistic: 17.67 on 3 and 150 DF,  p-value: 7.136e-10
m1a <- lm(pboo_20~Proximity,data=cities)
m2a <- lm(pboo_20~Proximity+log(t_20),data=cities)
m3a <- lm(pboo_20~Proximity+log(t_20)+dbw_20,data=cities)

m1b <- lm(pboo_10~Proximity,data=cities)
m2b <- lm(pboo_10~Proximity+log(t_10),data=cities)
m3b <- lm(pboo_10~Proximity+log(t_10)+dbw_10,data=cities)

m1c <- lm(pboo_00~Proximity,data=cities)
m2c <- lm(pboo_00~Proximity+log(t_00),data=cities)
m3c <- lm(pboo_00~Proximity+log(t_00)+dbw_00,data=cities)

m1d <- lm(pboo_90~Proximity,data=cities)
m2d <- lm(pboo_90~Proximity+log(t_90),data=cities)
m3d <- lm(pboo_90~Proximity+log(t_90)+dbw_90,data=cities)

m1e <- lm(pboo_80~Proximity,data=cities)
m2e <- lm(pboo_80~Proximity+log(t_80),data=cities)
m3e <- lm(pboo_80~Proximity+log(t_80)+dbw_80,data=cities)
stargazer( m1c, m2c, m3c, m1d, m2d, m3d, m1e, m2e, m3e,
          type="text", title="Regression Results",
          align=TRUE, dep.var.labels=c("Percent Black Homeownership 2000","Percent Black Homeownership 1990","Percent Black Homeownership 1980"),
          covariate.labels=c("City Population 2000","Dissimilarity Index 2000","Proximity","City Population 1990","Dissimilarity Index 1990","City Population 1980","Dissimilarity Index 1980"), out="main00-80.htm") 
## 
## Regression Results
## ================================================================================================================================================================================================================================================
##                                                                                                                            Dependent variable:                                                                                                  
##                          -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
##                                             Percent Black Homeownership 2000                                        Percent Black Homeownership 1990                                        Percent Black Homeownership 1980                    
##                                    (1)                     (2)                     (3)                     (4)                     (5)                     (6)                     (7)                     (8)                     (9)          
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## City Population 2000            7.116***                7.064***                6.444***                6.734***                7.128***                6.732***                4.724***                5.719***                5.407***        
##                                  (1.077)                 (1.282)                 (1.269)                 (1.017)                 (1.343)                 (1.263)                 (0.884)                 (1.211)                 (1.138)        
##                                                                                                                                                                                                                                                 
## Dissimilarity Index 2000                                  0.555                  -0.007                                                                                                                                                         
##                                                          (0.637)                 (0.648)                                                                                                                                                        
##                                                                                                                                                                                                                                                 
## Proximity                                                                       0.130***                                                                                                                                                        
##                                                                                  (0.041)                                                                                                                                                        
##                                                                                                                                                                                                                                                 
## City Population 1990                                                                                                              0.542                  -0.403                                                                                 
##                                                                                                                                  (0.677)                 (0.663)                                                                                
##                                                                                                                                                                                                                                                 
## Dissimilarity Index 1990                                                                                                                                0.171***                                                                                
##                                                                                                                                                          (0.034)                                                                                
##                                                                                                                                                                                                                                                 
## City Population 1980                                                                                                                                                                                      0.855                  -0.324         
##                                                                                                                                                                                                          (0.607)                 (0.623)        
##                                                                                                                                                                                                                                                 
## Dissimilarity Index 1980                                                                                                                                                                                                        0.127***        
##                                                                                                                                                                                                                                  (0.027)        
##                                                                                                                                                                                                                                                 
## Constant                        4.290***                 -0.865                   1.173                 3.830***                 -0.782                   3.147                 3.475***                 -4.314                   2.320         
##                                  (0.673)                 (6.564)                 (6.450)                 (0.634)                 (6.873)                 (6.498)                 (0.552)                 (6.144)                 (5.937)        
##                                                                                                                                                                                                                                                 
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Observations                       256                     200                     200                     257                     179                     179                     241                     154                     154          
## R2                                0.147                   0.144                   0.186                   0.147                   0.153                   0.259                   0.107                   0.155                   0.261         
## Adjusted R2                       0.143                   0.136                   0.174                   0.143                   0.144                   0.246                   0.103                   0.143                   0.246         
## Residual Std. Error         8.406 (df = 254)        8.765 (df = 197)        8.570 (df = 196)        7.947 (df = 255)        8.582 (df = 176)        8.053 (df = 175)        6.691 (df = 239)        7.209 (df = 151)        6.762 (df = 150)    
## F Statistic              43.673*** (df = 1; 254) 16.635*** (df = 2; 197) 14.944*** (df = 3; 196) 43.868*** (df = 1; 255) 15.943*** (df = 2; 176) 20.363*** (df = 3; 175) 28.579*** (df = 1; 239) 13.802*** (df = 2; 151) 17.666*** (df = 3; 150)
## ================================================================================================================================================================================================================================================
## Note:                                                                                                                                                                                                                *p<0.1; **p<0.05; ***p<0.01
stargazer(m1a, m2a, m3a, m1b, m2b, m3b,
          type="text", title="Regression Results",
          align=TRUE, dep.var.labels=c("Percent Black Homeownership 2020",
                                       "Percent Black Homeownership 2010"),
          covariate.labels=c("Proximity","City Population 2020","Dissimilarity Index 2020",
                             "City Population 2010","Dissimilarity Index 2010"),
                             out="main 2010 - 2020.htm") 
## 
## Regression Results
## ========================================================================================================================================================================
##                                                                                        Dependent variable:                                                              
##                          -----------------------------------------------------------------------------------------------------------------------------------------------
##                                             Percent Black Homeownership 2020                                        Percent Black Homeownership 2010                    
##                                    (1)                     (2)                     (3)                     (4)                     (5)                     (6)          
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Proximity                       7.318***                7.131***                7.172***                7.623***                7.498***                7.442***        
##                                  (1.270)                 (1.283)                 (1.288)                 (1.365)                 (1.371)                 (1.375)        
##                                                                                                                                                                         
## City Population 2020                                      6.678                   7.932                                                                                 
##                                                          (6.711)                 (7.231)                                                                                
##                                                                                                                                                                         
## Dissimilarity Index 2020                                                         -0.026                                                                                 
##                                                                                  (0.056)                                                                                
##                                                                                                                                                                         
## City Population 2010                                                                                                              0.662                   0.490         
##                                                                                                                                  (0.670)                 (0.712)        
##                                                                                                                                                                         
## Dissimilarity Index 2010                                                                                                                                  0.037         
##                                                                                                                                                          (0.051)        
##                                                                                                                                                                         
## Constant                        5.604***                 -9.916                  -12.198                5.466***                 -1.331                  -0.528         
##                                  (0.789)                (15.652)                (16.409)                 (0.872)                 (6.937)                 (7.034)        
##                                                                                                                                                                         
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Observations                       262                     261                     261                     240                     240                     240          
## R2                                0.113                   0.116                   0.116                   0.116                   0.119                   0.121         
## Adjusted R2                       0.110                   0.109                   0.106                   0.112                   0.112                   0.110         
## Residual Std. Error         10.008 (df = 260)       10.021 (df = 258)       10.037 (df = 257)       10.394 (df = 238)       10.395 (df = 237)       10.405 (df = 236)   
## F Statistic              33.183*** (df = 1; 260) 16.848*** (df = 2; 258) 11.272*** (df = 3; 257) 31.184*** (df = 1; 238) 16.078*** (df = 2; 237) 10.868*** (df = 3; 236)
## ========================================================================================================================================================================
## Note:                                                                                                                                        *p<0.1; **p<0.05; ***p<0.01

Proximity to freedom colonies as the mediator

Causal mediation analysis

#linear regression model path c

library(lavaan)

fit.totaleffect20=lm(pboo_20~dbw_20,cities)
summary(fit.totaleffect20)
## 
## Call:
## lm(formula = pboo_20 ~ dbw_20, data = cities)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.494 -6.204 -3.776  3.361 58.777 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  7.75619    1.53393   5.056 8.09e-07 ***
## dbw_20       0.02759    0.05460   0.505    0.614    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.63 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.0009849,  Adjusted R-squared:  -0.002872 
## F-statistic: 0.2553 on 1 and 259 DF,  p-value: 0.6138
fit.totaleffect10=lm(pboo_10~dbw_10,cities)
summary(fit.totaleffect10)
## 
## Call:
## lm(formula = pboo_10 ~ dbw_10, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.414  -6.611  -4.047   3.222  57.349 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  6.65783    1.54930   4.297 2.52e-05 ***
## dbw_10       0.07062    0.05063   1.395    0.164    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.01 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.008109,   Adjusted R-squared:  0.003941 
## F-statistic: 1.946 on 1 and 238 DF,  p-value: 0.1644
fit.totaleffect00=lm(pboo_00~dbw_00,cities)
summary(fit.totaleffect00)
## 
## Call:
## lm(formula = pboo_00 ~ dbw_00, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.879  -5.553  -2.565   2.516  53.694 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.47709    1.42056   1.744   0.0828 .  
## dbw_00       0.16763    0.04096   4.093  6.2e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.076 on 198 degrees of freedom
##   (69 observations deleted due to missingness)
## Multiple R-squared:  0.07801,    Adjusted R-squared:  0.07335 
## F-statistic: 16.75 on 1 and 198 DF,  p-value: 6.198e-05

#homeownership and percent black significant because they are highly correlated

fit.totaleffect2_20=lm(pb_20~pboo_20,cities)
summary(fit.totaleffect2_20)
## 
## Call:
## lm(formula = pb_20 ~ pboo_20, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11.0656  -2.3158  -0.6632   1.6532  16.8647 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.09306    0.26722   11.57   <2e-16 ***
## pboo_20      1.07084    0.01971   54.32   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.374 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.9193, Adjusted R-squared:  0.919 
## F-statistic:  2951 on 1 and 259 DF,  p-value: < 2.2e-16
fit.totaleffect2_10=lm(pb_10~pboo_10,cities)
summary(fit.totaleffect2_10)
## 
## Call:
## lm(formula = pb_10 ~ pboo_10, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11.2387  -1.9058  -0.6333   1.3838  15.1023 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.26128    0.24360   9.283   <2e-16 ***
## pboo_10      1.06376    0.01746  60.941   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.977 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.9398, Adjusted R-squared:  0.9395 
## F-statistic:  3714 on 1 and 238 DF,  p-value: < 2.2e-16
fit.totaleffect2_00=lm(pb_00~pboo_00,cities)
summary(fit.totaleffect2_00)
## 
## Call:
## lm(formula = pb_00 ~ pboo_00, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13.4643  -1.5188  -0.6209   1.2338  19.8202 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.63249    0.26102   6.254 2.42e-09 ***
## pboo_00      1.13258    0.02152  52.641  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.862 on 198 degrees of freedom
##   (69 observations deleted due to missingness)
## Multiple R-squared:  0.9333, Adjusted R-squared:  0.933 
## F-statistic:  2771 on 1 and 198 DF,  p-value: < 2.2e-16

#Proximity as the mediator

cities$Proximity <- as.ordered(cities$Proximity)
class(cities$Proximity)
## [1] "ordered" "factor"
summary(cities$Proximity)
## In Proximity  Not in Prox 
##          162          107
specmod20 <- "
#Path c
pboo_20 ~ c*dbw_20

#Path a
Proximity ~ a*dbw_20

#Path b
pboo_20 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"
specmod10 <- "
#Path c
pboo_10 ~ c*dbw_10

#Path a
Proximity ~ a*dbw_10

#Path b
pboo_10 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"
specmod00 <- "
#Path c
pboo_00 ~ c*dbw_00

#Path a
Proximity ~ a*dbw_00

#Path b
pboo_00 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"

specmod90 <- "
#Path c
pboo_90 ~ c*dbw_90

#Path a
Proximity ~ a*dbw_90

#Path b
pboo_90 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"

specmod80 <- "
#Path c
pboo_80 ~ c*dbw_80

#Path a
Proximity ~ a*dbw_80

#Path b
pboo_80 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"
fitmodel20<- sem(specmod20, data=cities)
fitmodel10<- sem(specmod10, data=cities)
fitmodel00<- sem(specmod00, data=cities)
fitmodel90<- sem(specmod90, data=cities)
fitmodel80<- sem(specmod80, data=cities)
summary(fitmodel20,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 16 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           261         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                47.852      47.852
##   Degrees of freedom                                 1           1
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   pboo_20 ~                                           
##     dbw_20     (c)   -0.025    0.052   -0.480    0.631
##   Proximity ~                                         
##     dbw_20     (a)    0.011    0.006    1.715    0.086
##   pboo_20 ~                                           
##     Proximity  (b)    4.715    0.682    6.917    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_20           7.756    1.905    4.071    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.571    0.183    3.127    0.002
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_20          89.900    7.233   12.429    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     pboo_20           0.199
##     Proximity         0.018
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab                0.052    0.031    1.677    0.094
summary(fitmodel10,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 19 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           240         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                48.420      48.420
##   Degrees of freedom                                 1           1
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   pboo_10 ~                                           
##     dbw_10     (c)    0.032    0.047    0.690    0.490
##   Proximity ~                                         
##     dbw_10     (a)    0.008    0.006    1.318    0.188
##   pboo_10 ~                                           
##     Proximity  (b)    5.025    0.722    6.958    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_10           6.658    2.102    3.168    0.002
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.440    0.178    2.469    0.014
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_10          94.947    8.134   11.673    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     pboo_10           0.216
##     Proximity         0.011
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab                0.038    0.029    1.299    0.194
summary(fitmodel00,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 18 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           200         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                42.125      42.125
##   Degrees of freedom                                 1           1
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   pboo_00 ~                                           
##     dbw_00     (c)    0.105    0.042    2.523    0.012
##   Proximity ~                                         
##     dbw_00     (a)    0.016    0.006    2.612    0.009
##   pboo_00 ~                                           
##     Proximity  (b)    4.013    0.618    6.490    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_00           2.477    1.861    1.331    0.183
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.757    0.210    3.601    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_00          65.443    5.638   11.607    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     pboo_00           0.260
##     Proximity         0.057
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab                0.063    0.025    2.487    0.013
summary(fitmodel90,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 19 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           179         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                47.177      47.177
##   Degrees of freedom                                 1           1
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   pboo_90 ~                                           
##     dbw_90     (c)    0.151    0.040    3.814    0.000
##   Proximity ~                                         
##     dbw_90     (a)    0.008    0.005    1.591    0.112
##   pboo_90 ~                                           
##     Proximity  (b)    4.132    0.602    6.869    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_90           1.135    2.026    0.560    0.575
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.569    0.209    2.729    0.006
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_90          56.677    4.987   11.365    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     pboo_90           0.338
##     Proximity         0.024
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab                0.035    0.022    1.592    0.111
summary(fitmodel80,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 22 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           154         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                22.933      22.933
##   Degrees of freedom                                 1           1
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   pboo_80 ~                                           
##     dbw_80     (c)    0.113    0.026    4.429    0.000
##   Proximity ~                                         
##     dbw_80     (a)    0.008    0.005    1.567    0.117
##   pboo_80 ~                                           
##     Proximity  (b)    3.061    0.639    4.789    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_80           0.719    1.723    0.417    0.676
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.613    0.239    2.563    0.010
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_80          41.867    4.871    8.596    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     pboo_80           0.306
##     Proximity         0.027
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab                0.023    0.015    1.572    0.116

#Black-to-white racial residential segregation is positively associated with racial income inequality.

plot(cities$dbw_20,cities$gini_20,pch=20,
     xlab='D index',ylab='Gini index',
     main='Cities by Residential Segregation and Income Inequality in 2020')

plot(cities$dbw_10,cities$gini_10,pch=20,
     xlab='D index',ylab='Gini index',
     main='Cities by Residential Segregation and Income Inequality in 2010')

#outcome = inequality

m5a <- lm(gini_20~dbw_20,data=cities)
summary(m5a)
## 
## Call:
## lm(formula = gini_20 ~ dbw_20, data = cities)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.106555 -0.030176  0.004545  0.031145  0.101210 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.3718508  0.0063533  58.529   <2e-16 ***
## dbw_20      0.0020690  0.0002261   9.149   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.04403 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.2443, Adjusted R-squared:  0.2413 
## F-statistic: 83.71 on 1 and 259 DF,  p-value: < 2.2e-16
m5b <- lm(gini_10~dbw_10,data=cities)
summary(m5b)
## 
## Call:
## lm(formula = gini_10 ~ dbw_10, data = cities)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.128300 -0.034858 -0.001421  0.034283  0.151779 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.3772492  0.0073349  51.432  < 2e-16 ***
## dbw_10      0.0016617  0.0002397   6.933 3.84e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.05212 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.168,  Adjusted R-squared:  0.1645 
## F-statistic: 48.07 on 1 and 238 DF,  p-value: 3.845e-11

##Regression results

stargazer(m5a,m5b,
          type="text", title="Regression Results",
          align=TRUE, dep.var.labels=c("Income Inequality 2020","Income Inequality 2010"),
          covariate.labels=c("Dissimilarity Index 2020","Dissimilarity Index 2010"),out="Gini20202010.htm")
## 
## Regression Results
## ========================================================================
##                                        Dependent variable:              
##                          -----------------------------------------------
##                          Income Inequality 2020  Income Inequality 2010 
##                                    (1)                     (2)          
## ------------------------------------------------------------------------
## Dissimilarity Index 2020        0.002***                                
##                                 (0.0002)                                
##                                                                         
## Dissimilarity Index 2010                                0.002***        
##                                                         (0.0002)        
##                                                                         
## Constant                        0.372***                0.377***        
##                                  (0.006)                 (0.007)        
##                                                                         
## ------------------------------------------------------------------------
## Observations                       261                     240          
## R2                                0.244                   0.168         
## Adjusted R2                       0.241                   0.165         
## Residual Std. Error         0.044 (df = 259)        0.052 (df = 238)    
## F Statistic              83.711*** (df = 1; 259) 48.067*** (df = 1; 238)
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01
m6a <- lm(gini_20~Proximity,data=cities)
m7a <- lm(gini_20~Proximity+log(t_20),data=cities)
m8a <- lm(gini_20~Proximity+log(t_20)+dbw_20,data=cities)
m9a <- lm(gini_20~Proximity+log(t_20)+dbw_20+pboo_20,data=cities)

m6b <- lm(gini_10~Proximity,data=cities)
m7b <- lm(gini_10~Proximity+log(t_10),data=cities)
m8b <- lm(gini_10~Proximity+log(t_10)+dbw_10,data=cities)
m9b <- lm(gini_10~Proximity+log(t_10)+dbw_20+pboo_20,data=cities)
stargazer(m6a, m7a, m8a, m9a, m6b, m7b, m8b, m9b,
          type="text", title="Regression Results",
          align=TRUE, dep.var.labels=c("Income Inequality 2020","2010"),
          covariate.labels=c("Proximity","City Population 2020","Dissimilarity Index 2020","Black Homeownership 2020"), out="Inequality outcome.htm") 
## 
## Regression Results
## =============================================================================================================================================================================================================
##                                                                                                          Dependent variable:                                                                                 
##                          ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
##                                                           Income Inequality 2020                                                                              2010                                           
##                                  (1)                  (2)                    (3)                     (4)                   (5)                  (6)                     (7)                     (8)          
## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Proximity                      0.0002               -0.001                 -0.004                   0.001                 0.001                -0.003                 -0.005                   0.001         
##                                (0.005)              (0.005)                (0.004)                 (0.004)               (0.005)              (0.005)                 (0.005)                 (0.005)        
##                                                                                                                                                                                                              
## City Population 2020                               0.100***               -0.00003                  0.008                                                                                                    
##                                                     (0.033)                (0.032)                 (0.031)                                                                                                   
##                                                                                                                                                                                                              
## Dissimilarity Index 2020                                                  0.002***                0.002***                                                                                   0.002***        
##                                                                           (0.0002)                (0.0002)                                                                                   (0.0003)        
##                                                                                                                                                                                                              
## Black Homeownership 2020                                                                          -0.001***                                                                                  -0.001***       
##                                                                                                   (0.0003)                                                                                   (0.0003)        
##                                                                                                                                                                                                              
## log(t_10)                                                                                                                                     0.012***                 0.004                   0.003         
##                                                                                                                                               (0.004)                 (0.004)                 (0.004)        
##                                                                                                                                                                                                              
## dbw_10                                                                                                                                                               0.002***                                
##                                                                                                                                                                      (0.0003)                                
##                                                                                                                                                                                                              
## Constant                      0.424***              0.190**               0.371***                0.363***              0.419***              0.300***               0.333***                0.352***        
##                                (0.003)              (0.078)                (0.072)                 (0.071)               (0.004)              (0.038)                 (0.035)                 (0.036)        
##                                                                                                                                                                                                              
## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Observations                     262                  261                    261                     261                   264                  240                     240                     235          
## R2                             0.00001               0.034                  0.247                   0.282                0.0001                0.043                   0.176                   0.210         
## Adjusted R2                    -0.004                0.026                  0.238                   0.271                -0.004                0.035                   0.165                   0.196         
## Residual Std. Error       0.051 (df = 260)     0.050 (df = 258)       0.044 (df = 257)        0.043 (df = 256)      0.060 (df = 262)      0.056 (df = 237)       0.052 (df = 236)        0.051 (df = 230)    
## F Statistic              0.002 (df = 1; 260) 4.475** (df = 2; 258) 28.059*** (df = 3; 257) 25.154*** (df = 4; 256) 0.015 (df = 1; 262) 5.380*** (df = 2; 237) 16.794*** (df = 3; 236) 15.252*** (df = 4; 230)
## =============================================================================================================================================================================================================
## Note:                                                                                                                                                                             *p<0.1; **p<0.05; ***p<0.01
m10a <- lm(gini_20~pb_20,data=cities)
summary(m10a)
## 
## Call:
## lm(formula = gini_20 ~ pb_20, data = cities)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.133079 -0.032519 -0.001667  0.034255  0.135233 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.4307733  0.0044585  96.619   <2e-16 ***
## pb_20       -0.0005279  0.0002629  -2.008   0.0457 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.05026 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.01533,    Adjusted R-squared:  0.01153 
## F-statistic: 4.032 on 1 and 259 DF,  p-value: 0.04569
m10b <- lm(gini_10~pb_10,data=cities)
summary(m10b)
## 
## Call:
## lm(formula = gini_10 ~ pb_10, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.15540 -0.03681 -0.00019  0.04235  0.14526 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.4258257  0.0050589  84.174   <2e-16 ***
## pb_10       -0.0002976  0.0003048  -0.976     0.33    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.05703 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.00399,    Adjusted R-squared:  -0.0001951 
## F-statistic: 0.9534 on 1 and 238 DF,  p-value: 0.3298
m11a <- lm(gini_20~pboo_20,data=cities)
summary(m11a)
## 
## Call:
## lm(formula = gini_20 ~ pboo_20, data = cities)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.13154 -0.03281 -0.00097  0.03240  0.13350 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.4315050  0.0039274 109.871  < 2e-16 ***
## pboo_20     -0.0008464  0.0002903  -2.916  0.00386 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.04974 on 260 degrees of freedom
##   (7 observations deleted due to missingness)
## Multiple R-squared:  0.03167,    Adjusted R-squared:  0.02794 
## F-statistic: 8.503 on 1 and 260 DF,  p-value: 0.003856
m11b <- lm(gini_10~pboo_10,data=cities)
summary(m11b)
## 
## Call:
## lm(formula = gini_10 ~ pboo_10, data = cities)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.152918 -0.037229 -0.000532  0.041745  0.143149 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.4287648  0.0046284  92.637   <2e-16 ***
## pboo_10     -0.0007376  0.0003317  -2.224   0.0271 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.05656 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.02036,    Adjusted R-squared:  0.01624 
## F-statistic: 4.946 on 1 and 238 DF,  p-value: 0.02708

#outcome = segregation

m12a <- lm(dbw_20~gini_20,data=cities)
summary(m12a)
## 
## Call:
## lm(formula = dbw_20 ~ gini_20, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -22.168  -7.256  -1.223   6.250  41.274 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -24.720      5.514  -4.483 1.11e-05 ***
## gini_20      118.059     12.903   9.149  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.52 on 259 degrees of freedom
##   (8 observations deleted due to missingness)
## Multiple R-squared:  0.2443, Adjusted R-squared:  0.2413 
## F-statistic: 83.71 on 1 and 259 DF,  p-value: < 2.2e-16
m12b <- lm(dbw_10~gini_10,data=cities)
summary(m12b)
## 
## Call:
## lm(formula = dbw_10 ~ gini_10, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -27.987  -8.574  -0.795   7.034  46.673 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -15.522      6.217  -2.497   0.0132 *  
## gini_10      101.117     14.585   6.933 3.84e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.86 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.168,  Adjusted R-squared:  0.1645 
## F-statistic: 48.07 on 1 and 238 DF,  p-value: 3.845e-11
m13a <- lm(dbw_20~Proximity,data=cities)
m14a <- lm(dbw_20~Proximity+log(t_20),data=cities)
m15a <- lm(dbw_20~Proximity+log(t_20)+pboo_20,data=cities)
m16a <- lm(dbw_20~Proximity+log(t_20)+pboo_20+gini_20,data=cities)

m13b <- lm(dbw_10~Proximity,data=cities)
m14b <- lm(dbw_10~Proximity+log(t_10),data=cities)
m15b <- lm(dbw_10~Proximity+log(t_10)+pboo_10,data=cities)
m16b <- lm(dbw_10~Proximity+log(t_10)+pboo_10+gini_10,data=cities)
stargazer(m13a, m14a, m15a, m16a, m13b, m14b, m15b, m16b,
          type="text", title="Regression Results",
          align=TRUE, dep.var.labels=c("Dissimilarity Index 2020","Dissimilarity Index 2010"),
          covariate.labels=c("Proximity","City Population 2020","Black Homeownership","Income Inequality","City Population 2010","Black Homeownership","Income Inequality"), out="Segregation.htm") 
## 
## Regression Results
## =============================================================================================================================================================================================================
##                                                                                                        Dependent variable:                                                                                   
##                      ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
##                                                        Dissimilarity Index 2020                                                                    Dissimilarity Index 2010                                  
##                              (1)                    (2)                     (3)                     (4)                   (5)                   (6)                     (7)                     (8)          
## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Proximity                   1.856*                 1.086                   1.251                   0.842                 1.711                 1.085                   0.770                   0.598         
##                            (1.081)                (1.014)                 (1.075)                 (0.949)               (1.304)               (1.236)                 (1.313)                 (1.215)        
##                                                                                                                                                                                                              
## City Population 2020                             47.799***               48.018***               36.414***                                                                                                   
##                                                   (7.503)                 (7.529)                 (6.778)                                                                                                    
##                                                                                                                                                                                                              
## Black Homeownership                                                       -0.033                   0.078                                                                                                     
##                                                                           (0.070)                 (0.063)                                                                                                    
##                                                                                                                                                                                                              
## Income Inequality                                                                               108.708***                                                                                                   
##                                                                                                  (12.624)                                                                                                    
##                                                                                                                                                                                                              
## City Population 2010                                                                                                                         4.692***                4.652***                3.507***        
##                                                                                                                                               (0.855)                 (0.857)                 (0.813)        
##                                                                                                                                                                                                              
## Black Homeownership                                                                                                                                                    0.059                  0.141*         
##                                                                                                                                                                       (0.083)                 (0.078)        
##                                                                                                                                                                                                              
## Income Inequality                                                                                                                                                                            92.373***       
##                                                                                                                                                                                              (14.427)        
##                                                                                                                                                                                                              
## Constant                  25.676***             -86.204***              -86.412***              -106.415***            27.416***             -21.208**               -21.352**              -49.247***       
##                            (0.764)               (17.576)                (17.608)                (15.708)               (0.922)               (8.900)                 (8.912)                 (9.321)        
##                                                                                                                                                                                                              
## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Observations                 261                    261                     261                     261                   240                   240                     240                     240          
## R2                          0.011                  0.146                   0.146                   0.338                 0.007                 0.119                   0.121                   0.252         
## Adjusted R2                 0.007                  0.139                   0.136                   0.328                 0.003                 0.112                   0.110                   0.239         
## Residual Std. Error   12.030 (df = 259)      11.204 (df = 258)       11.221 (df = 257)       9.900 (df = 256)      14.045 (df = 238)     13.257 (df = 237)       13.271 (df = 236)       12.272 (df = 235)   
## F Statistic          2.947* (df = 1; 259) 21.991*** (df = 2; 258) 14.690*** (df = 3; 257) 32.694*** (df = 4; 256) 1.721 (df = 1; 238) 16.034*** (df = 2; 237) 10.838*** (df = 3; 236) 19.755*** (df = 4; 235)
## =============================================================================================================================================================================================================
## Note:                                                                                                                                                                             *p<0.1; **p<0.05; ***p<0.01

#outcome = homeownership

m17a <- lm(pboo_20~gini_20,data=cities)
summary(m17a)
## 
## Call:
## lm(formula = pboo_20 ~ gini_20, data = cities)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.757 -6.354 -3.521  2.900 56.998 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   24.301      5.483   4.432 1.38e-05 ***
## gini_20      -37.412     12.830  -2.916  0.00386 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.46 on 260 degrees of freedom
##   (7 observations deleted due to missingness)
## Multiple R-squared:  0.03167,    Adjusted R-squared:  0.02794 
## F-statistic: 8.503 on 1 and 260 DF,  p-value: 0.003856
m17b <- lm(pboo_10~gini_10,data=cities)
summary(m17b)
## 
## Call:
## lm(formula = pboo_10 ~ gini_10, data = cities)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.567  -6.707  -3.943   2.528  55.439 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    20.24       5.29   3.826 0.000167 ***
## gini_10       -27.60      12.41  -2.224 0.027084 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.94 on 238 degrees of freedom
##   (29 observations deleted due to missingness)
## Multiple R-squared:  0.02036,    Adjusted R-squared:  0.01624 
## F-statistic: 4.946 on 1 and 238 DF,  p-value: 0.02708
m18a <- lm(pboo_20~Proximity,data=cities)
m19a <- lm(pboo_20~Proximity+log(t_20),data=cities)
m20a <- lm(pboo_20~Proximity+log(t_20)+dbw_20,data=cities)
m21a <- lm(pboo_20~Proximity+log(t_20)+dbw_20+gini_20,data=cities)

m18b <- lm(pboo_10~Proximity,data=cities)
m19b <- lm(pboo_10~Proximity+log(t_10),data=cities)
m20b <- lm(pboo_10~Proximity+log(t_10)+dbw_10,data=cities)
m21b <- lm(pboo_10~Proximity+log(t_10)+dbw_10+gini_10,data=cities)
stargazer(m18a, m19a, m20a, m21a, m18b, m19b, m20b, m21b,
          type="text", title="Regression Results",
          align=TRUE, dep.var.labels=c("Black Homeownership 2020","Black Homeownership 2010"),
          covariate.labels=c("Proximity","City Population 2020","Dissimilarity Index","Income Inequality","City Population 2010","Dissimilarity Index","Income Inequality"), out="Homeownership.htm") 
## 
## Regression Results
## ====================================================================================================================================================================================================================
##                                                                                                            Dependent variable:                                                                                      
##                      -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
##                                                         Black Homeownership 2020                                                                        Black Homeownership 2010                                    
##                                (1)                     (2)                     (3)                     (4)                     (5)                     (6)                     (7)                     (8)          
## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Proximity                   5.174***                5.043***                5.071***                4.891***                5.390***                5.302***                5.262***                5.086***        
##                              (0.898)                 (0.907)                 (0.910)                 (0.892)                 (0.965)                 (0.969)                 (0.972)                 (0.957)        
##                                                                                                                                                                                                                     
## City Population 2020                                  6.678                   7.932                   7.930                                                                                                         
##                                                      (6.711)                 (7.231)                 (7.072)                                                                                                        
##                                                                                                                                                                                                                     
## Dissimilarity Index                                                          -0.026                   0.077                                                                                                         
##                                                                              (0.056)                 (0.062)                                                                                                        
##                                                                                                                                                                                                                     
## Income Inequality                                                                                  -49.316***                                                                                                       
##                                                                                                     (13.877)                                                                                                        
##                                                                                                                                                                                                                     
## City Population 2010                                                                                                                                  0.662                   0.490                   0.663         
##                                                                                                                                                      (0.670)                 (0.712)                 (0.702)        
##                                                                                                                                                                                                                     
## Dissimilarity Index                                                                                                                                                           0.037                  0.098*         
##                                                                                                                                                                              (0.051)                 (0.054)        
##                                                                                                                                                                                                                     
## Income Inequality                                                                                                                                                                                  -38.970***       
##                                                                                                                                                                                                     (12.780)        
##                                                                                                                                                                                                                     
## Constant                    9.263***                 -6.351                  -8.612                   9.673                 9.277***                  2.418                   3.193                 16.178**        
##                              (0.635)                (15.721)                (16.463)                (16.904)                 (0.683)                 (6.978)                 (7.069)                 (8.149)        
##                                                                                                                                                                                                                     
## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Observations                   262                     261                     261                     261                     240                     240                     240                     240          
## R2                            0.113                   0.116                   0.116                   0.158                   0.116                   0.119                   0.121                   0.155         
## Adjusted R2                   0.110                   0.109                   0.106                   0.145                   0.112                   0.112                   0.110                   0.140         
## Residual Std. Error     10.008 (df = 260)       10.021 (df = 258)       10.037 (df = 257)       9.817 (df = 256)        10.394 (df = 238)       10.395 (df = 237)       10.405 (df = 236)       10.227 (df = 235)   
## F Statistic          33.183*** (df = 1; 260) 16.848*** (df = 2; 258) 11.272*** (df = 3; 257) 11.994*** (df = 4; 256) 31.184*** (df = 1; 238) 16.078*** (df = 2; 237) 10.868*** (df = 3; 236) 10.763*** (df = 4; 235)
## ====================================================================================================================================================================================================================
## Note:                                                                                                                                                                                    *p<0.1; **p<0.05; ***p<0.01

#Proximity as the mediator for inequality

cities$Proximity <- as.ordered(cities$Proximity)
class(cities$Proximity)
## [1] "ordered" "factor"
summary(cities$Proximity)
## In Proximity  Not in Prox 
##          162          107
specmodgini20 <- "
#Path c
pboo_20 ~ c*gini_20

#Path a
Proximity ~ a*gini_20

#Path b
pboo_20 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"
specmodgini10 <- "
#Path c
pboo_10 ~ c*gini_10

#Path a
Proximity ~ a*gini_10

#Path b
pboo_10 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"
fitmodel220<- sem(specmodgini20, data=cities)
fitmodel210<- sem(specmodgini10, data=cities)
summary(fitmodel220,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 38 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           262         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                50.678      50.678
##   Degrees of freedom                                 1           1
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   pboo_20 ~                                           
##     gini_20    (c)  -37.747   12.504   -3.019    0.003
##   Proximity ~                                         
##     gini_20    (a)    0.071    1.536    0.046    0.963
##   pboo_20 ~                                           
##     Proximity  (b)    4.711    0.662    7.119    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_20          24.301    5.909    4.113    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.321    0.657    0.489    0.625
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_20          86.336    7.054   12.239    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     pboo_20           0.230
##     Proximity         0.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab                0.335    7.235    0.046    0.963
summary(fitmodel210,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 38 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           240         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                47.537      47.537
##   Degrees of freedom                                 1           1
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   pboo_10 ~                                           
##     gini_10    (c)  -25.922   13.777   -1.882    0.060
##   Proximity ~                                         
##     gini_10    (a)   -0.332    1.418   -0.234    0.815
##   pboo_10 ~                                           
##     Proximity  (b)    5.058    0.734    6.895    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_10          20.239    6.524    3.102    0.002
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.092    0.605    0.151    0.880
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .pboo_10          93.123    8.392   11.097    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     pboo_10           0.232
##     Proximity         0.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab               -1.680    7.173   -0.234    0.815
spec20 <- "
#Path c
gini_20 ~ c*dbw_20

#Path a
Proximity ~ a*dbw_20

#Path b
gini_20 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"
spec10 <- "
#Path c
gini_10 ~ c*dbw_10

#Path a
Proximity ~ a*dbw_10

#Path b
gini_10 ~ b*Proximity

#Indirect effect (a*b)
ab :=a*b
"
fitmodel320<- sem(spec20, data=cities)
fitmodel310<- sem(spec10, data=cities)
summary(fitmodel320,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 23 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           261         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                 0.908       0.908
##   Degrees of freedom                                 1           1
##   P-value                                        0.341       0.341
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   gini_20 ~                                           
##     dbw_20     (c)    0.002    0.000   10.073    0.000
##   Proximity ~                                         
##     dbw_20     (a)    0.011    0.006    1.715    0.086
##   gini_20 ~                                           
##     Proximity  (b)   -0.003    0.003   -0.953    0.341
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .gini_20           0.372    0.006   61.761    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.571    0.183    3.127    0.002
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .gini_20           0.002    0.000   10.129    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     gini_20           0.249
##     Proximity         0.018
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab               -0.000    0.000   -0.836    0.403
summary(fitmodel310,fit.measures=TRUE, rsquare=TRUE)
## lavaan 0.6.17 ended normally after 17 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                         6
## 
##                                                   Used       Total
##   Number of observations                           240         269
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 0.000       0.000
##   Degrees of freedom                                 0           0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                 0.778       0.778
##   Degrees of freedom                                 1           1
##   P-value                                        0.378       0.378
##   Scaling correction factor                                  1.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.000
##   P-value H_0: RMSEA <= 0.050                       NA          NA
##   P-value H_0: RMSEA >= 0.080                       NA          NA
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000       0.000
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   gini_10 ~                                           
##     dbw_10     (c)    0.002    0.000    6.721    0.000
##   Proximity ~                                         
##     dbw_10     (a)    0.008    0.006    1.318    0.188
##   gini_10 ~                                           
##     Proximity  (b)   -0.004    0.004   -0.882    0.378
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .gini_10           0.377    0.007   52.885    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     Proximity|t1      0.440    0.178    2.469    0.014
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .gini_10           0.003    0.000   10.478    0.000
##    .Proximity         1.000                           
## 
## R-Square:
##                    Estimate
##     gini_10           0.173
##     Proximity         0.011
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab               -0.000    0.000   -0.740    0.460