Problems 5

Question 1


Below are social network data collected from members of a book club at a university. The students were asked to rate ‘how much they interacted online’ with the other students over the last two weeks on a five-point Likert scale with ‘1’ being ‘very little’ and ‘5’ being ‘a great deal’.


Mark Gene 5

Mark Silvia 4

Mark Sarah 4

Mark Tim 2

Gene Mark 2

Gene Silvia 2

Gene Sarah 3

Gene Tim 4

Silvia Mark 2

Silvia Gene 2

Silvia Sarah 4

Silvia Tim 4

Sarah Mark 2

Sarah Gene 1

Sarah Silvia 2

Sarah Tim 4

Tim Mark 1

Tim Gene 3

Tim Silvia 2

Tim Sarah 4


a. Enter the data in a spreadsheet using the adjacency matrix format and save the result as a CSV file.


"ID","Gene","Mark","Sarah","Silvia","Tim"

"Gene",0,2,3,2,4

"Mark",5,0,4,4,2

"Sarah",1,2,0,2,4

"Silvia",2,2,4,0,4

"Tim",3,1,4,2,0


b. Import the data into an xUCINET project.


BookClub<-xCreateProject(GeneralDescription="Members of a university book club.",

NetworkName="Interaction",

NETFILE="C:/Users/Steve Borgatti/Documents/ucinet data/asnrp51.csv",

FileType="csv",

InFormatType="AdjMat",

NetworkDescription="Amount of online interaction 1= very little to 5 = a great deal",

Mode=c("People"),

Directed=TRUE,

Loops=FALSE,

Values="Ordinal",

Class="matrix",

References="No references")

BookClub$Interaction


Gene Mark Sarah Silvia Tim

Gene 0 2 3 2 4

Mark 5 0 4 4 2

Sarah 1 2 0 2 4

Silvia 2 2 4 0 4

Tim 3 1 4 2 0


It is somewhat surprising that the matrix is so asymmetric.


c. Symmetrize the data using the minimum.


intsym <- xSymmetrize(BookClub$Interaction)


d. Dichotomize the symmetrized data using greater than 3.


intsymdichgt3 <- xDichotomize(intsym,Value=3)

intsymdichgt3


Gene Mark Sarah Silvia Tim

Gene 0 0 0 0 0

Mark 0 0 0 0 0

Sarah 0 0 0 0 1

Silvia 0 0 0 0 0

Tim 0 0 1 0 0


e. Save the data (as a .RData file), and also export it as a CSV file.


save(intsymdichgt3, file = "intsymdichgt3.RData")

write.csv(intsymdichgt3, file = "intsymdichgt3.csv" )


"","Gene","Mark","Sarah","Silvia","Tim"

"Gene",0,0,0,0,0

"Mark",0,0,0,0,0

"Sarah",0,0,0,0,1

"Silvia",0,0,0,0,0

"Tim",0,0,1,0,0


f. What would have happened if we had first dichotomized the data using the ‘greater than 3’ rule, and subsequently symmetrized the data using the minimum?


# the result is the same


intdichgt3 <- xDichotomize(BookClub$Interaction, Value = 3)

intdichgt3sym <- xSymmetrize(intdichgt3)

intdichgt3sym

all(intsymdichgt3 == intdichgt3sym)


[1] TRUE


g. Save the dichotomized symmetrize matrix back into the BookClub project.


online <- intdichgt3sym

BookClub <- xAddToProject(BookClub,

NETFILE1=online,

NetworkName="Online interaction",

FileType = "Robject")

Problem 2


Demographic and attribute data were also collected (see below). Data include age, gender and attitude towards premarital sex on a Likert scale from 1 to 5 (with ‘1’ being ‘completely against’ and ‘5’ being ‘completely in favor’).


Age Gender (1=male, 2=female) Attitude towards premarital sex (1= against, 5 = in favor)

Mark 18 1 4

Gene 25 1 2

Silvia 19 2 2

Sarah 21 2 5

Tim 22 1 1


a. Enter the data in a matrix format in a csv file


# put rows in same order as the network matrix in problem 1


"ID","Age","Attitude","Female"

"Gene",25,2,0

"Mark",18,4,0

"Sarah",21,5,1

"Silvia",19,2,1

"Tim",22,1,0


b. Add the data to the xUCINET project dataset that contains the network from Problem 1


BookClub <- xAddAttributesToProject(ProjectName = BookClub,

ATTFILE1="C:/Users/steve borgatti/Documents/asnr/bookclubattr.csv",

FileType="csv",

Mode=c("People"),

AttributesDescription=c("Age in years","Female (0=Male, 1=Female)","Attitude toward premarital sex (1= against, 5 = in favor)"))

BookClub$Attributes


NodeName Age Attitude Female

1 Gene 25 2 0

2 Mark 18 4 0

3 Sarah 21 5 1

4 Silvia 19 2 1

5 Tim 22 1 0

.

c. Convert the Attitude variable into a node-by-node matrix using absolute difference. What do the values represent?


attabsdiff <- xAttributeToNetwork(BookClub$Attributes$Attitude, Type="AbsDiff")

