Learn R Programming

NetMix (version 0.1.5)

simulate.mmsbm: Simulate a complete sociomatrix from an mmsbm object

Description

The function generates one sample network from the posterior predictive of the model represented by a fitted mmsbm object.

Usage

# S3 method for mmsbm
simulate(
  object,
  nsim = 1,
  seed = NULL,
  new.data.dyad = NULL,
  new.data.monad = NULL,
  parametric_mm = FALSE,
  ...
)

Arguments

object

An object of class mmsbm, a result of a call to mmsbm

nsim

Number of networks to simulate

seed

RNG seed.

new.data.dyad

An optional data.frame object. If not NULL, use these dyadic predictor values instead of those used to fit the original model.

new.data.monad

An optional data.frame object. See new.data.dyad.

parametric_mm

Boolean. Should the variational posterior be used for sampling the mixed-memberships (FALSE), or should the mixed-meberships be formed using the parameters in the monadic regression equation (TRUE)? Defaults to FALSE. If is.null(new.data.monad)=FALSE, setting this to FALSE will produce an error.

...

Currently ignored

Value

List of length nsim of simulated networks. If new.data.dyad = NULL, each element is a vector of length nrow(object$dyadic.data). Else, vector of length nrow(new.data.dyad). If seed is not NULL, return object includes its value as attribute "seed".

Examples

Run this code
# NOT RUN {
library(NetMix)
## Load datasets
data("lazega_dyadic")
data("lazega_monadic")
## Estimate model with 2 groups
lazega_mmsbm <- mmsbm(SocializeWith ~ Coworkers,
                      ~  School + Practice + Status,
                      senderID = "Lawyer1",
                      receiverID = "Lawyer2",
                      nodeID = "Lawyer",
                      data.dyad = lazega_dyadic,
                      data.monad = lazega_monadic,
                      n.blocks = 2,
                      mmsbm.control = list(seed = 123, 
                                           hessian = FALSE))

## Simulate 5 new networks
lazega_sim <- simulate(lazega_mmsbm, nsim = 5, seed = 123)

# }

Run the code above in your browser using DataLab