File size: 1,470 Bytes
3af64c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#Table 5: Correlations of k-nearest-neighbors metric, 
#calculated from neighborhood census network data,  
#with the proportion of social links to members of the same group.

#install packages
# install.packages('plyr')
# install.packages('dplyr')
# install.packages('tidyr')
# install.packages('ggplot2')
# install.packages('igraph')
# install.packages('geosphere')
# install.packages('tictoc')

rm(list=ls())
library(plyr);library(dplyr, warn.conflicts = F)
library(tidyr)
library(igraph, warn.conflicts = F)
library(geosphere)
library(ggplot2)
library(tictoc)

#setwd() #set working directory

s = function(x){summary(factor(x))}

#Read data
dat3 = readRDS('4-20-20_Network-KNearest_DeID_demed.RDS')
##########################################################################################

#Relationships between census-nearest-K and census-contact
#These are basis for manually-created Table 5

cor(dat3$Nearest5_SameRel, dat3$AllLinksSameRelig, use = 'pairwise.complete.obs') #0.3779793
cor(dat3$Nearest10_SameRel, dat3$AllLinksSameRelig, use = 'pairwise.complete.obs') #0.4163651
cor(dat3$Nearest15_SameRel, dat3$AllLinksSameRelig, use = 'pairwise.complete.obs') #0.4222002

cor(dat3$Nearest5_SameCaste, dat3$AllLinksSameCaste, use = 'pairwise.complete.obs') #0.47723
cor(dat3$Nearest10_SameCaste, dat3$AllLinksSameCaste, use = 'pairwise.complete.obs') #0.5185767
cor(dat3$Nearest15_SameCaste, dat3$AllLinksSameCaste, use = 'pairwise.complete.obs') #0.5329627