packages = c("splitstackshape", "stringr", "igraph", "spdep", "magrittr", "htmlwidgets", "htmltools", "plotly","networkD3","spatialreg","ggplot2","classInt","RColorBrewer")

## Now load or install&load all
package.check <- lapply(
  packages,
  FUN = function(x) {
    if (!require(x, character.only = TRUE)) {
      install.packages(x, dependencies = TRUE)
      library(x, character.only = TRUE)
    }
  }
)

Module 1 purpose & interpretation:

In this first module we explore the Scopus database, choose a topic of interest, and perform the necessary transformations to build an initial graph of the connections of co-authors (ignoring single authors). The purpose of the analysis is to better understand the interactions academics as it relates to publishing in a specific field of interest, which, for me, is in border studies. It’s important to consider what key word limits, time range, type of publication, country of origin, document type, etc. to employ as you create this data subset in Scopus that will best serve the analysis you are doing. For me I choose the widest range of time and include as many relevant key words to make sure I have the broadest sampling possible within the border studies field. For other people, maybe they specifically want to look at how borders are being talked about in the U.S. only, then they might pose a more limited search. The purpose of the analysis here, which is mostly data cleaning, is to prepare the an adjacency list of co-authors. This is done by formatting the authors names to avoid special symbols or prefixes / suffixes, then splitting the authors column list of names to get each individual author in their own column, then looping through those columns to get down to a two column list of each co-authorship pair. This adjacency list is then used to make the graph visual.

The interpretation of making the graph is limited, which is fine considering this is just a first step in visualizing the network. It is not clean enough to understand anything from it at this point, but that will be developed in later modules. The analysis of the dimensions of the adjacency list and connections in the graph allow us to see how many unique articles and authors there are, and the number of connections (co-author pairings) we have. In the analysis we also rank the co-authorship pairings to see who are the most prolific co-author pairs, meaning the co-author pairs that have published together the most. We inspect some of the abstracts of the papers that these pairings published to see what these articles are about and begin to understand what the most important topics are in the border studies field.

1 Module: Data Formats and Transformations I (one-mode)

For this deliverable you will need one publication dataset of a topic and time frame of your interest. You can create this file from Scopus as discussed in class. Please explain the dataset used indicating the time frame, the topic and other inclusion criteria like type of publication, for example. For this deliverable make sure to describe:

1.1 The topic you selected (with a description of why you are interested in such a topic)

I have decided to search scopus based on “border” as a key word because I have become interested in border studies and how border policies effect migration and human rights protections, for this reason as well I’ve applied the key word limits of “borders”, “migration”, “mobility”, and “refugee”. I’ve been interested in migration issues for a long time but this semester I’m taking a political science course that focuses on Borders in International Relations and I’ve learned how important it is to account for border policy while looking at migration. I will use the social sciences as my subject area because most papers and authors I’d be interested in work within political science, sociology, etc. I’m open to Spanish or English language sources and feel it’s important to include Spanish in this search considering a lot of border policy work is looking at the US-Mexico border. On the other hand, there are a plethora of borders throughout the world that merit study so I am not limiting the country/ territory.

In sum:
key word search: border
key word limits: borders, migration, mobility, refugee
subject: social sciences
2010-2024
document type: articles
languages: sspanish and english
any country or territory
source type: journal

1.2 The time span (illustrate why you selected this time span)

I’m considering the time period 2010-2024 (present) in my search because a lot of migration scholars consider that modern day large migration waves came after Arab Spring in 2010, and I’m going to present day because clearly border issues are still very prevalent and evolving.

1.3 Type of publication (journal article, conference papers, book chapters or all types) mentioning also why you selected this topic.

I’ve chosen to consider Journal articles only since this is the source that would be most helpful to me in continuing to learn about border issues, additionally this is the only type of source we’ve considered in my class.

1.4 Create a co-authorship network wherein all relationships among coauthors are established.

#clean data, prepare author names that match ID, get one-mode matrix g and two-mode matrix g2 

source <- read.csv("scopus_final.csv")
#dim(source)
# clean the data, keep only authors where ID is included 
source <- source[source$Author.s..ID!="[No author id available]",]
#--> we see that all rows are kept, so all authors had an ID
#dim(source)

#try 2
#Let's take out only the column with author relationships:
authors<-as.data.frame(source[,1]) #take first column, all rows
colnames(authors)<-"Authors" #same column name as original data set

#Since next step is to separate all names, we need to consider how they are separated in papers with multiple co-authors, also need to account for different name suffixes:

#Addressing names and titles  
authors$Authors <- gsub(" Jr.,", "", 
                  gsub(" II.,", "", 
                       gsub(" Jr.", "",
                            gsub(" M.S.", "",
                                 gsub(" M.S.,", "",
                                      gsub(" II.", "", authors[,1]))))))

#authors$Authors <- gsub("\\.,", ";",authors$Authors) #-> not needed because data set already formatted with ; between each name
#Lower case all the text to avoid the same author being recognized two in case of accidental lack of capitalized letters in one instance of their name.
authors$Authors <- tolower(authors$Authors)

a1<-cSplit(authors, splitCols = "Authors", sep = ";", direction = "wide", drop = FALSE) #retain the matrix form version of the adjacency list input
#Here we just drop the original first column, which is where the complete list of coauthors for each paper is held
a1<-a1[,-1]

#read it as a matrix
mat <- as.matrix(a1)
a1<-mat
edgelist1<-matrix(NA, 1, 2)#empty matrix two columns
for (i in 1:(ncol(a1)-1)) {
  edgelist11 <- cbind(a1[, i], c(a1[, -c(1:i)]))
  edgelist1 <- rbind(edgelist1,edgelist11)
  edgelist1<-edgelist1[!is.na(edgelist1[,2]),]
  #handles where it's not considered empty but it's missing
  edgelist1<-edgelist1[edgelist1[,2]!="",]
  }
#dim(edgelist1)

plot(graph.edgelist(edgelist1))

g<- graph.edgelist(edgelist1, directed = FALSE)
#weight exists in igraph (it's a hidden attribute)
E(g)$weight <- 1 #must step
#simplify command "collapses" it -- i.e. it takes the long list of relationships where A - B can be listed multiple times, so that it only has A - B once but the weight is the sum of how many times A - B showed up
g.c <- simplify(g)
#E(g.c)$weight 
links<-as.data.frame(cbind(as_edgelist(g.c), E(g.c)$weight))
#links
#dim(links)
links$V3<-as.numeric(links$V3)
links<- links[order(links$V3, decreasing=T),]
#table(links[,1])

1.5 After this, describe the network, how many authors are represented, how many connections are in this network?

#number articles
dim(source)
## [1] 2354   29
#number connections in network
dim(edgelist1)
## [1] 7639    2
#number coauthor pairs (after using weights and simplify to account for when pairs have done multiple papers)
dim(links)
## [1] 7540    3
#number authors (collapsing links to be authors alone)
dim(table(links[,1]))
## [1] 1470

From the 2,354 journal articles included in our data set, there are 7,540 unique co-author partnerships represented in this network with 1,470 unique individual authors. The network itself is showing all the edge list connections of co-author pairs (before weighting gets all unique co-author partners), of which there are 7,639. *This means that there are 7639-7540=99 instances where a co-author pairing has published more than once together.

1.6 Who are the top five most prolific co-authors? What are they publishing about?

head(links[order(links$V3, decreasing=T),],10)
##                    V1             V2 V3
## 106   casas-cortes m. cobarrubias s.  6
## 277         davies t.     isakjee a.  4
## 139         perret s.      aradau c.  3
## 565    gritsenko a.a.    zotova m.v.  3
## 602      kolosov v.a. sebentsov a.b.  3
## 1145      ladino m.t.    gatica y.c.  3
## 1437 van den broek j.      rutten r.  3
## 1438 van den broek j.  benneworth p.  3
## 1440        rutten r.  benneworth p.  3
## 1690       marsico g.       tateo l.  3

The top five most prolific co-authoring pairings are Casa-Cortes M. & Cobarrubias S. with 6 works together; Davies T. & Isakjee A. with 4 works together; and then there are 9 other co-author pairings that each have 3 works together.

### I used ChatGPT to help with this code block