> attabsdiff


[,1] [,2] [,3] [,4] [,5]

[1,] 0 2 3 0 1

[2,] 2 0 1 2 3

[3,] 3 1 0 3 4

[4,] 0 2 3 0 1

[5,] 1 3 4 1 0


The matrix shows how different in attitude towards pre-marital sex each pair of persons is. Nodes 3 and 5 (Sarah and Tim) are the most different in attitude (bad news for Sarah).


d. Convert the Gender variable into a node-by-node matrix using the difference. What does this result in?


attdiff <- xAttributeToNetwork(BookClub$Attributes$Attitude, Type="Diffij")

> attdiff


[,1] [,2] [,3] [,4] [,5]

[1,] 0 -2 -3 0 1

[2,] 2 0 -1 2 3

[3,] 3 1 0 3 4

[4,] 0 -2 -3 0 1

[5,] -1 -3 -4 -1 0


The result gives the row node's attitude minus the column node's attitude. Node 1's attitude minus Node 2's equals -2: Node 1 is less in favor of premarital sex than node 2.

Problem 3


In addition to the one-mode social network data above, two-mode data were also collected on which university events each had attended over the last six months. Here are the data:


Mark went to Hawking’s Lecture

Gene went to Hawking’s Lecture and Spring Concert

Silvia went to Hawking’s Lecture, Halloween Event, and Fall Dance

Sarah went to Hawking’s Lecture, Halloween Event, Spring Concert, and Fall Dance

Tim went to Halloween Event, Spring Concert, and Fall Dance


a. Format the data as a spreadsheet file using an adjacency matrix format, and save as a CSV file. [Note: the original question asked for a nodelist format, but this has not been implemented yet.]


"ID","Fall_Dance","Halloween_Event","Hawking_Lecture","Spring_Concert"

"Gene",0,0,1,1

"Mark",0,0,1,0

"Sarah",1,1,1,1

"Silvia",1,1,1,0

"Tim",1,1,0,1


b. Add the network to the project (from Problems 1 and 2) as a matrix object, and check the output when calling the resulting object.


BookClub<-xAddToProject(ProjectName=BookClub,

NetworkName="Attendance",

NETFILE1="C:/Users/steve borgatti/Documents/asnr/bookclubattendance.csv",

FileType="csv",

InFormatType="AdjMat",

NetworkDescription="Attendance at university events",

Mode=c("People","Events"),

Directed=FALSE,

Values="Binary",

Class="matrix")

BookClub$Attendance


Fall_Dance Halloween_Event Hawking_Lecture Spring_Concert

Gene 0 0 1 1

Mark 0 0 1 0

Sarah 1 1 1 1

Silvia 1 1 1 0

Tim 1 1 0 1


Problem 4


Finally, the students were asked who talks to whom about school-related matters.


Mark reports he talks to Gene, Silvia, and Sarah

Gene reports he talks to Tim

Silvia reports she talks to Tim and Sarah

Sarah reports she talks to Tim

Tim reports he talks to Sarah


a. Enter the data using the edgelist format and save as a CSV file. Import into R


Gene,Mark

Gene,Tim

Mark,Sarah

Mark,Silvia

Sarah,Silvia

Sarah,Tim

Silvia,Tim


fn = "c:/Users/steve borgatti/Documents/asnr/bookclubtalkstoel.csv"

dt <- read.csv(fn)

g <- igraph::graph.data.frame(dt, directed=TRUE)

talksto <- igraph::as_adj(g,sparse=FALSE)

talksto <- talksto[order(rownames(talksto)),order(colnames(talksto))]

talksto


Gene Mark Sarah Silvia Tim

Gene 0 0 0 0 0

Mark 1 0 1 1 0

Sarah 0 0 0 0 1

Silvia 0 0 1 0 1

Tim 0 0 1 0 0


b. Symmetrize the network using the ‘OR’ approach.


talkstosym <- xSymmetrize(talksto,Type="Max")

talkstosym


Gene Mark Sarah Silvia Tim

Gene 0 1 0 0 0

Mark 1 0 1 1 0

Sarah 0 1 0 1 1

Silvia 0 1 1 0 1

Tim 0 0 1 1 0

Problem 5


Imagine you would want to combine the dichotomized online interaction network (Problem 1) and the face-to-face talking network (Problem 4) into one matrix.


a. How would you go about making sure you are able to distinguish between ties where (a) members only talk face-to-face, but do not interact online, (b) members who only interact online, but not face-to-face, (c) where members do both, and (d) where members do neither? Import both datasets into R and use R to solve this.


f2f = talkstosym*2 #created in the last problem

interactswith = online + f2f #onine created in probem 1

interactswith


Gene Mark Sarah Silvia Tim

Gene 0 2 0 0 0

Mark 2 0 2 2 0

Sarah 0 2 0 2 3

Silvia 0 2 2 0 2

Tim 0 0 3 2 0


In this matrix, a 1 would mean online only, a 2 means f2f only, and a 3 means both online and face to face.


b. Given the type of data, could you consider a different approach of combining both data? Reflect on your answer.