1

I'm trying to create a list of bipartite networks that I'll eventually use to fit a TERGM. Each network represents a single year. However, I'm having trouble creating the individual networks using the as.network() function from statnet.

For a single year's network, I have a dataframe of nodes with a variable that equals TRUE if a node is mode-1, and false if it's mode-2. I also have a data frame containing edges for that year.

When I pass these to as.network(), I get a

To make things more concrete, here's an example:

        # Set up nodes and edges
        my_nodes <- data.frame(
          name = c("Federal Govt.", "State 1", "State 2", "State 3", "State 4", "State 5", "State 6",
                   "Group 1", "Group 2", "Group 3", "Group 4", "Group 5", "Group 6", "Group 7", "Group 8", "Group 9"),
          is_actor = c( rep(TRUE, 7), rep(FALSE, 9) ),
          religious = c( rep(0, 7), 1, rep(0, 6), 1, 1 )
        )
        
        my_edges <- data.frame(
          actor1 = c("Federal Govt."),
          actor2 = c("Group 7")
        )

        my_edges <- data.frame(
          actor1 = c("Federal Govt."),
          actor2 = c("Group 7")
        )
        
        # Create network object
        my_net <- as.network( x = my_edges, vertices = my_nodes, bipartite = TRUE, bipartite_col = "is_actor" )

When I call this network in the console, I get:

 Network attributes:
  vertices = 16 
  directed = FALSE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = 1 
  total edges= 1 
    missing edges= 0 
    non-missing edges= 1 

 Vertex attribute names: 
    is_actor religious vertex.names 

No edge attributes

Here's the first issue: Why is bipartite = 1, when is_actor == TRUE for 7 of the nodes?

When I convert this network to a sociomatrix, I get a numeric vector...

        # The sociomatrix I get from as.sociomatrix()
        as.sociomatrix(my_net)


State 1 State 2 State 3 State 4 State 5 State 6 Group 1 Group 2 Group 3 Group 4 Group 5 Group 6 Group 7 Group 8 Group 9 
      0       0       0       0       0       0       0       0       0       0       0       0       1       0       0 

...when I expected to get a matrix where each row is a state, and each column is a group:


              Group 1 Group 2 Group 3 Group 4 Group 5 Group 6 Group 7 Group 8 Group 9
Federal Govt.       0       0       0       0       0       0       1       0       0
State 1             0       0       0       0       0       0       0       0       0
State 2             0       0       0       0       0       0       0       0       0
State 3             0       0       0       0       0       0       0       0       0
State 4             0       0       0       0       0       0       0       0       0
State 5             0       0       0       0       0       0       0       0       0
State 6             0       0       0       0       0       0       0       0       0

Here's the second issue: Why is as.sociomatrix() producing a numeric vector instead of a matrix where the rows represent one kind of actor, and columns represent the other?

This doesn't happen with all the bipartite networks I try to create. Sometimes as.network() will create a bipartite network where only some of the nodes/vertices are properly designated as the right mode.

How can I get as.network() to produce the bipartite networks I'm trying to create?

Thank you!

greg-f
  • 11
  • 1

0 Answers0