# List of authors in copairing 1
selected_authors <- c("cobarrubias s.","casas-cortes m.") 
#put source to lowercase
source$Authors <- tolower(source$Authors)
#finds rows (articles) where both of the authors of interest are listed in the Authors column
matches <- sapply(source$Authors, function(x) all(sapply(selected_authors, function(Authors) grepl(Authors, x))))
# filter out the rows where there is a match
filtered_abstracts <- source$Abstract[matches]
# Print the filtered abstracts
print(filtered_abstracts)
## [1] "The soviet social theorist Mikhail M. Bakhtin developed the theory of the carnivalesque as a logic of exaggeration, inversion and irony. Beyond carnival events themselves, Bakhtin proposed this logic as a creative instance to foresee openings within an assumed normality. The conceptual gaze of the ‘carnivalesque’ helps to rethink the reconfiguration of actors and practices around mobility, borders and migration during the initial lockdowns of the COVID-19 pandemic. This impasse worked as a corona-carnival in the midst of the current mobility regime. The use of ‘carnivalesque’ in this article is not related to the playful aspects of carnival as a parade, but to the potential of the carnivalesque impasse for envisioning alternatives, which are not necessarily emancipatory but deeply ambivalent, grotesque and unfinished. That carnivalesque momentum, marked by social norms placed on pause, is captured in artistic and linguistic production, acting as a collective legacy for imagining futures otherwise. This paper compiles some keywords which emerged during the corona-carnival impasse, each holding hopeful and dystopian glimpses of possible alterations to the status-quo. These linguistic productions question assumed notions and practices of migration management, opening the social imagination to other ways of engaging with human mobilities. © The Author(s) 2023."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
## [2] "[No abstract available]"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
## [3] "Migration movements and migratory controls are becoming a hot topic within academia, governmental institutions and media circles. Beyond conventional approaches to human mobility and its management, alternative interpretations are surfacing with important epistemological, methodological and political repercussions. This piece focuses on the emergent school of thought known as “Autonomy of Migration”. By engaging the textual production and projects (including cartographies) of key authors and collectives of this tradition, we identify central concepts of this political, theoretical and methodological school of thought. We also trace a genealogy of this tradition, pointing to the different historical contexts from which it emerged and expanded to several scholarly fields and activist initiatives, including some of the critical reactions to its possible limitations. This article includes a brief discussion on its methodological underpinnings through an empirical case. © 2020 Universidad Nacional de Educacion a Distancia. All rights reserved."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
## [4] "The generative power of mapping speaks to the material effects produced by maps and their capacity to order particular social and spatial relations. By focusing on the role that maps and mapping practices play within the politics of migration - the contentious field of actions and relations which determines who can move and in what condition -, we show how cartography is in fact used both as a practice for the control and government of mobility as well as a tool for advocating, facilitating and even embodying, border crossing. We make this point by engaging two stories related to the mapping EU's external borders in which we have been directly involved as researchers and activists: the first one concerning the mapping of migrants' routes, the second looking instead at the surveillance of maritime borders. In both cases, we point to an on-going \"clash of cartographies\" in the current flurry of charting borders and flows, showing how cartography works on the ground for both the world of migration management and the struggles for free movement."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
## [5] "In recent years border externalization has emerged as a central policy framework for European Union (EU) border and migration management. New multi-lateral and bi-lateral agreements on border management have been forged between the EU, its member states, and its North African neighbours and neighbours-of-neighbours. In the process, what is meant by the ‘border’ is being transformed with implications for where the border is located, who has jurisdiction over particular spaces, and how border and migration management is undertaken. This paper analyses the spatial logics of EU border externalization practices as they are being applied to and in North and West Africa. It focuses on Operation Seahorse and the transnationally coordinated border control projects and infrastructures implemented by the Guardia Civil of Spain. Seahorse serves as an implementation case of the Migration Routes Initiative, an approach toward migration management emphasizing interregional cooperation between designated origin-transit-destination countries. The initiative is the organizing strategy of the Global Approach to Migration, the EU’s overarching framework toward migration policy. The paper shows how Seahorse is changing migration policy and re-articulating Europe’s relations with African countries, producing new bordering processes, creating new geographies of integration and border management, and redefining the practices of territory, sovereignty, and extra-territoriality. © The Author(s) 2014."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
## [6] "Despite technological upgrading of borders at the edges of Europe, \"Fortress Europe\" continues to fail as an effective means of controlling irregular migration. As a consequence, European states are restructuring their border regimes by externalizing migration management to non-EU countries beyond the border and creating new programs and policies to do so. Autonomy of Migration (AoM) offers a distinct way for thinking about border control mechanisms and goals of managing mobility. AoM does not read this off-shoring of borders through the lens of centralized and coordinated state powers, but develops an autonomous gaze that supplements these institutional readings of apparatuses of capture with a view that takes as its starting point the ways in which border architectures, institutions, and policies interact with and react to the turbulence of migrant mobilities. By engaging current EU externalization policies, this paper illustrates the shifting relationship between border control and mobility. Resumen: A pesar de las actualizaciones tecnológicas recientes de la frontera en el perímetro de la Unión Europea, la llamada \"Europa Fortaleza\", tanto como metáfora como realidad, continua sin poder controlar la migración irregular. En respuesta, los estados miembros de la Unión están restructurando sus sistemas fronterizos externalizando la gestión migratoria a países no miembros de la UE, delegando funciones de control migratorio a países fuera de la frontera europea. El enfoque de la Autonomia de la Migracion (AoM) ofrece un anáisis poco común para pensar los mecanismos de control fronterizo y sus objetivos de gestionar la movilidad humana. AoM no interpreta dicho desplazamiento de fronteras únicamente desde la óptica del poder estatal centralizado. AoM ofrece una mirada autonoma de la movilidad, complementando esas lecturas institucionales que enfatizan los aparatos de captura. Así, AoM enfatiza la turbulencia de las migraciones como parte constituyente, y no solo receptiva, de las arquitecturas, instituciones y políticas fronterizas. Este artículo sobre la externalización de las politicas fronterizas de la Union Europea ilustra la relación productiva entre control migratorio fronterizo y movilidad migratoria. © 2015 Antipode Foundation Ltd."

We can see that Casa-Cortes M. & Cobarrubias S. tend to focus on Europe / the European Union, mapping and cartographic processes as they relate to bordering, and the externalization or pushing back of borders.

### I used ChatGPT to help with this code block
# List of authors in copairing 2
selected_authors <- c("davies t.",  "isakjee a.") 
#put source to lowercase
source$Authors <- tolower(source$Authors)
#finds rows (articles) where both of the authors of interest are listed in the Authors column
matches <- sapply(source$Authors, function(x) all(sapply(selected_authors, function(Authors) grepl(Authors, x))))
# filter out the rows where there is a match
filtered_abstracts <- source$Abstract[matches]
# Print the filtered abstracts
print(filtered_abstracts)
## [1] "This article examines the eco-coloniality of the UK–France border by tracing the transformation of the notorious Calais “jungle” refugee camp into a nature reserve. We empirically investigate the ecological politics of the Calais borderzone, arguing that the environment plays a crucial role in both enacting and obscuring border violence. Based on long-term research at this site, we explore how the environment does political work by excluding, harming, and erasing the presence of racialized migrants from the shores of the English Channel. Taking a critical postcolonial approach, we argue that environmental ideas that were once forged during empire—including the imperial origins of environmentalism—continue to shape the marginalization of racialized groups today. By deepening our understanding of what counts as border violence and tracing the colonial genealogy of violent environmentalism, this article develops the concept of ‘eco-coloniality’. This builds upon burgeoning research at the intersection of border studies and political ecology, which has explored the co-option of ‘nature’ into violent border practices, and the deepening links between eco-fascism and exclusionary migration regimes. At a time of heightened environmental disruption, we emphasize the importance of unearthing the roots that connect contemporary politics with the perennial legacies of colonialism. Ultimately, we suggest that the protection of the environment, both at the border and during empire, has been used as a pretense for dispossessing racialized groups. © The Author(s) 2024."
## [2] "This article focuses on the advancement of fantasy policy solutions to irregular migration, drawing on the case study of the UK/French border. In 2018 people began to cross the English Channel in significant numbers to seek asylum. This led to much commentary and a raft of new legislation seeking to criminalise people crossing the Channel and end rights to seek asylum in the UK. In this article, we explore the interaction between two sets of fantasies that are advanced by politicians and mainstream political parties in the UK. That is: the liberal technocratic fantasy–that this phenomenon can be efficiently ‘fixed’ through interventions in policing and multilateral cooperation with neighbouring EU states; and the illiberal fantasy that extreme and performative punishments can solve it. These fantasies intersect and break at different points in time, and involve many of the same policy solutions which are represented in different terms. Importantly, both of these fantasies reproduce racialised and colonial logics and ultimately serve border imperialism. © 2024 The Author(s). Published by Informa UK Limited, trading as Taylor & Francis Group."                                                                                                                                                                                                                                                                                                                                                                                                                                     
## [3] "Borders are sites of epistemic struggle. Focusing on the illegal tactic of the “pushback,” which is routinely deployed by state authorities to forcefully expel asylum seekers from European Union territory without due process, this article explores the uneven politics of knowledge that helps to support or unsettle this clandestine border violence. Drawing on long-term qualitative research on the Croatia–Bosnia border, including interviews with pushback survivors and activists, as well as a database of border violence reports, we explore the competing truth claims and epistemologies that help to conceal, or counter, the pushback regime. Informed by postcolonial perspectives and contributing to political geographies of violence, we argue that “epistemic violence” (Spivak 1988) is a central feature of contemporary borders. We propose that epistemic borderwork is regularly used by state authorities to silence unwanted voices, undermine insurgent perspectives, and stifle the capacity of refugees to draw attention to their own mistreatment. In opposition to this injustice, activists are documenting, mapping, and archiving pushback survivor testimony to construct a counternarrative of refusal, which subverts the harmful knowledge claims of state authorities. In doing so, refugees and activists create epistemic friction, which helps to resist the ontological violence of borders, and “pushes back” against the pushback regime. © 2022 The Author(s). Published with license by Taylor & Francis Group, LLC."                                                               
## [4] "This paper examines how racial violence underpins the European Union’s border regime. Drawing on two case studies, in northern France and the Balkans, we explore how border violence manifests in divergent ways: from the direct physical violence which is routine in Croatia, to more subtle forms of violence evident in the governance of migrants and refugees living informally in Calais, closer to Europe’s geopolitical centre. The use of violence against people on the move sits uncomfortably with the liberal, post-racial self-image of the European Union. Drawing upon the work of postcolonial scholars and theories of violence, we argue that the various violent technologies used by EU states against migrants embodies the inherent logics of liberal governance, whilst also reproducing liberalism’s tendency to overlook its racial limitations. By interrogating how and why border violence manifests we draw critical attention to the racialised ideologies within which it is predicated. This paper characterises the EU border regime as a form of “liberal violence” that seeks to elide both its violent nature and its racial underpinnings. © 2020 The Authors. Antipode published by John Wiley & Sons Ltd on behalf of Antipode Foundation Ltd."

We can see that Davies T. & Isakjee A. tend to focus on the UK-France border, specifically on migrants living in the Calais “jungle” refugee camp. They examine violence and the role of colonial pasts in border enforcement.

1.7 Why would be challenging to talk about most prolific authors? (hint, solo author issue in this approach).

We would not be able to identify the most prolific author with this information because we are only counting co-author relationships. For example, say there is an author that only publishes alone but is very prolific – they would not be counted in this network at all.

Module 2 purpose & interpretation:

Moving from the co-authorship adjacency list and graph created in the first module, where we used the authors written names, in this module we will now use the authors assigned IDs instead. The purpose of using author IDs instead of names is to account for when author’s names may have changed or been written incorrectly in the data set. This is done by splitting the author ID column list of names to get each individual author ID in their own column, then an unlisting is performed to get all the IDs stacked on top of each other. Duplicates can then be removed to get down to a unique column of author IDs. Separately, before removing duplicates, we use the table function to see the count of publications for each author ID.

The interpretation here is mostly in the analysis of the dimensions of the author ID list, which shows us that there were not any misspelled or changed names to worry about since it matched the dimension of the author name unique list. In the analysis we also rank authors to see who are the most prolific. We inspect some of the abstracts of the papers that these authors published to see what these articles are about and even further our understanding of the more common and important topics in the border studies field.

2 Module: using IDs

# Creating adjacency list from names
#we already have this from above, but we can recall it as follows
a1<-cSplit(authors, splitCols = "Authors", sep = ";", direction = "wide", drop = FALSE) #retain the
a1<-a1[,-1]

#Adjacency list from authors' IDs, that is, split the authorsID column
df_authors_id <- as.data.frame(source[ , 3])
colnames(df_authors_id) <- "AU"
author_id_split <- cSplit(df_authors_id, splitCols = "AU", sep = ";", direction = "wide", drop = TRUE) 
dim(author_id_split) 
## [1] 2354   93
dim(a1)
## [1] 2354   93

2.1 With your own words, explain what problems we aimed to solve with the creation of an ID adjacency list and a names adjacency list?

Authors’ names may be misspelled or changed over time, but their ID number will not. Looking at IDs instead of names allows for better accuracy.

2.2 During your cleaning procedures, did your adjacency lists for names and ID have the same dimensions?

