# Calculating Network Homophily – Part 2

In an earlier post, we learned a command for one type of network homophily in R: the proportion of ties in a social network connecting two actors matching on a given characteristic. Today, we’ll build a command for calculating a second conception of network homophily. Specifically, this is the average proportion of characteristic matching within ego-networks, or the neighborhoods of each individual node.

First, let’s load igraph as we always do for these commands, and install it first if you need it:

Next, we’ll build the function for the ego-network homophily score, again commenting to describe each step in the function:

Continue reading

# Calculating Network Homophily – Part 1

A student in the Networks course recently asked for help calculating homophily scores for the network data she had collected, and I was surprised to find that no command exists in R to calculate network homophily, or the proportion of shared ties among nodes with shared attributes. After doing a little background digging, I now suspect that this is in part due to some disagreement on what constitutes homophily in a social network at all!

Broadly, there are two basic approaches to measuring homophily in a network. The first is the proportion of all edges in a network (ties between actors) which bridge two actors with matching characteristics on some dimension. For example, gender homophily could be calculated for both males and females. Male homophily would be calculated as the total number of edges that exist between two males, expressed as a proportion of the total number of edges involving at least one male. A second approach would start by calculating same gender alters as a proportion of total ego network alters, and then averaging across egos with a given characteristic (e.g., male or female) to get average ego network homophily.

Today, we’re going to focus on how to implement the first approach in R. First, we need to load the necessary library to perform these functions, and install it if it’s not already on our computer:

Continue reading