|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rm(list=ls()) |
|
|
library(plyr);library(dplyr, warn.conflicts = F) |
|
|
library(tidyr) |
|
|
library(igraph) |
|
|
library(geosphere) |
|
|
library(ggplot2, warn.conflicts = F) |
|
|
library(tictoc) |
|
|
|
|
|
|
|
|
dir.create(paste0(getwd(), '/Output/')) |
|
|
dir.create(paste0(getwd(), '/Output/Network-sample-calculations/')) |
|
|
path0 = paste0(getwd(), '/Output/Network-sample-calculations/', Sys.Date(),'/') |
|
|
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] = |
|
|
cor(out_sim_list[[i]]$Nearest5_SameRel_samp, out_sim_list[[i]]$AllLinksSameRelig, use = 'pairwise.complete.obs') |
|
|
cor_df$Nearest10_SameRel_samp_AllLinksSameRelig[i] = |
|
|
cor(out_sim_list[[i]]$Nearest10_SameRel_samp, out_sim_list[[i]]$AllLinksSameRelig, use = 'pairwise.complete.obs') |
|
|
cor_df$Nearest15_SameRel_samp_AllLinksSameRelig[i] = |
|
|
cor(out_sim_list[[i]]$Nearest15_SameRel_samp, out_sim_list[[i]]$AllLinksSameRelig, use = 'pairwise.complete.obs') |
|
|
|
|
|
|
|
|
|
|
|
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') |
|
|
|
|
|
|
|
|
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') |
|
|
|
|
|
|
|
|
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') |
|
|
|
|
|
} |
|
|
toc() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mean(cor_df$Nearest5_SameRel_samp_AllLinksSameRelig) |
|
|
sd(cor_df$Nearest5_SameRel_samp_AllLinksSameRelig) |
|
|
mean(cor_df$Nearest10_SameRel_samp_AllLinksSameRelig) |
|
|
sd(cor_df$Nearest10_SameRel_samp_AllLinksSameRelig) |
|
|
mean(cor_df$Nearest15_SameRel_samp_AllLinksSameRelig) |
|
|
sd(cor_df$Nearest15_SameRel_samp_AllLinksSameRelig) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sum(dat$AllLinksSameRelig < 1, na.rm = T) / sum(dat$Nearest10_SameRel <= 10, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel == 10, na.rm = T) / sum(dat$Nearest10_SameRel == 10, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 10, na.rm = T) / sum(dat$Nearest10_SameRel < 10, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 9, na.rm = T) / sum(dat$Nearest10_SameRel < 9, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 8, na.rm = T) / sum(dat$Nearest10_SameRel < 8, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 7, na.rm = T) / sum(dat$Nearest10_SameRel < 7, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 6, na.rm = T) / sum(dat$Nearest10_SameRel < 6, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 5, na.rm = T) / sum(dat$Nearest10_SameRel < 5, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 4, na.rm = T) / sum(dat$Nearest10_SameRel < 4, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 3, na.rm = T) / sum(dat$Nearest10_SameRel < 3, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 2, na.rm = T) / sum(dat$Nearest10_SameRel < 2, na.rm = T) |
|
|
sum(dat$AllLinksSameRelig < 1 & dat$Nearest10_SameRel < 1, na.rm = T) / sum(dat$Nearest10_SameRel < 1, na.rm = T) |
|
|
s(dat$Nearest10_SameRel) |
|
|
|
|
|
sum(dat$Nearest10_SameRel == 10, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 10, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 9, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 8, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 7, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 6, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 5, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 4, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 3, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 2, na.rm = T) |
|
|
sum(dat$Nearest10_SameRel < 1, na.rm = T) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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] = |
|
|
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] = |
|
|
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] = |
|
|
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 = |
|
|
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 = |
|
|
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 = |
|
|
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 = |
|
|
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 = |
|
|
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 = |
|
|
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 = |
|
|
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 = |
|
|
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') |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mean(k_cor_df$SameRel_5_cor) |
|
|
sd(k_cor_df$SameRel_5_cor) |
|
|
mean(k_cor_df$SameRel_10_cor) |
|
|
sd(k_cor_df$SameRel_10_cor) |
|
|
mean(k_cor_df$SameRel_15_cor) |
|
|
sd(k_cor_df$SameRel_15_cor) |
|
|
|