2.2.1 If so, what is the meaning of these dimensions?

Yes, they did! The dimensions of both are 2354, 93, meaning that there are 2,354 articles included in this data set and there is at least one article with 93 total co-authors on it.

2.2.2 Let us assume that you did not have the same dimensions, what would be the reason for this discrepancy and how would you address this issue?

If the dimensions were different that would mean that some author’s whose names showed up did not show up as IDs, or vice versa. We would address this by looking at the rows (articles) where there are not an equal number of author name / ID columns that are filled in (not NA). We would then need to investigate each row with this issue.

2.3 As part of the feature engineering procedures, we created a database with ID and Name columns.

2.3.1 What is the meaning of the number of rows of this database?

The number of rows is the number of unique individual authors we have within our dataset, which is 3,274.

2.3.2 Does this number match the number of unique actors you have in your first deliverable in the object g (i.e., the graph we created)?

No it does not, there were 7,639 connections there where as we have 3,274 now.

2.3.3 If the number does not match, what do you think is the reason for this mismatch?

It does not match because the graph in module 1 was representing co-authorship pairs, clearly it will be a larger number as each individual author can have multiple coauthor pairings with other individual authors.

2.4 Please explain the role of unlisting in this data cleaning or feature engineering process.

#unlisting the values of the adjacency matrices
df_authorid_authorname_unlisted <- data.frame(id = unlist(author_id_split), names = unlist(a1))

dim(df_authorid_authorname_unlisted)
## [1] 218922      2
#gets rid of where the id is missing
df_authorid_authorname_unlisted <- df_authorid_authorname_unlisted[!is.na(df_authorid_authorname_unlisted$id),]
dim(df_authorid_authorname_unlisted)
## [1] 4000    2
#gets rid of duplicates
df_authorid_authorname_unlisted <- df_authorid_authorname_unlisted[!duplicated(df_authorid_authorname_unlisted$id),]
dim(df_authorid_authorname_unlisted)
## [1] 3274    2
head(df_authorid_authorname_unlisted)
##                 id           names
## AU_011 57196458199        milan c.
## AU_012 56684310700     esposito f.
## AU_013 56135176100 castro neira y.
## AU_014 55086379400     lonergan g.
## AU_015 57188966884      baykurt b.
## AU_016 59312942500       sigala m.

The unlisting is used to take multiple names or IDs that are stored in separate columns and stack them all on top of each other to get only one column of all author names and one column of all author IDs. It works well for us because the articles are in the same order in each matrix so as we unlist and stack all the names / IDs it acts to pair each name and ID together. For example, if the first row (article) has two authors, then when we unlist that row we will have author ID 1 in row 1, column 1 and author ID 2 in row 2, column 1; while we have author name 1 in row 1 column 2 and author name 2 in row 2 column 2. Thus it shows that author name 1 and author ID 1 are a pair and that author name 2 and author ID 2 are a pair. We then later get rid of NA or missing values, and then we use the remove duplicates so that we get down to a unique list of authors where each one is listed only one time. Notice how the dimensions is reduced with the removal of duplicates (Not with NA because there weren’t any).

2.5 Who are the top five most prolific authors? And what are they publishing about?

#most Prolific authors by ID
pub_count <- as.data.frame(table(unlist(author_id_split))) #table command will list # of times in the matrix certain IDs appear

#adding pub_count column which is frequency from above and join based on the author id column
df_authorid_authorname_unlisted$pub_count <- pub_count$Freq[match(df_authorid_authorname_unlisted$id, pub_count$Var1)] 

head(df_authorid_authorname_unlisted[order(df_authorid_authorname_unlisted$pub_count, decreasing=T), ],12)
##                   id              names pub_count
## AU_01174 55948479300        tazzioli m.        11
## AU_01166 55012664100           tapia m.         8
## AU_017   56042603500          lamour c.         7
## AU_0115  16230635700           jones r.         7
## AU_0141  35097193300    casas-cortes m.         7
## AU_01229 35097279200     cobarrubias s.         7
## AU_01443  6506435455       de genova n.         7
## AU_01704  6507849304 queirolo palmas l.         7
## AU_01990 55711214500        guizardi m.         7
## AU_0129  16554034600          aradau c.         6
## AU_0133  57197773539      glouftsios g.         6
## AU_01158 35387150500           vives l.         6
#a <- df_authorid_authorname_unlisted
#a <- a[order(a$pub_count, decreasing=T), ]
#head(a)

###head(as.data.frame(table(unlist(author_id_split)))[order(as.data.frame(table(unlist(author_id_split)))[,2], decreasing=T),])

#In case you need to add names to your graphs
#V(g2)$label <- df_authorid_authorname_unlisted$name[match(V(g2)$name, df_authorid_authorname_unlisted$id)]

#In case you need to add names to your graphs
#V(g2)$label <- a$name[match(V(g2)$name, a$id)]

We see that the top 5 most prolific authors are Tazzioli M. with 11 total publications, Tapia M. with 8 total publications, and then seven authors equally prolific with 7 total publications.

### I used ChatGPT to help with this code block
selected_authors <- c("tazzioli m.") 
#put source to lowercase
source$Authors <- tolower(source$Authors)
#finds rows (articles) where both of the authors of interest are listed in the Authors column
matches <- sapply(source$Authors, function(x) all(sapply(selected_authors, function(Authors) grepl(Authors, x))))
# filter out the rows where there is a match
filtered_abstracts <- source$Abstract[matches]
# Print the filtered abstracts
print(filtered_abstracts)
##  [1] "This article interrogates the reservations in the Left in Europe towards claims for freedom of movement and stay. The piece argues that an unequal right to desire – conceived as an aspiration move, to stay and to seek for a better life – underpins those criticisms and suggests that for developing counter-politics of migration, it is key to challenge such racialised predicament. The first section shows how expansive claims for equal access to mobility and the right to stay are discredited as utopian and non-realistic. The second section unsettles the politics of number that sustains public discourses on migration showing that this can be turned to the advantage of arguments in support of border controls. It moves on contending that a critique of racialising borders needs to unpack the unequal right to desire. The fourth section draws attention to the nexus between the disruption of futurity and the unequal right to desire and argues that this enables tracing connections between migrants and (some) citizens through the lens of dispossessed future. It suggests that the allegedly utopian character of claims for freedom of movement does not the depend on the failure of past struggles but on the unquestioned racialised right to desire © The Author(s) 2024."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
##  [2] "This paper argues that the border regime works through entanglements of digital and nondigital data and of \"low-tech\"and \"high-tech\"technologies. It suggests that a critical analysis of the assemblages between digital and nondigital requires exploring their effects of subjectivation on those who are labeled as \"migrants.\"The paper starts with a critique of the presentism and techno-hype that pervade research on borders and technology, and points to the importance of analyzing historical continuities and ruptures in the technologization of the border regime. It then explores the assemblages of high-tech and low-tech technologies used for controlling mobility and investigates the imbrication of digital and nondigital records that migrants need to deal with and show not only at the border but throughout their journeys and, eventually, to obtain refugee status. The third section discusses migrants' tactical uses of digital and nondigital records, their attempts to erase or reconstruct traces of their passages, and states' oscillation between politics of identification and nonidentification. Finally, the fourth section questions the image of the \"data double\"and contends that, rather than a discrete digital subject, migrants' digital traces generate scattered digital subjectivities that migrants themselves cannot fully access.  © 2023 The Author(s)."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
##  [3] "This Symposium reflects on the growing relevance of biopolitical perspectives in camps studies, border studies, refugee studies, and in particular in research at the intersection between mobility studies and political geography. The five interventions accordingly engage with questions regarding the use of biopolitics as an analytical framework, but also as a pervasive strategy and governmental tool in Western societies. Through an analysis of several empirical cases – most notably hotspots on the Greek Aegean Island, refugee’s forced hyper mobility in Europe, speech acts connected to the ethnic cleansing of the Rohingya people in Myanmar and the ‘voluntary return’ policies in Europe, and the paper borders created by visa systems – the authors indicate new possible fields of enquiry related to the biopolitical critically inspired by the work of authors such as Giorgio Agamben and Jasbir Puar, while also clearly restating the fundamental importance of Foucault’s original contribution to any biopolitical analytical framework today. © The Author(s) 2021."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
##  [4] "This article focuses on the politics of migrant dispersal that has been enforced in Europe for regaining control over 'unruly' migrants' presence and movements, with a specific focus on the French and on the Italian contexts. The article shows that dispersal can be considered as a spatial strategy of governmentality and that far from being a new policy, it was already adopted to manage former colonised populations. The article argues that strategies of migrant dispersal are today enacted by state authorities, in collaboration with humanitarian actors, for troubling migrants' presence and autonomous movements, as well as for disrupting and dividing temporary migrant collective formations. First, it retraces a colonial genealogy of dispersal, as a political technology used for disciplining unruly populations. Then, it analyses how dispersal strategies have been put into place in France (Calais and Paris) and in Italy (Ventimiglia) not only by scattering migrants across space but also by dismantling migrant spaces of life ('lieux de vie'). The article moves on demonstrating that the politics of dispersal is mainly enforced for preventing the consolidation of migrant multiplicities, criminalising them as 'migrant mobs' and spatially dividing them. The third section of the article brings attention to the effects of migrants' forced hypermobility and to the convoluted geographies that dispersal triggers. It concludes by bringing attention to the increasing criminalisation of migrant support networks that try to prevent the dismantling of migrant autonomous spaces.  © 2019 The Author(s)."                                                                                                                                                                                                                                                                                                                    
##  [5] "This article focuses on the twofold relationship between migrants’ mobility and modes of government, suggesting that mobility is an object of government and, at once, a technique for governing migrants. It focuses on mobility as a technology of government, investigating how intra-European migration movements are managed by national authorities, with particular attention to illegalized migrants who fall under the Dublin Regulation. Building on ethnographic research conducted between 2015 and 2017, the article centres first on the Italian–French border (Ventimiglia) and on the Swiss–Italian border (Como). Then, it moves on exploring how migrants are currently managed in France, being transferred from Calais to hosting centres across the country. It highlights how migrants’ movements are controlled, disrupted and diverted not (only) through detention and immobility but by generating effects of containment keeping migrants on the move and forcing them to engage in convoluted geography. It shows that one of the main strategies for governing migration through mobility consists in the politics of migrant dispersal, that is by scattering migrants across spaces and dividing emergent migrant groups. © The Author(s) 2019."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
##  [6] "This article deals with border controls at the French-Italian Alpine frontier which have been implemented to govern and contain the migrants in transit. It analyses border controls by focusing on the circulation of knowledge and the economy of visibility which are enacted at that frontier. The article illustrates how the French-Italian Alpine area has become a border-zone for migrants, showing that modes of knowledge and forms of visibility are constitutive of bordering processes. It moves on with a section on the production and circulation of knowledge at the border, introducing the notion of “disjointed knowledges” to account for the asymmetries and fragmentariness at play in border control activities. It argues that we need to start from the partial non-circulation of data and local frictions in order to understand bordering practices. Then, it engages with the obfuscated visibility produced on migrant crossing, drawing attention to how migrants’ presence at the border is alternatively visible and concealed by the authorities. © 2020 Elsevier Ltd"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
##  [7] "In this paper we examine the increasing criminalisation by states and the EU of citizen networks that have mobilised across Europe for supporting migrants in transit. Through these transnational solidarity practices a sort of infrastructure of migrant support has been built. The paper focuses on ‘crimes of solidarity’ that have taken place in France and in Italy and argues that the criminalisation of individuals which build solidarity connections across borders paradoxically constitutes a radical challenge to Europe’s principles of citizens’ solidarity across borders. The infrastructure of migrant support enacts a form of Europeanisation of citizens’ practices that states and local authorities try instead to undermine. The paper moves on by focusing on the ambivalences of the expression ‘smuggling activities’, which is increasingly being used to name individuals who help migrants to cross or to stay without making any economic profit from that. The essay considers the frictions between local, national and European authorities in tolerating or criminalising citizens that act in solidarity with the migrants, bringing humanitarian help and building material channels for safe passages. The final part of the paper reads the moment of crimes of solidarity in terms of a genealogy of European borders. It argues that one consequence of the criminalisation of solidarity is that new hybrid forums concerning migration, citizenship and borders questions are emerging. These arise, for example, when citizens are prosecuted for acts of assistance. Their trials have potential to become public scenes and spaces of counter-politics where it is not only the citizen but Europe that is in the dock. While some have argued that criminalisation and humanitarianism closes down the politics of European borders, we argue that it may allow for unexpected political opportunities. © Bristol University Press 2019."
##  [8] "[No abstract available]"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
##  [9] "The conversation between Étienne Balibar and Nicholas De Genova engages with the Mediterranean of migration as a multifaceted, productive, and contested space, which can represent a counterpoint to a deep-rooted Eurocentric imaginary. Looking at the Mediterranean as a space produced by the mobility of the bodies crossing it and by the combination of different struggles, Balibar and De Genova comment on some of the political movements that have taken center stage in the Mediterranean region in the past few years and suggest that the most important challenge today is to mobilize a “Mediterranean point of view” whereby the political borders of Europe and its self-centered referentiality can be challenged. © 2017 The Author. Antipode © 2017 Antipode Foundation Ltd."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
## [10] "This article engages with the production and government of migrant multiplicities in border zones of Europe, arguing that the specificity of migrant multiplicities consists in their temporary and divisible character. It is argued that there are three different forms of migrant multiplicities: (1) the multiplicity produced due to migrants’ spatial proximity; (2) the virtual multiplicity generated through data; and (3) the visualized and narrated multiplicity that emerges from media portraits of the ‘spectacle’ of the arrivals of migrants. It is claimed that multiplicities are made to divide and partition the migrants and thus prevent the formation of a collective political subject. In the concluding section, the article deals with the ambivalent character of the term ‘the mob’, addressing the twofold dimension of migrant multiplicities: these are in fact generated by techniques of power, at the same time exceeding them and representing potential emerging political subjects. © 2016, © The Author(s) 2016."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
## [11] "Foucault’s shift from an analytical focus on discipline to governmentality saw the theme of visibility move into the background of his attention. In this article we ask how the debates about governmentality and visibility can be brought into a mutually productive relationship. Building on recent arguments for greater rigour in conceptualising visibility, we proceed to examine what visibility means and does in the context of migration control in Europe. Focusing on the EU’s recently deployed programme of border surveillance, EUROSUR, we elaborate how multiple forms of visibility are at play. We conclude that the politics of visibility is an important theme for future studies in the governance of migration. © 2016 University of Kent."

