R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(igraph)
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
g5 <- graph_from_literal(Lillie-Mom-Dad-Liz-Kate-Lillie, Sylvia-Mom, Lillie-Nat:Dani, Lillie-Dani, Dani-Joyce, Lillie-Francine-Alicia-Nat-Lillie)

plot(g5)

Scenario

A fitness-apparel brand is launching a new product and can give free samples to only two people. The network below shows who influences whom on social media. Use network metrics to decide who should receive the samples.

library(igraph)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:igraph':
## 
##     as_data_frame, groups, union
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# A social media network around a brand
g_mkt <- graph_from_literal(
  Brand-Ava-Ben-Cara,       # chain of connections
  Brand-Cara,
  Ava-Dan:Eli:Fay,          # Ava is connected to Dan, Eli, and Fay
  Ben-Gus,
  Cara-Hal:Ivy,
  Dan-Eli,
  Fay-Gus,
  Hal-Ivy-Jon,
  Brand-Kim-Jon
)

set.seed(123)  # fixes the layout so the plot looks the same each time
plot(g_mkt, vertex.color = "lightpink", vertex.label.color = "black")

Tasks

Task 1: Visualize the network

Look at the plot above. Who looks most “central” visually? Identify any cliques (tightly connected groups).

Answer: The most “central” people in this graph appear to be Ava, Ben, Brand, and Cara.They are near the main connected part of the visual and are connected to multiple people. Ava, Dan, and Eli may be a potential clique, since Ava is connected to both Dan and Eli, and Dan and Eli are connected to each other. Hal and Ivy are directly connected, and both connect to Cara and Jon through the network structure. They form a tight cluster.

Task 2: Compare centrality measures

Compute degree, closeness, and betweenness, then put the results in one data frame and rank the nodes.

centrality_df <- data.frame(
  person      = V(g_mkt)$name,
  degree      = degree(g_mkt),
  closeness   = round(closeness(g_mkt), 3),
  betweenness = round(betweenness(g_mkt), 2)
)

centrality_df %>% arrange(desc(betweenness))
##       person degree closeness betweenness
## Ava      Ava      5     0.050       25.83
## Cara    Cara      4     0.048       18.17
## Brand  Brand      3     0.050       17.00
## Ben      Ben      3     0.048       13.33
## Kim      Kim      2     0.037        5.00
## Ivy      Ivy      3     0.037        4.50
## Fay      Fay      2     0.036        2.17
## Gus      Gus      2     0.034        1.50
## Jon      Jon      2     0.033        1.50
## Dan      Dan      2     0.034        0.00
## Eli      Eli      2     0.034        0.00
## Hal      Hal      2     0.034        0.00

Answer: The highest-ranking people for each measure are: Degree: Ava ranks first with 5 connections, followed by Cara with 4. Degree measures the number of direct connections a person has.

Closeness: Ava and Brand tie for first at 0.050. Closeness measures how near a person is to everyone else through shortest paths.

Betweenness: Ava ranks first at 25.83, followed by Cara at 18.17 and Brand at 17.00. Betweenness measures how often a person lies on the shortest paths connecting other pairs of people.

The rankings do not agree with each other. Ava ranked first in two categories (degree and betweeness), which makes her a strong candidate. However Cara also ranks relatively high in all categories. Brand also has good scores despite having less connections as shown in the direct networking visual.

Task 3: Choose two seed customers

Which two people should receive free samples? Justify your choice using at least two different metrics. (Hint: is high degree the same as being a bridge?)

Answer: I would choose Ava and Cara to receive the free samples. Ava has the highest degree (5) and the highest betweenness (25.83). She can directly reach five connections and is also important for connecting different parts of the network. This makes her a strong choice for generating referrals. Cara has the second-highest degree (4) and the second-highest betweenness (18.17). She connects the Brand–Ben portion of the network to the Hal–Ivy group. Giving Cara a sample would help spread awareness to people who might not be reached. I think a person can have a high degree without having a high bridge. Someone with fewer connections may still act as an important bridge between groups.