Generating peer nomination dataset in R

#1
Hi all,

I have been trying to generate a dataset on peer nominations in R. Often in research participants are asked to nominate others in the peer group (or classroom) as a friend.

My requirements
Each peer has to nominate x other peers as friends
Participants can't select themselves
Participants can only select a peer once.:

Below is my code ( n = sample size/class size, nom = amount of nominations):


network <- function(n, nom){
mat <- matrix(data = NA, nrow = n, ncol = nom, byrow = TRUE)
for (i in 1:n){
mat[i, ] <- (sample((1:n)[-i], nom, replace = F))
}
as.data.frame(mat)
colnames(mat) <- paste("nom", 1:n, sep="")
}



The function works fine, but I want to make it more realistic, since now the selection process is pretty random.

If someone selects a peer as a friend I want to increase the chance the peer will nominate the other as well. This way the friendship becomes reciprocal.

Also I would like to generate a variable (lets say popularity) which is random, this is
no problem. But then high values of popularity should be related with an increased
chance of nomination.

I have no idea where to start. Does someone has suggestions or knows of other treads that are relevant for my questions?

Thank you!:tup:
 

hlsmith

Not a robit
#2
Good luck. I am not experienced in creating the dataset you are interested, but it seems like you will need a weighting factor that could get transformed into a probability. I was thinking of, say when you examine a Bernoulli trial and the probability is not 0.5.