Tazzioli M. tends to write about migration to and through Europe, and how technology and ruling bodies effect migrant experiences. They seem to write often about theories of border control and governance.

### I used ChatGPT to help with this code block
selected_authors <- c("tapia m.") 
#put source to lowercase
source$Authors <- tolower(source$Authors)
#finds rows (articles) where both of the authors of interest are listed in the Authors column
matches <- sapply(source$Authors, function(x) all(sapply(selected_authors, function(Authors) grepl(Authors, x))))
# filter out the rows where there is a match
filtered_abstracts <- source$Abstract[matches]
# Print the filtered abstracts
print(filtered_abstracts)
## [1] "The COVID-19 pandemic caused the stoppage of the movement of people globally, a situation that especially affected tourism as an economic activity. This article addresses the impact of the closure of the Peruvian-Chilean border during the COVID-19 pandemic on the hotel and gastronomic sector of Tacna. Through a qualitative methodology that included a bibliographic review, economic data analysis, and semi-structured interviews with hotel and restaurant owners and managers, we investigated the problems they had to face during the pandemic and the strategies to overcome them. The findings indicate that until March 2020 both items experienced strong growth within the framework of cross-border practices from Chileans to Tacna, within which enjoying Peruvian food was one of the main attractions. The pandemic forced small hotels and restaurants to deploy strategies such as layoffs and the provision of family labor to overcome the crisis and convert to delivery food. The largest and most formalized companies accessed subsidies and support from the state and in other cases, the reconversion was hand in hand with agreements with mining companies to house workers while the health emergency lasted. © (2024), (Universidad de Tarapaca). All rights reserved."
## [2] "The study of human mobility between border cities strains notions of border and calls into question ideas that have long been used in migration studies. Border social practices show that the transborder nature of two cities (Arica and Tacna) are mainly the result of their inhabitants' desire to take advantage of the act of crossing, which leads to various types of mobilities. The disparities and asymmetries of the cities and strong sense of border that exists there do not prevent people from crossing daily, weekly or monthly to work or sell goods in Arica or decrease the cost of living, seek medical care or enjoy cuisine and recreational activities in Tacna. As such, mobility at the border and socio-spatial practices as well as space-time continuity form the basis of the constitution of Arica and Tacna as Transborder Urban Complexes."

Tapia M.’s work focuses on the Peru-Chile border, with special focus on the city of Tacna.

Module 3 purpose & interpretation:

In the first two modules have focused on one mode data, meaning that all the subjects of interest in the dataset and in the data cleaning are of the same type, of authors. Now in module 3 we are going to be considering a two mode network, meaning we are considering two types of data, both authors and publications. This is done by processing the author ID column list of names as we’ve done recently, but then attaching a new column of the publication’s IDs to each co-authorship pairing in the adjacency list. We make a graph visual of this network again.

The interpretation of the graph is limited again because of the quality of the visual, this will be improved in the next module. The interpretation here is mostly in the analysis of the dimensions of the author ID - paper ID adjacency list, which reveals the number of unique articles and lets us see which articles have the most number of authors. We again consider which pairings have the most publications, which is the same as considered before, but it is interesting to look at the paper with the most authors attached to it. This gives us a better idea of the extent to which authors collaborate in the border studies field.

3 Module: Data Formats and Transformations I (two-mode)

Create a publication network wherein all relationships link (co-)authors with their respective publication.

# clean the data, keep only authors and articles
source <- source[source$Author.s..ID!="[No author id available]",]
### create a author-author matrix through transformation of a two-mode edgelist#
authors <- as.data.frame(source[,3])
colnames(authors) <- "AU"
source_split <- cSplit(authors, splitCols = "AU", sep = ";", direction = "wide", drop = TRUE)
#dim(source_split) 
mat_source_split <- as.matrix(source_split)
combined <- cbind(source$EID, mat_source_split)
mat_combined_eid_source_split <- as.matrix(combined)
edgelist_two_mode <- cbind(mat_combined_eid_source_split[, 1], c(mat_combined_eid_source_split[, -1]))
edgelist_two_mode <- edgelist_two_mode[!is.na(edgelist_two_mode[,2]), ]
head(edgelist_two_mode)
##      [,1]                 [,2]         
## [1,] "2-s2.0-85205144697" "57196458199"
## [2,] "2-s2.0-85158062010" "56684310700"
## [3,] "2-s2.0-85153379892" "56135176100"
## [4,] "2-s2.0-85188279386" "55086379400"
## [5,] "2-s2.0-85152933522" "57188966884"
## [6,] "2-s2.0-85203064030" "59312942500"
#2:1 makes it so article linked to author
g2 <- graph.edgelist(edgelist_two_mode[, 2:1], directed = TRUE)
#g2
#5624 is total number of everything
#4000 is number of connections

#articles, authors
#igraph will assume its a one mode network unless there is a type attribute
#true if name does exist at vertex level in the human column of edge list
V(g2)$type <- V(g2)$name %in% edgelist_two_mode[ , 2] 
#V(g2)$name is the column called name at the vertex level
#true means human, false means article
table(V(g2)$type)
## 
## FALSE  TRUE 
##  2350  3274
#we have 3,274 authors and 2,350 articles
#i<-table(V(g2)$type)[2]

#Transformations to retain actors, move from graph to matrix
mat_g2_incidence <- t(get.incidence(g2))
mat_g2_incidence_to_1 <- mat_g2_incidence%*%t(mat_g2_incidence)

summary(diag(mat_g2_incidence_to_1))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.000   1.000   1.000   1.222   1.000  11.000
diag(mat_g2_incidence_to_1)<-0 #set like this if looking at peer effects or spill overs, like no one is influence by theirselves
#also need to do it for visualization purposes
g <- graph.adjacency(mat_g2_incidence_to_1, mode = "undirected")
plot(g)

After this, describe the network by answering: ## How many authors are represented? 3,274 authors ## How many publications are represented in this network? 2,350 articles

table(V(g2)$type)
## 
## FALSE  TRUE 
##  2350  3274

3.1 And how many connections were established?

dim(edgelist_two_mode)
## [1] 4000    2

There are 4000 connections established.

3.2 Who are the top five most prolific authors? What are they publishing about?

#most Prolific authors by ID
pub_count <- as.data.frame(table(unlist(author_id_split))) #table command will list # of times in the matrix certain IDs appear

#adding pub_count column which is frequency from above and join based on the author id column
df_authorid_authorname_unlisted$pub_count <- pub_count$Freq[match(df_authorid_authorname_unlisted$id, pub_count$Var1)] 

