Hi Tore,

thank you, will do that:)!

Hi Elena,

Please read up on the various data types in R. When you create a vector of numbers from 1 to 10, you can only replace each of these values with another value and not an object. If you would like to store objects within objects, use lists.

Best,

Tore

me again. I tried doing this:

out4 <- c(1,2,3,4,5,6,7,8,9,10)

# Loop across

for(i in 1:length(out4)) {

# Generate random network

randonet4 andere Messung closure (brauch ich nt)

out4[i]<- reinforcement_tm(randonet4) }

print(randonet4)

print(out4)

And it helps I get different reinforcement values. But if I try this loop with something" as complex" as this:

out5 <- c(1,2,3,4,5,6,7,8,9,10)

# Loop across

for(i in 1:length(out5)) {

# Generate random network

randonet5 <- rg_tm(ni=133,np=48,ties=190,weights=1,seed=i)

# Compute

out5[i] <- projecting_tm(randonet5, "Newman")

out6 <- betweenness_w(out5[i])[,"betweenness"]}

print (out6)

I get this warning message:

Error in if (NC == 2) net <- data.frame(tmp[, 1], tmp[, 2]) :

argument is of length zero

In out5[i] <- projecting_tm(randonet5, "Newman") :

number of items to replace is not a multiple of replacement length

Can you help?

Best,

elena

I have a two-mode, undirected, unweighted network. One mode are people, the other are projects that they participated in. I calculated (with all the code from your website! Thanks!) betweenness and so on. Now I want to create 1000 random networks and see if my estimates are significantly different from the random networks. Therefore I need to write a loop. I am not quite sure whether my code makes any sense. Can you take a look? There is no Error or something, but the output is quite confusing. I want to transfer the random network data into SPSS and calculate mean betweenness for example and than do some t-tests (or something else) in order to see if there is a significant difference. Have you done something like this already?

And if I print(tmp) the output is a list. But it should be 1000 different lists with the betweenness of each random network. Or am I mistaken?

Thank you for your help:)

out4 <- rep(twomode5, 1000)

# Loop across

for(i in 1:length(out4)) {

# Generate random network

n1 <- length(unique(twomode5[,1]))

n2 <- length(unique(twomode5[,2]))

ptie <- nrow(twomode5)/(n1*n2)

randonet andere Messung closure (brauch ich nt)

out5<- reinforcement_tm(randonet)

# Compute betweenness

net <- projecting_tm(randonet, "Newman")

tmp <- betweenness_w(net )[,"betweenness"]

}

print (tmp)

Best regards,

Elena

Hi Matthew,

The easiest way to do this is to create an output vector and then a loop. Below is an example snippet of code.

Best,

Tore

# Load tnet library(tnet) # Initialize output vector out <- rep(NaN, 1000) # Loop across for(i in 1:length(out)) { # Generate random network randonet <- rg_tm(ni=1125,np=338,ties=1504,weights=1,seed=i) # Compute reinforcement and store in output vector out[i] <- reinforcement_tm(randonet) } # Average score mean(out)]]>

randonet <- rg_tm(ni=1125,np=338,ties=1504,weights=1,seed=NULL)

randonet <- as.tnet(randonet, type="binary two-mode tnet")

reinforcement_tm(randonet)

clustering_tm(randonet)

clustering_local_tm(randonet)

As far as I can tell, this has worked fine. However, I would like to stabilize the random measurements by averaging the values from multiple random networks. Is there an easy way to do the above procedure to, for example, 1,000 random networks simultaneously and then output the averages of the resulting measures?

]]>Hi Thomas,

The difference is the method used for creating the network. When you set the probability, each tie has this probability of being created — i.e., whether or not each individual tie exists is completely independent of the other ties. In the resulting network, there approximately -but not exactly be- (probability*n*(n-1)) ties. Conversely, if the number of ties is specified (e.g., ties=300), there will be exactly that amount of ties in the resulting network. In this case, the ties are not completely independent of each other as the number is fixed.

In terms of the degree distribution, both methods will create a classical random network with a Poisson distribution. If you would like to maintain a degree distribution, see the rg_reshuffling_tm-function.

Best,

Tore

I am using the rg_tm function to create a random network. I would like to know if there is a difference in the resulting degree distribution of the network if (1) I put in the exact number of ties (e.g. ties=300) or (2) if I Put in the probability of having a tie (e.g. ties=0.05).

For example that the degree in the second case is a Poisson distribution while in the first case there is no distribution function but just a single value.

Best regards,

Thomas