This function draws weights according to a user-defined distribution for the edges of an existing binary SBM.

rWeightSBM(anSBM, family = c("gaussian", "poisson", "laplace"), theta)

Arguments

anSBM

SBM sampled from the rSBM function with nbBlock

family

character describing the distribution used for the weigths

theta

list embedding parameters required for the distribution of the weights. Either "gaussian", "poisson" or "laplace". See details.

Elements in the theta should be named as follows, depending on the argument family, with dimension matching the number of blocks in the original SBM:

  • Gaussiantheta$mu, a (nbBlock x nbBlock) matrix of means; theta$sigma, a (nbBlock x nbBlock) matrix of standard deviations

  • Laplacetheta$m, a (nbBlock x nbBlock) matrix of location parameters; theta$s, a (nbBlock x nbBlock) matrix of scale parameters

  • Poissontheta$lambda, a (nbBlock x nbBlock) matrix of means.

  • Otherssoon available.

Value

an SBM weight weigthed edges

Examples

## graph parameters nbNodes <- 90 blockProp <- c(.5, .25, .25) # group proportions nbBlock <- length(blockProp) # number of blocks connectParam <- diag(.4, nbBlock) + 0.05 # connectivity matrix: affiliation network ## Graph Sampling mySBM <- rSBM(nbNodes, connectParam, blockProp) ## Sampling Gaussian weights mu_within <- 4 ; sigma_within <- .5 mu_between <- 2 ; sigma_between <- .5 theta <- list() theta$mu <- matrix(mu_between , nbBlock, nbBlock); diag(theta$mu) <- mu_within # means theta$sigma <- matrix(sigma_between, nbBlock, nbBlock); diag(theta$sigma) <- sigma_within # sd mySBM_Gaussian <- rWeightSBM(mySBM, "gaussian", theta)
#> Error in igraph::gsize(mySBM): object 'mySBM' not found
hist(igraph::E(mySBM_Gaussian)$weight, breaks = sqrt(igraph::gsize(mySBM_Gaussian)))
#> Error in "igraph" %in% class(graph): object 'mySBM_Gaussian' not found
## Sampling Laplace weights m_within <- 4 ; s_within <- .5 m_between <- 2 ; s_between <- .5 theta <- list() theta$m <- matrix(m_between, nbBlock, nbBlock); diag(theta$m) <- m_within # location parameter theta$s <- matrix(s_between, nbBlock, nbBlock); diag(theta$s) <- s_within # scale parameters mySBM_Laplace <- rWeightSBM(mySBM, "laplace", theta)
#> Error in igraph::gsize(mySBM): object 'mySBM' not found
hist(igraph::E(mySBM_Laplace)$weight, breaks = sqrt(igraph::gsize(mySBM_Laplace)))
#> Error in "igraph" %in% class(graph): object 'mySBM_Laplace' not found
## Sampling Poisson weights lambda_within <- 4 lambda_between <- 4 theta <- list() # mean/variance parameter theta$lambda <- matrix(lambda_between, nbBlock, nbBlock) diag(theta$lambda) <- lambda_within mySBM_Poisson <- rWeightSBM(mySBM, "poisson", theta)
#> Error in igraph::gsize(mySBM): object 'mySBM' not found
hist(igraph::E(mySBM_Poisson)$weight, breaks = sqrt(igraph::gsize(mySBM_Poisson)))
#> Error in "igraph" %in% class(graph): object 'mySBM_Poisson' not found