head(df_authorid_authorname_unlisted[order(df_authorid_authorname_unlisted$pub_count, decreasing=T), ],12)
##                   id              names pub_count
## AU_01174 55948479300        tazzioli m.        11
## AU_01166 55012664100           tapia m.         8
## AU_017   56042603500          lamour c.         7
## AU_0115  16230635700           jones r.         7
## AU_0141  35097193300    casas-cortes m.         7
## AU_01229 35097279200     cobarrubias s.         7
## AU_01443  6506435455       de genova n.         7
## AU_01704  6507849304 queirolo palmas l.         7
## AU_01990 55711214500        guizardi m.         7
## AU_0129  16554034600          aradau c.         6
## AU_0133  57197773539      glouftsios g.         6
## AU_01158 35387150500           vives l.         6

We see that the top 5 most prolific authors are Tazzioli M. with 11 total publications, Tapia M. with 8 total publications, and then seven authors equally prolific with 7 total publications. Tazzioli M. tends to write about migration to and through Europe, and how technology and ruling bodies effect migrant experiences. They seem to write often about theories of border control and governance. Tapia M.’s work focuses on the Peru-Chile border, with special focus on the city of Tacna.

3.3 What is the publication with the highest number of co-authors? What is this publication about?

We know from our adjacency matrices’ dimensions that there is at least one paper with 93 co-authors.

dim(a1)
## [1] 2354   93
#find row where AU93 not NA
rows_with_non_na <- which(!is.na(a1$Authors_93))
print(rows_with_non_na)
## [1] 1596
#the row (article) of interest is in spot 1596, let's pull that title &abstract
source[1596,4]
## [1] "Harnessing cross-border resources to confront climate change"
source[1596,"Abstract"]
## [1] "The US and Mexico share a common history in many areas, including language and culture. They face ecological changes due to the increased frequency and severity of droughts and rising energy demands; trends that entail economic costs for both nations and major implications for human wellbeing. We describe an ongoing effort by the Environment Working Group (EWG), created by The University of California's UC-Mexico initiative in 2015, to promote binational research, teaching, and outreach collaborations on the implications of climate change for Mexico and California. We synthesize current knowledge about the most pressing issues related to climate change in the US-Mexico border region and provide examples of cross-border discoveries and research initiatives, highlighting the need to move forward in six broad rubrics. This and similar binational cooperation efforts can lead to improved living standards, generate a collaborative mindset among participating universities, and create an international network to address urgent sustainability challenges affecting both countries. © 2018"

The publication with the highest number of co-authors is the journal article entitled “Harnessing cross-border resources to confront climate change” and has 93 co-authors. It is about how climate change is effecting the US - Mexico border region.

3.4 How are points 4 and 5 similar or different? In what ways?

These are different questions because of the object of interest, in question 4 we want to know the individual authors that have the most connections with the papers, while in question 5 we want to know the individual paper that has the most connections to authors (ie was written by the most people). The directionality of the question is important.

3.5 If the number of human actors is different in this deliverable and deliverable 1, what is the cause?

It is the same.

Module 4 purpose & interpretation:

Now with a clear understanding of the dimensions of our dataset, number of unique authors and publications, most proliferate authors and publications with the highest number of authors, we move to improving on the visual representation of these networks. The purpose here is to allow ourselves and our audience to detect outliers and patterns in the publishing dynamics of the border studies field. To make the graph visually appealing and interpretable we need to use HTML code to format the colors and spacing of the nodes and connections in the network. We also add labels to the nodes. One important consideration in this module is to decide if we want to account for solo authors or not. This changes how we process the data to make the adjacency list. We make the choice to include solo authors here by determining if the number of solo authors we’d lose by not including them is significant enough to warrant inclusion, which in our case it is.

The interpretation here is in the visual understanding of the network, which gives us an idea of how much authors in this field tend to work together, and lets us see when there are more connections than you would expect in comparison to others. By the color of the nodes we can see how many publications are connected to each author, or how many authors are connected to each publication (in the two mode visual). By having both one mode and two mode visuals we can compare and see how they differ and the implications that has for understanding the publishing dynamics of the border studies field.

4 Module: Interactive Network Visualizations

Replicate the interactive network visualizations (one mode and two mode) but relying on your publication data. Decide whether you want to plot the co-author relationships starting from a one-mode network or whether you want to link authors to papers and then transform this to a one-mode network. Recall that the latter retains solo authors, in case you have those in your dataset. Whatever you decide, explain why you selected to map the co-authors or start with the two-mode form and the get the co-authors via network transformation.

4.1 One Mode replication

To create the interactive network visualization for one mode I first need to choose what approach to take. I end up choosing to start with the two-mode form and then get co-authors later because I have 1,496 papers written by single authors and I want to include all of this data in the visualization.

#re-load the data set and set to 'a'
a<-read.csv("scopus_final.csv")

#count the number of single authors to see what approach to take
single_author_count <- sum(!grepl(";", a$Authors))
cat("There are", single_author_count, " papers in the dataset that are written by a solo author.")
## There are 1496  papers in the dataset that are written by a solo author.

Now we create the adjacency list and connect it to the papers’ EIDs and then create a weighted graph and the visualization. Note that the solo authors are included and are represented by the nodes completely unconnected. In the visualization you can see each node’s name (Author name), as well as their Publication count, degree measure, and max centrality measure. Note that hovering over the line will tell you the number of co-publications for those co-authors.

#Procedures to decompose an adjacency list into a weighted graph

#Keeping only column with author relationships
authors<-as.data.frame(a[,1])

#rename that column
colnames(authors)<-"AU"

#edit the names to only keep A-Z (getting rid of nonenglish characters)
authors$AU <- str_remove_all(authors$AU, "[^[\\a-zA-Z ]]") #only keeps A-Z, so gets rid of non-English characters

#split the authors column by the ; which is the separator seen in the file
a1<-cSplit(authors, splitCols = "AU", sep = ";", direction = "wide", drop = TRUE) 

#read it as a matrix
mat <- as.matrix(a1)

#getting the EID next to all the authors
mat <- cbind(a$EID, mat)
edgelist1<-matrix(NA, 1, 2)#empty matrix two columns

# for (i in 1:(ncol(mat)-1)) {
#this retains solo authors

#making author to paper network (2 node) (not getting connection between author A and author B)
#for (i in 1:1) {
for (i in 1:(ncol(mat)-1)) {
  edgelist11 <- cbind(mat[, i], c(mat[, -c(1:i)]))
  edgelist1 <- rbind(edgelist1,edgelist11)
  edgelist1<-edgelist1[!is.na(edgelist1[,2]),]
  edgelist1<-edgelist1[edgelist1[,2]!="",]
  }
#dim(edgelist1)

g<- graph_from_data_frame(edgelist1[, 2:1], directed = FALSE)
V(g)$type <- V(g)$name %in% edgelist1[ , 2]
#table(V(g)$type)
i<-table(V(g)$type)[2]


#Transformations to retain actors
mat_g2_incidence <- t(get.incidence(g)) #rectangular matrix
#dim(mat_g2_incidence)
dta <- data.frame(id=rownames(mat_g2_incidence), count=rowSums(mat_g2_incidence))
dta <- dta[order(dta$count, decreasing=T), ] #gives # of publication each person has

mat_g2_incidence_to_1 <- mat_g2_incidence%*%t(mat_g2_incidence)
diag(mat_g2_incidence_to_1)<-0

g<-graph.adjacency(mat_g2_incidence_to_1, mode="undirected")
E(g)$weight <- 1 #must step
g.c <- simplify(g)
# E(g.c)$weight 

#centrality measures
cent<-data.frame(ID=V(g.c)$name, ev=evcent(g.c)$vector, deg=degree(g.c)/max(degree(g.c)), bet=betweenness(g.c, normalized=F)/max(betweenness(g.c, normalized=F)), clo=closeness(g.c)/max(closeness(g.c)[!is.na(closeness(g.c))])) 
#head(cent)
cent$max_cent <- cent$ev + cent$deg + cent$bet + cent$clo

cent<- cent[order(cent$max_cent, decreasing=T),] 
#head(cent)

V(g.c)$label <- V(g.c)$name
V(g.c)$name<-1:length(V(g.c)) #(1:length(V(g)))-1
links<-as.data.frame(cbind(get.edgelist(g.c),as.numeric(E(g.c)$weight)))

links$V1<-as.numeric(as.character(links$V1))
#links

links$V2<-as.numeric(as.character(links$V2))
#str(links)

#links
links<-cbind(links[,1:2]-1, links[,3])
colnames(links)<-c("source","target", "value")

#Get pub count matching names
#most Prolific authors by name
V(g.c)$pub_count <- dta$count[match(V(g.c)$label, dta$id)] 

V(g.c)$label <- paste("Name: ", V(g.c)$label, ", Pub. count = ", V(g.c)$pub_count, ", Degree = ", degree(g.c), ", Max Centrality (max = 4) = ", round(cent$max_cent[match(V(g.c)$label, cent$ID)], 3) , sep="")
#head(V(g.c)$label)


nodes <- data.frame(name=V(g.c)$label, group = V(g.c)$pub_count, size=round(betweenness(g.c,directed=F,normalized=T)/max(betweenness(g.c,directed=F,normalized=T))*115, 3)) #so size isn't tiny

###

netviz <- forceNetwork(Links = links, Nodes = nodes,
                  Source = 'source', Target = 'target',
                  NodeID = 'name',
                  Group = 'group', # color nodes by group calculated earlier
                  charge = -5, # node repulsion
                  linkDistance = 20,
                  opacity = 1,
                  Value = 'value',
                  Nodesize = 'size', # color nodes by group calculated earlier
                  zoom = T, 
                  legend= TRUE,
                  fontSize=24,
                  colourScale = JS("d3.scaleOrdinal(d3.schemeCategory20)"))

HTMLaddons <- 
"function(el, x) { 
d3.select('body').style('background-color', 'white')
d3.selectAll('.legend text').style('fill', 'green') 
 d3.selectAll('.link').append('svg:title')
      .text(function(d) { return 'Intensity: ' + d.value ; })
  var options = x.options;
  var svg = d3.select(el).select('svg')
  var node = svg.selectAll('.node');
  var link = svg.selectAll('link');
  var mouseout = d3.selectAll('.node').on('mouseout');
  function nodeSize(d) {
    if (options.nodesize) {
      return eval(options.radiusCalculation);
    } else {
      return 6;
    }
  }

  
d3.selectAll('.node').on('click', onclick)

  function onclick(d) {
    if (d3.select(this).on('mouseout') == mouseout) {
      d3.select(this).on('mouseout', mouseout_clicked);
    } else {
      d3.select(this).on('mouseout', mouseout);
    }
  }

  function mouseout_clicked(d) {
    node.style('opacity', +options.opacity);
    link.style('opacity', +options.opacity);

    d3.select(this).select('circle').transition()
      .duration(750)
      .attr('r', function(d){return nodeSize(d);});
    d3.select(this).select('text').transition()
    
      .duration(1250)
      .attr('x', 0)
      .style('font', options.fontSize + 'px ');
  }

}
" 
netviz$x$links$linkDistance <- (1/links$value)*125
onRender(netviz, HTMLaddons) 

