Adding values to the edges of a network in R

48 views Asked by At

I have a data set (csv file) of arms exports that consists of the following variables called arms1993:

countryA, countryB, year of arms trade, and the value of the arms export from country A to B in each year.

Here's some actual data from my data set:

countryA countryB year value
Portugal Angola 1993 1
Spain Angola 1993 17
Germany China 1993 16
France China 1993 166
Germany Croatia 1993 0.5
France South Africa 1993 20

I've created a network from this data set with the code below:

net_arms1993 <- as.network(arms1993, directed = TRUE)
net_arms1993

I can plot the network:

plot(net_arms1993)

What I'm having trouble doing is assigning the value of the arms export to each edge. My ultimate goal is to run a series of ERGMs using edge as a covariate in the model. What I can't figure out how to do is, how can I add this value? This is what I've come up with:

edge_values <- arms1993$TIV
set.edge.value(net_arms1993, "TIV", edge_values)
get.edge.value(net_arms1993, "TIV")

The get.edge.value function works (I retrieve the right values). However, I don't think it is working because when I plug it into the ERGM, it returns a value of Inf for the edge covariate:

arms.model1993 <- ergm(net_arms1993 ~ edges + edgecov(net_arms1993, "TIV"))
summary(arms.model1993)
0

There are 0 answers