#package installation # install.packages('plyr') # install.packages('dplyr') # install.packages('tidyr') # install.packages('igraph') # install.packages('geosphere') # install.packages('ggplot2') # install.packages('tictoc') rm(list=ls()) library(plyr);library(dplyr, warn.conflicts = F) library(tidyr) library(igraph) library(geosphere) library(ggplot2, warn.conflicts = F) library(tictoc) #setwd() #set working directory dir.create(paste0(getwd(), '/Output/')) dir.create(paste0(getwd(), '/Output/Network-sample-calculations/')) path0 = paste0(getwd(), '/Output/Network-sample-calculations/', Sys.Date(),'/') #Directory for output files dir.create(path0) s = function(x){summary(factor(x))} dat = readRDS('4-20-20_Network-KNearest_DeID_demed.RDS') ################################################################################################ tic() out_sim_list = readRDS('4-21-20_1000x_sample_nearest.RDS') toc() # cor_df = data.frame(Nearest5_SameRel_samp_AllLinksSameRelig = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig = rep(NA, length(out_sim_list)), Nearest5_SameRel_samp_AllLinksSameRelig_Neigh1 = rep(NA, length(out_sim_list)), Nearest5_SameRel_samp_AllLinksSameRelig_Neigh2 = rep(NA, length(out_sim_list)), Nearest5_SameRel_samp_AllLinksSameRelig_Neigh3 = rep(NA, length(out_sim_list)), Nearest5_SameRel_samp_AllLinksSameRelig_Neigh4 = rep(NA, length(out_sim_list)), Nearest5_SameRel_samp_AllLinksSameRelig_Neigh5 = rep(NA, length(out_sim_list)), Nearest5_SameRel_samp_AllLinksSameRelig_Neigh6 = rep(NA, length(out_sim_list)), Nearest5_SameRel_samp_AllLinksSameRelig_Neigh7 = rep(NA, length(out_sim_list)), Nearest5_SameRel_samp_AllLinksSameRelig_Neigh8 = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig_Neigh1 = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig_Neigh2 = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig_Neigh3 = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig_Neigh4 = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig_Neigh5 = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig_Neigh6 = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig_Neigh7 = rep(NA, length(out_sim_list)), Nearest10_SameRel_samp_AllLinksSameRelig_Neigh8 = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig_Neigh1 = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig_Neigh2 = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig_Neigh3 = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig_Neigh4 = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig_Neigh5 = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig_Neigh6 = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig_Neigh7 = rep(NA, length(out_sim_list)), Nearest15_SameRel_samp_AllLinksSameRelig_Neigh8 = rep(NA, length(out_sim_list)) ) tic() for(i in 1:length(out_sim_list)){ cor_df$Nearest5_SameRel_samp_AllLinksSameRelig[i] = #nearest 5 religion correlation cor(out_sim_list[[i]]$Nearest5_SameRel_samp, out_sim_list[[i]]$AllLinksSameRelig, use = 'pairwise.complete.obs') cor_df$Nearest10_SameRel_samp_AllLinksSameRelig[i] = #nearest 10 religion correlation cor(out_sim_list[[i]]$Nearest10_SameRel_samp, out_sim_list[[i]]$AllLinksSameRelig, use = 'pairwise.complete.obs') cor_df$Nearest15_SameRel_samp_AllLinksSameRelig[i] = #nearest 5 religion correlation cor(out_sim_list[[i]]$Nearest15_SameRel_samp, out_sim_list[[i]]$AllLinksSameRelig, use = 'pairwise.complete.obs') #nearest-5 cor_df$Nearest5_SameRel_samp_AllLinksSameRelig_Neigh1[i] = cor(out_sim_list[[i]]$Nearest5_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 1")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 1")], use = 'pairwise.complete.obs') cor_df$Nearest5_SameRel_samp_AllLinksSameRelig_Neigh2[i] = cor(out_sim_list[[i]]$Nearest5_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 145")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 145")], use = 'pairwise.complete.obs') cor_df$Nearest5_SameRel_samp_AllLinksSameRelig_Neigh3[i] = cor(out_sim_list[[i]]$Nearest5_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 30")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 30")], use = 'pairwise.complete.obs') cor_df$Nearest5_SameRel_samp_AllLinksSameRelig_Neigh4[i] = cor(out_sim_list[[i]]$Nearest5_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 68")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 68")], use = 'pairwise.complete.obs') cor_df$Nearest5_SameRel_samp_AllLinksSameRelig_Neigh5[i] = cor(out_sim_list[[i]]$Nearest5_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 42")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 42")], use = 'pairwise.complete.obs') cor_df$Nearest5_SameRel_samp_AllLinksSameRelig_Neigh6[i] = cor(out_sim_list[[i]]$Nearest5_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 51")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 51")], use = 'pairwise.complete.obs') cor_df$Nearest5_SameRel_samp_AllLinksSameRelig_Neigh7[i] = cor(out_sim_list[[i]]$Nearest5_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 82")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 82")], use = 'pairwise.complete.obs') cor_df$Nearest5_SameRel_samp_AllLinksSameRelig_Neigh8[i] = cor(out_sim_list[[i]]$Nearest5_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 93")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 93")], use = 'pairwise.complete.obs') #nearest-10 cor_df$Nearest10_SameRel_samp_AllLinksSameRelig_Neigh1[i] = cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 1")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 1")], use = 'pairwise.complete.obs') cor_df$Nearest10_SameRel_samp_AllLinksSameRelig_Neigh2[i] = cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 145")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 145")], use = 'pairwise.complete.obs') cor_df$Nearest10_SameRel_samp_AllLinksSameRelig_Neigh3[i] = cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 30")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 30")], use = 'pairwise.complete.obs') cor_df$Nearest10_SameRel_samp_AllLinksSameRelig_Neigh4[i] = cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 68")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 68")], use = 'pairwise.complete.obs') cor_df$Nearest10_SameRel_samp_AllLinksSameRelig_Neigh5[i] = cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 42")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 42")], use = 'pairwise.complete.obs') cor_df$Nearest10_SameRel_samp_AllLinksSameRelig_Neigh6[i] = cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 51")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 51")], use = 'pairwise.complete.obs') cor_df$Nearest10_SameRel_samp_AllLinksSameRelig_Neigh7[i] = cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 82")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 82")], use = 'pairwise.complete.obs') cor_df$Nearest10_SameRel_samp_AllLinksSameRelig_Neigh8[i] = cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 93")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 93")], use = 'pairwise.complete.obs') #nearest-15 cor_df$Nearest15_SameRel_samp_AllLinksSameRelig_Neigh1[i] = cor(out_sim_list[[i]]$Nearest15_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 1")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 1")], use = 'pairwise.complete.obs') cor_df$Nearest15_SameRel_samp_AllLinksSameRelig_Neigh2[i] = cor(out_sim_list[[i]]$Nearest15_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 145")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 145")], use = 'pairwise.complete.obs') cor_df$Nearest15_SameRel_samp_AllLinksSameRelig_Neigh3[i] = cor(out_sim_list[[i]]$Nearest15_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 30")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 30")], use = 'pairwise.complete.obs') cor_df$Nearest15_SameRel_samp_AllLinksSameRelig_Neigh4[i] = cor(out_sim_list[[i]]$Nearest15_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Jaipur 68")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Jaipur 68")], use = 'pairwise.complete.obs') cor_df$Nearest15_SameRel_samp_AllLinksSameRelig_Neigh5[i] = cor(out_sim_list[[i]]$Nearest15_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 42")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 42")], use = 'pairwise.complete.obs') cor_df$Nearest15_SameRel_samp_AllLinksSameRelig_Neigh6[i] = cor(out_sim_list[[i]]$Nearest15_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 51")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 51")], use = 'pairwise.complete.obs') cor_df$Nearest15_SameRel_samp_AllLinksSameRelig_Neigh7[i] = cor(out_sim_list[[i]]$Nearest15_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 82")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 82")], use = 'pairwise.complete.obs') cor_df$Nearest15_SameRel_samp_AllLinksSameRelig_Neigh8[i] = cor(out_sim_list[[i]]$Nearest15_SameRel_samp[which(out_sim_list[[i]]$A.A7 == "Patna 93")], out_sim_list[[i]]$AllLinksSameRelig[which(out_sim_list[[i]]$A.A7 == "Patna 93")], use = 'pairwise.complete.obs') } #throws a warning about "standard deviation is 0", because sometimes by chance everyone has the same Nearest10 score toc() #2.5 sec #histograms for nearest-k vs contact correlations from neighborhood samples #FIGURE A3 ggplot(data = cor_df, aes(cor_df$Nearest10_SameRel_samp_AllLinksSameRelig)) + geom_histogram(aes(y = (..count..)/sum(..count..) ), bins = 50) + theme_bw() + labs(x = 'Correlation, Nearest-k vs Outgroup Contacts', y = 'Proportion') + ggtitle('Nearest-10 Same Religion vs. Outgroup Contacts\nSample of 60 per neighborhood\nAll neighborhoods together') + theme(plot.title = element_text(hjust = 0.5, size = 14)) ggsave(filename = paste0(path0, 'k_contact_networksamp_histogram.png'), height = 150, width = 150, units = 'mm'); rm(path0) #*******RESULT******# #Correlations over 1k iterations between k-nearest score calculated for random sam- ple of 60 individuals from each neighborhood, versus contact with individuals from another religion. #TABLE A2 mean(cor_df$Nearest5_SameRel_samp_AllLinksSameRelig) #0.4181599 sd(cor_df$Nearest5_SameRel_samp_AllLinksSameRelig) #0.05066349 mean(cor_df$Nearest10_SameRel_samp_AllLinksSameRelig) #0.4312065 sd(cor_df$Nearest10_SameRel_samp_AllLinksSameRelig) #0.0466517 mean(cor_df$Nearest15_SameRel_samp_AllLinksSameRelig) #0.4375551 sd(cor_df$Nearest15_SameRel_samp_AllLinksSameRelig) #0.04528044 ############################################################################################################################################### ################################################################################################################################################ #*******RESULT******# #Relationship between proportion of the 10 nearest neighbors of another religion, and proportion who have any contacts with members of another religion. #TABLE A3 sum(dat$AllLinksSameRelig < 1, na.rm = T) / sum(dat$Nearest10_SameRel <= 10, na.rm = T) # 15% of whole sample have non-homogeneous contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel == 10, na.rm = T) / sum(dat$Nearest10_SameRel == 10, na.rm = T) #1% of samerel = 10 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 10, na.rm = T) / sum(dat$Nearest10_SameRel < 10, na.rm = T) #26% of samerel < 10 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 9, na.rm = T) / sum(dat$Nearest10_SameRel < 9, na.rm = T) #30% of samerel < 9 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 8, na.rm = T) / sum(dat$Nearest10_SameRel < 8, na.rm = T) #33% of samerel < 8 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 7, na.rm = T) / sum(dat$Nearest10_SameRel < 7, na.rm = T) #37% of samerel < 7 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 6, na.rm = T) / sum(dat$Nearest10_SameRel < 6, na.rm = T) #38% of samerel < 6 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 5, na.rm = T) / sum(dat$Nearest10_SameRel < 5, na.rm = T) #41% of samerel < 5 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 4, na.rm = T) / sum(dat$Nearest10_SameRel < 4, na.rm = T) #46% of samerel < 4 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 3, na.rm = T) / sum(dat$Nearest10_SameRel < 3, na.rm = T) #54% of samerel < 3 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 2, na.rm = T) / sum(dat$Nearest10_SameRel < 2, na.rm = T) #66% of samerel < 2 have hetero contacts sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 1, na.rm = T) / sum(dat$Nearest10_SameRel < 1, na.rm = T) #75% of samerel < 1 have hetero contacts s(dat$Nearest10_SameRel) sum(dat$Nearest10_SameRel == 10, na.rm = T) #1159 sum(dat$Nearest10_SameRel < 10, na.rm = T) #1422 sum(dat$Nearest10_SameRel < 9, na.rm = T) #1134 sum(dat$Nearest10_SameRel < 8, na.rm = T) #909 sum(dat$Nearest10_SameRel < 7, na.rm = T) #734 sum(dat$Nearest10_SameRel < 6, na.rm = T) #539 sum(dat$Nearest10_SameRel < 5, na.rm = T) #378 sum(dat$Nearest10_SameRel < 4, na.rm = T) #240 sum(dat$Nearest10_SameRel < 3, na.rm = T) #135 sum(dat$Nearest10_SameRel < 2, na.rm = T) #68 sum(dat$Nearest10_SameRel < 1, na.rm = T) #28 ################################################################################################################################################ #What is relationship between census-nearest-K and sample-nearest-K? k_cor_df = data.frame(SameRel_5_cor = rep(NA, length(out_sim_list)), SameRel_10_cor = rep(NA, length(out_sim_list)), SameRel_15_cor = rep(NA, length(out_sim_list)), SameRel_10_cor_neigh1 = rep(NA, length(out_sim_list)), SameRel_10_cor_neigh2 = rep(NA, length(out_sim_list)), SameRel_10_cor_neigh3 = rep(NA, length(out_sim_list)), SameRel_10_cor_neigh4 = rep(NA, length(out_sim_list)), SameRel_10_cor_neigh5 = rep(NA, length(out_sim_list)), SameRel_10_cor_neigh6 = rep(NA, length(out_sim_list)), SameRel_10_cor_neigh7 = rep(NA, length(out_sim_list)), SameRel_10_cor_neigh8 = rep(NA, length(out_sim_list)) ) for(i in 1:length(out_sim_list)){ k_cor_df$SameRel_5_cor[i] = #nearest 5 religion correlation cor(out_sim_list[[i]]$Nearest5_SameRel_samp, out_sim_list[[i]]$Nearest5_SameRel, use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor[i] = #nearest 10 religion correlation cor(out_sim_list[[i]]$Nearest10_SameRel_samp, out_sim_list[[i]]$Nearest10_SameRel, use = 'pairwise.complete.obs') k_cor_df$SameRel_15_cor[i] = #nearest 15 religion correlation cor(out_sim_list[[i]]$Nearest15_SameRel_samp, out_sim_list[[i]]$Nearest15_SameRel, use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor_neigh1 = #nearest 10 religion correlation, neigh x cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == 'Jaipur 1')], out_sim_list[[i]]$Nearest10_SameRel[which(out_sim_list[[i]]$A.A7 == 'Jaipur 1')], use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor_neigh2 = #nearest 10 religion correlation, neigh x cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == 'Jaipur 145')], out_sim_list[[i]]$Nearest10_SameRel[which(out_sim_list[[i]]$A.A7 == 'Jaipur 145')], use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor_neigh3 = #nearest 10 religion correlation, neigh x cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == 'Jaipur 30')], out_sim_list[[i]]$Nearest10_SameRel[which(out_sim_list[[i]]$A.A7 == 'Jaipur 30')], use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor_neigh4 = #nearest 10 religion correlation, neigh x cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == 'Jaipur 68')], out_sim_list[[i]]$Nearest10_SameRel[which(out_sim_list[[i]]$A.A7 == 'Jaipur 68')], use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor_neigh5 = #nearest 10 religion correlation, neigh x cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == 'Patna 42')], out_sim_list[[i]]$Nearest10_SameRel[which(out_sim_list[[i]]$A.A7 == 'Patna 42')], use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor_neigh6 = #nearest 10 religion correlation, neigh x cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == 'Patna 51')], out_sim_list[[i]]$Nearest10_SameRel[which(out_sim_list[[i]]$A.A7 == 'Patna 51')], use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor_neigh7 = #nearest 10 religion correlation, neigh x cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == 'Patna 82')], out_sim_list[[i]]$Nearest10_SameRel[which(out_sim_list[[i]]$A.A7 == 'Patna 82')], use = 'pairwise.complete.obs') k_cor_df$SameRel_10_cor_neigh8 = #nearest 10 religion correlation, neigh x cor(out_sim_list[[i]]$Nearest10_SameRel_samp[which(out_sim_list[[i]]$A.A7 == 'Patna 93')], out_sim_list[[i]]$Nearest10_SameRel[which(out_sim_list[[i]]$A.A7 == 'Patna 93')], use = 'pairwise.complete.obs') }#throws a warning about "standard deviation is 0", because sometimes by chance everyone in random sample has the same Nearest10 score #*******RESULT******# #Correlation between k-nearest score calculated for random sample of 60 individuals from each neighborhood, versus the same metric calculated for the entire neighborhood. The reported means and standard deviations of the correlations are for 500 random samples of 60 individuals from each neighborhood. #TABLE A1 mean(k_cor_df$SameRel_5_cor) # 0.7706546 sd(k_cor_df$SameRel_5_cor) # 0.02571546 mean(k_cor_df$SameRel_10_cor) # 0.8508894 sd(k_cor_df$SameRel_10_cor) # 0.01996775 mean(k_cor_df$SameRel_15_cor) # 0.8735986 sd(k_cor_df$SameRel_15_cor) # 0.01815468 ################################################################################################################################################