4.2 Two mode replication

In the two mode visualization that follows you can see each node’s name (Author name or paper ID), as well as their Publication count, degree measure, and max centrality measure. Note that hovering over the connecting lines of the nodes shows the title of the publication and the number of citations it has.

#Procedures to decompose an adjacency list into a weighted graph
a<-read.csv("scopus_final.csv")

#Keeping only column with author relationships
authors<-as.data.frame(a[,1])#"Author.s..ID"])
colnames(authors)<-"AU"

#package for first split
# install.packages("splitstackshape")
 authors$AU <- str_remove_all(authors$AU, "[^[\\a-zA-Z ]]")

#As can be seen in the file the separator of interest is :
a1<-cSplit(authors, splitCols = "AU", sep = ";", direction = "wide", drop = TRUE) #retain the matrix form version of the adjacency list input
#fix(a1)
#class(a1)

#In case package cannot be installed uncomment and keep working using this version, alternatively you can decompose the cells into columns using excel

#read it as a matrix
mat <- as.matrix(a1)
# mat

dim(mat)# the resulting column dimension is the number of times you will have to repeat the following procedure minus 1
## [1] 2354   93
mat <- cbind(a$EID, mat)
edgelist1<-matrix(NA, 1, 2)#empty matrix two columns
# for (i in 1:(ncol(mat)-1)) {
for (i in 1:1) {
  edgelist11 <- cbind(mat[, i], c(mat[, -c(1:i)]))
  edgelist1 <- rbind(edgelist1,edgelist11)
  edgelist1<-edgelist1[!is.na(edgelist1[,2]),]
  edgelist1<-edgelist1[edgelist1[,2]!="",]
  }
#dim(edgelist1)

# install.packages("igraph")

g<- graph.data.frame(edgelist1[, 2:1], directed = FALSE)
V(g)$type <- V(g)$name %in% edgelist1[ , 2]
#table(V(g)$type)
i<-table(V(g)$type)[2]
V(g)$label<-V(g)$name

#Transformations to count number of publications
mat_g2_incidence <- t(get.incidence(g))
dta <- data.frame(id=rownames(mat_g2_incidence), count=rowSums(mat_g2_incidence))
dta <- dta[order(dta$count, decreasing=T), ]

# Centrality key actors
cent<-data.frame(bet=betweenness(g, normalized=T, directed = FALSE)/max(betweenness(g, normalized=T, directed = FALSE)),eig=evcent(g)$vector, degree=degree(g, mode="total")/max(degree(g, mode="total"))) 
cent$index <- rowSums(cent)
cent$name<-rownames(cent) #Ids in this case
#head(cent);tail(cent)

###
cent$bet[1:i]<-(cent$bet[1:i]/max(cent$bet[1:i]))#*10
cent$eig[1:i]<-cent$eig[1:i]/max(cent$eig[1:i])
cent$index[1:i]<-cent$index[1:i]/max(cent$index[1:i])*5
#summary(cent[1:i,])
cent$bet[(i+1):nrow(cent)]<-cent$bet[(i+1):nrow(cent)]/max(cent$bet[(i+1):nrow(cent)])#*20
cent$eig[(i+1):nrow(cent)]<-cent$eig[(i+1):nrow(cent)]/max(cent$eig[(i+1):nrow(cent)])
cent$index[(i+1):nrow(cent)]<-cent$index[(i+1):nrow(cent)]/max(cent$index[(i+1):nrow(cent)])*10
#summary(cent[(i+1):nrow(cent),])

#head(cent)
cent$max_cent <- NA
cent$max_cent[1:i] <- cent$eig[1:i] + cent$degree[1:i] + cent$bet[1:i] 
cent$max_cent[(i+1):nrow(cent)] <- cent$eig[(i+1):nrow(cent)] + cent$degree[(i+1):nrow(cent)] + cent$bet[(i+1):nrow(cent)]
cent<- cent[order(cent$max_cent, decreasing=T),] 
#head(cent)

# Units or elements
V(g)$pub_citat_count <- c(dta$count[match(V(g)$label[1:i], dta$id)], a$Cited.by[match(V(g)$label[(i+1):length(V(g)$name)], a$EID)]) 

V(g)$label <- c(paste("Name: ", V(g)$label[1:i], ", Pub. count = ", V(g)$pub_citat_count[1:i], ", Degree = ", degree(g)[1:i], ", Max Centrality (max = 3) = ", round(cent$max_cent[match(V(g)$label[1:i], cent$name)], 3) , sep=""), 
                paste("EID: ", V(g)$label[(i+1):length(V(g)$name)], ", Citation count = ", V(g)$pub_citat_count[(i+1):length(V(g)$name)], ", Degree = ", degree(g)[(i+1):length(V(g)$name)], ", Max Centrality (max = 3) = ", round(cent$max_cent[match(V(g)$label[(i+1):length(V(g)$name)], cent$name)], 3) , sep="")) 
#head(V(g)$label)
#tail(V(g)$label)

#Gets edgelist from graph, also any other attribute at the edge level to be included in the mapping
links_p<-as.data.frame(cbind(get.edgelist(g))) #To get a place_holder transformation

#Adding other attributes
links_p$V3<-as.numeric(a$Cited.by)[match(links_p$V2, a$EID)]
links_p$V4<-a$Title[match(links_p$V2, a$EID)]

# Making edgelist for interactive visualization
V(g)$name<-1:length(V(g))-1
links<-as.data.frame(cbind(get.edgelist(g))) 
links$V1<-as.numeric(as.character(links$V1))
links$V2<-as.numeric(as.character(links$V2))
links$V3 <- links_p$V3
links$V4 <- links_p$V4
#str(links)
#head(links)

colnames(links)<-c("source","target", "citation", "title") 

nodes <- data.frame(name= V(g)$label, pubs_citation = V(g)$pub_citat_count, groups = ifelse(V(g)$type==1, "Author", "Article"))
#head(nodes)

{
nodes$group<-NA
nodes$group <-cut(nodes$pubs_citation, c(0,1,3,10,20,max(nodes$pubs_citation)), right=TRUE, include.lowest = FALSE)
table(is.na(nodes$group))
table(nodes$group)
head(nodes[is.na(nodes$group),],20)
nodes$group<-ifelse(is.na(nodes$group), "No Citation", ifelse(nodes$group=="(0,1]", "1 cit/pub", ifelse(nodes$group=="(1,3]", "2 or 3 cit/pub", ifelse(nodes$group=="(3,10]", "4 to 10 cit/pub", ifelse(nodes$group=="(10,20]", "11 to 20 cit/pub", "Over 20 cit/pub")))))
counts<-data.frame(table(nodes$group))

counts$labels <- paste(counts$Var1, ", N= ", counts$Freq, sep="")
nodes$groups <- counts$labels[match(nodes$group, counts$Var1)]
#head(nodes)
}


ColourScale <- 'd3.scaleOrdinal()
            .domain(["1 cit/pub, N= 3174", "11 to 20 cit/pub, N= 42", "2 or 3 cit/pub, N= 464", "4 to 10 cit/pub, N= 155", "No Citation, N= 721", "Over 20 cit/pub, N= 38"])
           .range(["#ff3397", "#e5ff33", "#F4BB44", "#B2BEB5", "#EE4B2B", "#FF3131"]);'


netviz<-forceNetwork(Links = links, Nodes = nodes,
                  Source = 'source', Target = 'target',
                  NodeID = 'name',
                  Group = "groups", # color nodes by group calculated earlier
                  charge = -20, # node repulsion
                  linkDistance = JS("function(d) { return d.linkDistance; }"),#JS("function(d){return d.value}"),
                  linkWidth = JS("function(d) { return Math.sqrt(d.citation)*4; }"),
                  opacity = 0.8,
                  Value = "citation",
                  Nodesize = 'pubs_citation', 
                  radiusCalculation = JS("Math.sqrt(d.nodesize*30)+10"),
                  zoom = T, 
                  fontSize=14,
                  bounded= F,
                  legend= TRUE,
                  # linkColour = ifelse(links$campus == "NEUNK", "#CCFFFF", ifelse(links$campus == "NEUNL", "#e3eaa7", "#abb2b9")),
                  colourScale = JS(ColourScale))

HTMLaddons <- 
"function(el, x) { 
d3.select('body').style('background-color', 'white')
d3.selectAll('.legend text').style('fill', 'green') 
 d3.selectAll('.link').append('svg:title')
      .text(function(d) { return 'Number of citations : ' + d.value + ', Title: ' + d.title ; })
  var options = x.options;
  var svg = d3.select(el).select('svg')
  var node = svg.selectAll('.node');
  var link = svg.selectAll('link');
  var mouseout = d3.selectAll('.node').on('mouseout');
  function nodeSize(d) {
    if (options.nodesize) {
      return eval(options.radiusCalculation);
    } else {
      return 6;
    }
  }

  
d3.selectAll('.node').on('click', onclick)

  function onclick(d) {
    if (d3.select(this).on('mouseout') == mouseout) {
      d3.select(this).on('mouseout', mouseout_clicked);
    } else {
      d3.select(this).on('mouseout', mouseout);
    }
  }

  function mouseout_clicked(d) {
    node.style('opacity', +options.opacity);
    link.style('opacity', +options.opacity);

    d3.select(this).select('circle').transition()
      .duration(750)
      .attr('r', function(d){return nodeSize(d);});
    d3.select(this).select('text').transition()
    
      .duration(1250)
      .attr('x', 0)
      .style('font', options.fontSize + 'px ');
  }

}
"
netviz$x$links$value <- links$citation
netviz$x$links$title <- links$title
netviz$x$links$linkDistance <- (links$citation)*50
onRender(netviz, HTMLaddons)

4.3 Finally, tell us WHY should we even care about doing all of this (or do we)?

Creating these visualizations allows us and our audience to see the network for themselves and makes it easy to spot edge case type situations. For example, in the one mode visualization you can immediately notice the cluster of nodes (I think over 80!) that are all together, which is so different from the majority of the other connections in the visualization. Also, your attention might next be attracted to the nodes with different colors, which shows you how many publications each author has. Our audience as academics and researchers is growing and growing and with that means we have more responsibility to communicate our results well and make things attractive and attention grabbing, which is what these visualizations do.

Module 5 purpose & interpretation:

In this module we use a different dataset which represents the friendships of a group of people. The purpose here is to consider how social connections factor into certain outcomes. In this case we are considering each person’s fees collected and their hourly rate. We use a statistical test called Moran’s I which allows us to determine if the differences in the outcome variables are statistically associated with the relationship of the peoples. The statistical method lets us see to what extent the network is significant as well, i.e. do my direct social connections only matter or does it also matter that my friend A is connected to person B, so by secondary association I am also connected to person B. Moran’s I is normalized to range from −1 to +1, with +1 indicating a perfect spatial autocorrelation, suggesting a 1 to 1 variation in a given outcome and the average outcomes of a units’ neighbors.

The interpretation in this module relies on comparing the Moran’s I values between outcomes, which will tell us if the networked associations among friends make more of a difference (or have a greater connection) on peoples’ hourly rates or their fees collected. By looking at these numbers we can theorize why the network would matter more or less for either outcome. We also can interpret the importance of isolates (people with no friend connections) in this module as well because we consider the Moran’s I statistic both with and without isolates. Ultimately we determine how many higher order neighbors (i.e. neighbors beyond the direct neighbor) are statistically significant to the outcomes of concern.

5 Module: Friendship Data

Please replicate the procedures used in social dependence or peer effects to answer the following questions but using a friendship dataset instead:

5.1 Is there evidence of stronger dependence in the per hour rate compared to the fees brought in 1990 amounts?

Hour rate was 0.520938960 with a significant p value and fees was 0.455321539 with a significant p value as well. Thus, there is evidence that hourly rate has stronger dependence than fees because the Moran I’s statistic is larger. This could be because there are more factors that effect fees than hourly rate. However, this difference seems to be subtle since the difference between the two values is quite small. Also, this difference in Moran’s I is smaller than that of the coworker network, this indicates that the friendship network has less differences in connections between these two characteristics.

#Friendship data loading in
idfriend <- "1dwX4kKlx-ctkU0JyH74p3r1w-jJdTAqi"
friendshiplazega <- read.csv(sprintf("https://docs.google.com/uc?id=%s&export=download", idfriend))
#idadvice <- "1dbZDumTH9dFwNStIKKEO9bhx_ftYtLam" 
#advicelazega <- read.csv(sprintf("https://docs.google.com/uc?id=%s&export=download", idadvice))

# 1 is friendship, 0 is no friendship
advicelazega <- as.matrix(friendshiplazega)
#advicelazegac <- advicelazega
#str(advicelazega)
#dim(advicelazega)

#Reading attributes also provided by Lazega
idattributes <- "1e0GtrRS5PFFNdnd1e4fJcjeuBZ6deF7g"
datattrout <- read.csv(sprintf("https://docs.google.com/uc?id=%s&export=download", idattributes))

#Transforming the matrices to spatial form (row normalized) as shown in equation (21)
advicelazega <-advicelazega /rowSums(advicelazega)
summary(rowSums(advicelazega))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##       1       1       1       1       1       1       6
# Replacing potential NAN to zeros as shown in equation (22)
advicelazega[is.na(advicelazega)]<-0
listwAd<-mat2listw(advicelazega)

#########
#Testing influence
#########
moran.test(datattrout$HrRATE90,listwAd, zero.policy=TRUE)
## 
##  Moran I test under randomisation
## 
## data:  datattrout$HrRATE90  
## weights: listwAd  
## n reduced by no-neighbour observations  
## 
## Moran I statistic standard deviate = 8.6798, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.520938960      -0.015625000       0.003821452
moran.test(datattrout$FeesCollec90,listwAd, zero.policy=TRUE)
## 
##  Moran I test under randomisation
## 
## data:  datattrout$FeesCollec90  
## weights: listwAd  
## n reduced by no-neighbour observations  
## 
## Moran I statistic standard deviate = 7.628, p-value = 1.192e-14
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.455321539      -0.015625000       0.003811733
#########
#Visualizing Local Moran’s I clusters and outliers 
#########
# mt <- moran.test(datattrout$FeesCollec90, listwAd, zero.policy=TRUE)
# label_x = "Individual Fees Collected"
# label_y = "Lagged Individual Fees Collected"
# mp <- moran.plot(datattrout$FeesCollec90, listwAd, zero.policy=T,
# labels=datattrout$id, xlab = label_x, ylab = label_y)
# title(main="Moran’s Plot", cex.main=2, col.main="grey11", 
# font.main=2, sub=paste("Plot includes 71 lawyers (Moran’s I = ", 
# round(mt$ estimate[1], 3), ", p < .0001)", sep=""), cex.sub=1.15, col.sub="grey11", font.sub=2,)

5.2 Do you have isolates in the model? Clue, you can test for the presence of isolates using: table(rowSums(friendshiplazega)==0)

Yes, there are 6 isolates in the model, meaning there are 6 people in this community that do not have any friends.

table(rowSums(advicelazega)==0)
## 
## FALSE  TRUE 
##    65     6

5.3 How many higher order neighbors did you find? Does this change by outcome?

Note that the friendship network we are looking at is sparse enough that by having isolates and keeping them in it is not possible to find the higher order neighbors. To address this issue we consider secondary friends (i.e. friends of a friend) as direct friends (inherently making a new friendship network).

We find only one higher order neighbors because only the first order neighbor is statistically significant with the complete confidence interval of that neighbor falling in the Moran’s I above 0 range.

The number of higher order neighbors does not change by outcome because for either hourly rate or fees in both cases only the first neighbor is significant and considered higher order.

advicelazega1 <- advicelazega%*%t(advicelazega)#increasing relationships by considering friends of friends
diag(advicelazega1)<-0
advicelazega[advicelazega1>1]<-1
 
#Transforming the matrices to spatial form (row normalized) as shown in equation (21)
advicelazega1 <-advicelazega1 /rowSums(advicelazega1)
# Replacing potential NAN to zeros as shown in equation (22)
advicelazega1[is.na(advicelazega1)]<-0
listwAd1<-mat2listw(advicelazega1)
 
#run plots to see number of higher order neighbors
keep_listNAd1 <- subset(listwAd1[[2]], subset=card(listwAd1[[2]])>= 0)
 
plot.spcor(sp.correlogram(keep_listNAd1, datattrout$HrRATE90, order = 3, method = "I", zero.policy=T), xlab = "Social lags", main = "Social correlogram: Autocorrelation with CIs")

plot.spcor(sp.correlogram(keep_listNAd1, datattrout$FeesCollec90, order = 3, method = "I", zero.policy=T), xlab = "Social lags", main = "Social correlogram: Autocorrelation with CIs")

5.4 After removing isolates: How do the Moran’s I estimates change? & Are there any differences in these changes by outcome?

The Moran’s I for Hour rate increased to 0.684439193 with a significant p value (.1635 change) and the Moran’s I for fees increased to 0.528467238 (.0731 change) with a significant p value as well. The Moran’s I for the fees changed less than that of the hour rate, indicating that by removing isolates the remaining network of connections has a greater dependence on hour rate than fees.

##########################################
### REMOVE UNCONNECTED:::::
#########
#How are disconnected unit influencing these results and how to remove them?
#########
sub_listNAd <- subset(listwAd[[2]], subset=card(listwAd[[2]])> 0)
#sub_listNAd
#weights
sub_listWAd <- nb2listw(sub_listNAd, glist=NULL, style="W", zero.policy=NULL)
#making this a spatial points dataframe
sub_datattrout <- subset(datattrout, subset=card(listwAd[[2]]) > 0)

moran.test(sub_datattrout$HrRATE90,sub_listWAd, zero.policy=TRUE)
## 
##  Moran I test under randomisation
## 
## data:  sub_datattrout$HrRATE90  
## weights: sub_listWAd    
## 
## Moran I statistic standard deviate = 10.907, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.684439193      -0.015625000       0.004119984
moran.test(sub_datattrout$FeesCollec90,sub_listWAd, zero.policy=TRUE)
## 
##  Moran I test under randomisation
## 
## data:  sub_datattrout$FeesCollec90  
## weights: sub_listWAd    
## 
## Moran I statistic standard deviate = 8.5307, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.528467238      -0.015625000       0.004067992
#########
#Visualizing Local Moran’s I clusters and outliers 
#########
# mt <- moran.test(sub_datattrout$HrRATE90, sub_listWAd, zero.policy=TRUE)
# label_x = "Hr Rate Collected"
# label_y = "Lagged Hr Rates Collected"
# mp <- moran.plot(sub_datattrout$HrRATE90, sub_listWAd, zero.policy=T,
# labels=sub_datattrout$id, xlab = label_x, ylab = label_y)
# title(main="Moran’s Plot", cex.main=2, col.main="grey11", 
# font.main=2, sub=paste("Plot includes 71 lawyers (Moran’s I = ", 
# round(mt$ estimate[1], 3), ", p < .0001)", sep=""), cex.sub=1.15, col.sub="grey11", font.sub=2,)

5.5 After removing isolates: How many higher order neighbors did you find? and Does this change by outcome?

We find two higher order neighbors because they are statistically significant with the complete confidence interval of that neighbor falling in the Moran’s I above 0 range. The number of higher order neighbors does not change by outcome because for either hourly rate or fees in both cases only the first and second order neighbors are significant and considered higher order.

#########
# Methodological questions with practical implications:
# How do we know that our proposed initial matrix of weights is robust enough to estimate outcome dependence?
# How many neighbors of neighbors (higher order neighboring structures) do we have to account for to establish a data driven selection of neighboring structures?
#########
plot.spcor(sp.correlogram(sub_listNAd, sub_datattrout$HrRATE90, order = 6, method = "I", zero.policy=T), xlab = "Social lags", main = "Social correlogram: Autocorrelation with CIs")

plot.spcor(sp.correlogram(sub_listNAd, sub_datattrout$FeesCollec90, order = 6, method = "I", zero.policy=T), xlab = "Social lags", main = "Social correlogram: Autocorrelation with CIs")

###Test
#moran.plot(sub_datattrout$HrRATE90, nth_order[[2]], zero.policy=T, labels=sub_datattrout$id)
###

Module 6 purpose & interpretation:

In this last module we return to our publications data set. The purpose is to employ the same methods from module 5 to consider if the networked interactions of the co-authors in our data set have any influence on the publication counts of authors. This will help us understand if academics in this field find publishing success by working with multiple people, or, perhaps the connections aren’t as important and being a solo author is the way to go. We again must consider if we want to include solo authors and we also need to consider if we include isolates here, but isolates in this context would be solo authors that for every paper they publish it solo. We also visualize the relationship of publication counts of authors and co-authors.

The interpretation in this module relies on the Moran’s I value and the visualization. The Moran’s I tells us if the networked associations among authors makes a difference in those authors’ publication counts. We also determine the number of higher order neighbors that are statistically significant. The interpretation here is if your co-authors’ co-authors (co-authors’…) matter to your own number of publications.

6 Module: Going back to publication data

##Decide whether you want to focus on co-authors or want to include all authors, including solo authors. I will include solo authors because as mentioned before there are 1,496 papers written by solo authors in my data set.

6.1 What are the implications of this decision? That is, tell me how this decision changes whether you start with one-mode or two-mode data. What about isolates?

