les miserables graph

v4vaqvtran
timer Asked: Mar 7th, 2017

Question Description

Q1. One premise of the Strength of Weak Tie theory is that, the stronger the tie between two people is, the more likely their contacts will overlap so that they will have common ties with the same third parties. Test this hypothesis for the les miserables graph we studied in class. The following code block prints the number of shared neighbors for the endpoints of every edge:

for(i in E(g)){
a = ends(g, i)[1]
b = ends(g, i)[2]
source_neighbors = neighbors(g, a)
target_neighbors = neighbors(g, b)
num_overlap_neighbors = length(intersection(source_neighbors, target_neighbors))
print(num_overlap_neighbors)
}

1. Rewrite it as a function that takes i as its input (an edge i), and gives the number of overlapping neighbors of edge i's endpoints as output. For example if the function name is get_overlap then given the input 24 the output should be
get_overlap(24)
[1] 6

Hint: to define a function in R

get_overlap = function(i){

a = ends(g, i)[1]
b = ends(g, i)[2]
source_neighbors = neighbors(g, a)
target_neighbors = neighbors(g, b)
num_overlap_neighbors = length(intersection(source_neighbors, target_neighbors))

return(num_overlap_neighbors)

}


2. use sapply() to apply the function to E(g) to get a vector as output: sapply(E(g), get_overlap)


3. Run a regression with the tie strength (measured as the edge weight, which is the value attribute) as the dependent variable and number of shared neighbors as the independent variable. What is your conclusion? Submit a single Word/Pdf file with R code attached at the end. Please DO NOT submit a zip file.

Hint:

To run a linear regression in R use lm() function

lm(y ~ x)

where y would be E(g)$value, and x would be the vector you constructed in step 2.

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors