R/sampling_sbm.R
rWeightSBM.Rd
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)
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
## 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#> 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#> 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#> Error in "igraph" %in% class(graph): object 'mySBM_Poisson' not found