If you want to focus on co-authors only, then you can start with the one-mode adjacency list. Also, in this context the isolate means an author that published alone (i.e. doesn’t have any connections with other authors for a paper) so that means by creating the one mode adjacency list you also get rid of the isolates. On the other hand, if you want to account for solo authors, which are the isolates, you need to create the two mode adjacency list between articles and authors in the data structuring process. By way of this process the isolates will automatically be kept in.

6.2 Test for outcome dependence using author’s number of publication as a function of her/his coauthors’ number of publications

The Moran’s I statistic in this case is 0..26 and is statistically significant (low p-value), this indicates that the author’s number of publications is statistically connected to their co-author’s number of publications.

#Procedures to decompose an adjacency list into a weighted graph
a<-read.csv("scopus_final.csv")

#Keeping only column with author relationships
authors<-as.data.frame(a[,3])#"Author.s..ID"])
colnames(authors)<-"AU"
authors$AU <- str_remove_all(authors$AU, "[^[\\a-zA-Z ]]") #only keeps A-Z, so gets rid of non-English characters

#As can be seen in the file the separator of interest is ;
a1<-cSplit(authors, splitCols = "AU", sep = ";", direction = "wide", drop = TRUE) #retain the matrix form version of the adjacency list input

#read it as a matrix
mat <- as.matrix(a1)
#getting the EID next to all the authors
mat <- cbind(a$EID, mat)
edgelist1<-matrix(NA, 1, 2) #empty matrix two columns

# for (i in 1:(ncol(mat)-1)) {
#this retains solo authors
#making author to paper network (2 node) (not getting connection between author A and author B)
for (i in 1:(ncol(mat)-1)) {
  edgelist11 <- cbind(mat[, i], c(mat[, -c(1:i)]))
  edgelist1 <- rbind(edgelist1,edgelist11)
  edgelist1<-edgelist1[!is.na(edgelist1[,2]),]
  edgelist1<-edgelist1[edgelist1[,2]!="",]
}

g<- graph.data.frame(edgelist1[, 2:1], directed = FALSE)
V(g)$type <- V(g)$name %in% edgelist1[ , 2]
#table(V(g)$type)
i<-table(V(g)$type)[2]

#Transformations to retain actors
mat_g2_incidence <- t(get.incidence(g))
# This removes papers with only one author
# dim(mat_g2_incidence[,colSums(mat_g2_incidence)>1])
# mat_g2_incidence <- mat_g2_incidence[,colSums(mat_g2_incidence)>1]
dta <- data.frame(id=rownames(mat_g2_incidence), count=rowSums(mat_g2_incidence))
dta <- dta[order(dta$count, decreasing=T), ]

mat_g2_incidence_to_1 <- mat_g2_incidence%*%t(mat_g2_incidence)
diag(mat_g2_incidence_to_1)<-0

# This removes isolates?
#table(rowSums(mat_g2_incidence_to_1)==0) ##the number of False gives you how many solo authors
# mat_g2_incidence_to_1<-mat_g2_incidence_to_1[ rowSums(mat_g2_incidence_to_1)!=0,]
# mat_g2_incidence_to_1<-mat_g2_incidence_to_1[,colSums(mat_g2_incidence_to_1)!=0]
#dim(mat_g2_incidence_to_1)

mat_g2_incidence_to_1 <- mat_g2_incidence_to_1 /rowSums(mat_g2_incidence_to_1)
#summary(rowSums(mat_g2_incidence_to_1))

mat_g2_incidence_to_1[is.na(mat_g2_incidence_to_1)]<-0
listw<-mat2listw(mat_g2_incidence_to_1)

#Creating a dataset for tests.  #much easier to keep order in matrix and add info based on order, than to modify the matrix
pd <- data.frame(id=colnames(mat_g2_incidence_to_1))
pd$pub<- dta$count[match(pd$id, dta$id)]

pd$lag.pub <- round(lag.listw(listw, pd$pub, zero.policy=T, na.action=na.omit),3)

moran.test(pd$pub, listw, zero.policy=TRUE)
## 
##  Moran I test under randomisation
## 
## data:  pd$pub  
## weights: listw  
## n reduced by no-neighbour observations  
## 
## Moran I statistic standard deviate = 11.892, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2635090061     -0.0004557885      0.0004926836

6.3 Visualize this influence level, what may be the mechanism to explain these clusters and outliers?

We see clusters where an author has published 2 or 3 times themselves, but have had no co-authors. This could be explained by a researcher who has published alone once to publish again in the future, i.e. people who work independently continue to work independently. We also see that there are more authors / coauthors with relatively matching amounts of publications, i.e. the lines at y_i=1, y_i=2, … have more points where the y_j values are the same or very similar. This makes sense because in academia researchers with similar levels of experience tend to work together (at least from my observation), so it’s more likely that the author and co-authors have similar amounts of publications. The far right or high up outliers might be explained by a mismatch of author experiences where an established researcher agrees to work with some early career academics or advise a PhD student on a paper. Overall we see that most authors have published 4 or less articles in the Border studies field.

#Moran's I procedures for social dependence 
mi <- moran.test(pd$pub, listw, zero.policy=TRUE)
mp_math <- moran.plot(pd$pub, listw, labels=as.character(pd$id), zero.policy = TRUE)

#adds a label, br breaks the line
mp_math$new_label <- paste("Author ID: ", mp_math$labels, "<br>own pub record: ", pd$pub[match(mp_math$labels, pd$id)], 
                           "<br>Co-authors' record: ", pd$lag.pub[match(mp_math$labels, pd$id)], sep="") 

mphu <-ggplot(mp_math, aes(x=jitter(x), y=jitter(wx), text=new_label)) + geom_point(shape=1, alpha=0) + 
    geom_hline(yintercept=mean(mp_math$wx), lty=2) + 
    geom_vline(xintercept=mean(mp_math$x), lty=2) + theme_minimal() + 

    geom_point(data=mp_math[(mp_math$wx>=mean(mp_math$wx)&mp_math$x>=mean(mp_math$x))&mp_math$is_inf==FALSE,], aes(x=x, y=wx), shape=1, alpha=.1) +
    geom_point(data=mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx>=mean(mp_math$wx))&mp_math$is_inf==TRUE,], aes(x=x, y=wx), shape=9, alpha=.4) +
    
    geom_point(data=mp_math[(mp_math$x<mean(mp_math$x)&mp_math$wx>=mean(mp_math$wx))&mp_math$is_inf==FALSE,], aes(x=x, y=wx), shape=1, alpha=.1) +
    geom_point(data=mp_math[(mp_math$x<mean(mp_math$x)&mp_math$wx>=mean(mp_math$wx))&mp_math$is_inf==TRUE,], aes(x=x, y=wx), shape=9, alpha=.4) +

    geom_point(data=mp_math[(mp_math$x<mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==FALSE,], aes(x=x, y=wx), shape=1, alpha=.1) +
    geom_point(data=mp_math[(mp_math$x<mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,], aes(x=x, y=wx), shape=9, alpha=.4) +

    geom_point(data=mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==FALSE&(mp_math$x-mp_math$wx<min(mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,]$x-mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,]$wx)),], aes(x=x, y=wx), shape=1, alpha=.3, position=position_jitter(h=0.1,w=0.1)) +
    geom_point(data=mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==FALSE&(mp_math$x-mp_math$wx>=min(mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,]$x-mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,]$wx)),], aes(x=x, y=wx), shape=9, alpha=.8, colour=rgb(223, 255, 0, max=255, 255/1), position=position_jitter(h=0.1,w=0.1)) +
    geom_point(data=mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,], aes(x=x, y=wx), shape=9, alpha=.8, colour=rgb(255, 0, 126, max=255, 255/1), position=position_jitter(h=0.1,w=0.1)) + 
    xlab("Authors' Own Publication count (y_i)") + ylab("Coauthors' Publication count (y_j)") + ggtitle("Peer effects", 
              subtitle = "") + labs(caption = "(PHUDCFILY)") +
        theme(plot.title = element_text(color=rgb(255, 0, 126, max=255, 255/1), size=14, face="bold"),
              plot.subtitle = element_text(color = "blue"))#
ggplotly(mphu, tooltip = c("new_label")) %>%
  layout(title = list(text = paste0('<b>Peer effects on Publication Performance</b>',
                                    '<br>',
                                    '<sup style="color:black; font-weight:bold">',
                                     paste(dim(mat_g2_incidence_to_1)[1],' authors in ', dim(mat_g2_incidence)[2],' Publications. Conservative: ', dim(mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,])[1], ' HL cases (pink), Liberal: ', dim(mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==FALSE&(mp_math$x-mp_math$wx>=round(min(mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,]$x-mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,]$wx),3)),])[1], ' HL cases (green) </sup>', sep=""),
                                     '<span style="font-size:10px; font-weight:bold; color: rgb(255, 0, 126, max=255, 255/1)">',
                                     paste("\nSource: Scopus. Moran's I = ", round(mi$estimate[1], 3)," P. Value ", ifelse(mi$p.value==0, "< 0.001", mi$p.value), ', Liberal threshold = ', round(min(mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,]$x-mp_math[(mp_math$x>=mean(mp_math$x)&mp_math$wx<mean(mp_math$wx))&mp_math$is_inf==TRUE,]$wx),3), '</span>', sep=""))))

6.4 Test how many higher order neighbors should we account for in this framework?

We find that we should account for two higher order neighbors because they are statistically significant with the complete confidence interval of that neighbor falling in the Moran’s I above 0 range.

#higher order
plot.spcor(sp.correlogram(listw[[2]], pd$pub, order = 5, method = "I", zero.policy=TRUE), xlab = "Social lags", main = "Social correlogram: Autocorrelation with CIs")

6.5 If needed create a higher order weight matrix and test for autocorrelation.

Autocorrelation occurs when “the spatial neighbors of unit 𝑖 realize outcomes that are more similar to the outcomes of such a unit 𝑖 than what we could expect to observe under a spatial random process” (González Canché). The Moran’s I allows us to test for autocorrelation, and we see here that after making the higher order weight matrix the Moran’s I statistic is still significant, suggesting that the spatial relationships with (or in this case the networked connections of authors) is related to the author’s publication count.

nth_order <- nblag(listw[[2]], maxlag=2)#this assumes two
nth_order <- nblag_cumul(nth_order)
nth_order <- nb2listw(nth_order, style="W", zero.policy=T)
mt <- moran.test(pd$pub, nth_order, zero.policy=TRUE)
mt
## 
##  Moran I test under randomisation
## 
## data:  pd$pub  
## weights: nth_order  
## n reduced by no-neighbour observations  
## 
## Moran I statistic standard deviate = 8.9353, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.1896925919     -0.0004557885      0.0004528587