Description Usage Arguments Value Examples
This function draws weights according to a user-defined distribution for the edges of an existing binary SBM.
1 | rWeightSBM(anSBM, family = c("gaussian", "poisson", "laplace"), theta)
|
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
|
an SBM weight weigthed edges
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ## 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)
hist(igraph::E(mySBM_Gaussian)$weight, breaks = sqrt(igraph::gsize(mySBM_Gaussian)))
## 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)
hist(igraph::E(mySBM_Laplace)$weight, breaks = sqrt(igraph::gsize(mySBM_Laplace)))
## 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)
hist(igraph::E(mySBM_Poisson)$weight, breaks = sqrt(igraph::gsize(mySBM_Poisson)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.