3

My problem is the following:

I am using the R SNA package for social network analysis. Lets say, my starting point is an edgelist with the following characteristics. Every row contains a firm name, the ID of a project they are involved and further characteristics, let's say the projects year. Firms can be in several projects, and one project can consist of a cooperation of more than one firm. Example:

Name   Project   Year
AA     1         2003
AB     1         2003
AB     2         2003
AB     3         2004
AC     2         2003
AC     4         2005

For the network analysis I need a adjacency matrix with all firms as row and column header, which I construct as follows:

grants.edgelist <- read.csv("00-composed.csv", header = TRUE, sep = ";", quote="\"", dec=",", fill = TRUE, comment.char="")

grants.2mode <-  table(grants.edgelist)   # cross tabulate -> 2-mode sociomatrix

grants.adj <- grants.2mode%*%t(grants.2mode)     # Adjacency matrix as product of the 2-mode sociomatrix`

Now my problem: I want to run a netlm Regression on the adjacency matrix, where I test how the network in one given year explains the network in the next year. However, therefore I wanted to subset the grants.edgelist in a set for (lets say) 2003 and 2005 only. However, I figured out that not all firms are in projects every year, and therefore the corresponding adjacency matrix has different rows and columns.

Now my question: How could I obtain a adjacency matrix containing all firms in row and column header, but their intersection set on zero expect of the year I want to observe. I hope it is clear what I mean.

Thank you very much in advance. This problem is driving me crazy today!

Best wishes

Daniel

Jarrod Urban
  • 134
  • 7
  • Most of the question makes it sound like you want, for example, the 2003 and 2004 adjacency matrices, but only the Names and Projects that are found in both years. But the question at the end makes me question my interpretation. – ndoogan Mar 09 '13 at 04:33

1 Answers1

1

Assuming that there the possibility of the same firm working a the same project in multiple years (if not, there are definitly simpler solutions). One way to do this is to construct a networkDynamic object, and then extract the years you want and feed them into netlm.

library(networkDynamic)

# construct example dataset
firmProj <- matrix(
                    c('AA', 1,  2003,
                      'AB', 1, 2003,
                      'AB', 2, 2003,
                      'AB', 3, 2004,
                      'AC', 2, 2003,
                      'AC', 4, 2005),
                       ncol=3,byrow=TRUE)
colnames(firmProj)<-c('Name',   'Project',   'Year')

# make network encompassing all edges
baseNet<-network(firmProj[,1:2])

# get the ids/names of the vertices
ids<-network.vertex.names(baseNet)

# convert original data to a timed edgelist
tel<-cbind(as.numeric(firmProj[,3]),   # convert years to numeric start time
           as.numeric(firmProj[,3])+1, # convert years to numeric end  time
           match(firmProj[,1],ids),    # match label to network id
           match(firmProj[,2],ids))    # match label to network id

# convert to a networkDynamic object
dynFirmProj<-networkDynamic(baseNet, edge.spells = tel)

# bin static networks from the dynamic one, and convert them into list of adjacency matrices
lapply(
       get.networks(dynFirmProj,start=2003, end = 2006, time.increment = 1),
       as.matrix)

[[1]]
   1 2 3 4 AA AB AC
1  0 0 0 0  0  0  0
2  0 0 0 0  0  0  0
3  0 0 0 0  0  0  0
4  0 0 0 0  0  0  0
AA 1 0 0 0  0  0  0
AB 1 1 0 0  0  0  0
AC 0 1 0 0  0  0  0

[[2]]
   1 2 3 4 AA AB AC
1  0 0 0 0  0  0  0
2  0 0 0 0  0  0  0
3  0 0 0 0  0  0  0
4  0 0 0 0  0  0  0
AA 0 0 0 0  0  0  0
AB 0 0 1 0  0  0  0
AC 0 0 0 0  0  0  0

[[3]]
   1 2 3 4 AA AB AC
1  0 0 0 0  0  0  0
2  0 0 0 0  0  0  0
3  0 0 0 0  0  0  0
4  0 0 0 0  0  0  0
AA 0 0 0 0  0  0  0
AB 0 0 0 0  0  0  0
AC 0 0 0 1  0  0  0

However, I'm not sure netlm will be the best way to look at this, as dichotomous data for the dependent variable "..is strongly discouraged due to the assumptions of the analysis." But maybe I'm not quite understanding your question.

skyebend
  • 1,079
  • 6
  • 19