Learn R Programming

NetMix (version 0.2.0.3)

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,
  ...
)

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".

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.

...

Currently ignored

Author

Santiago Olivella (olivella@unc.edu), Adeline Lo (aylo@wisc.edu), Tyler Pratt (tyler.pratt@yale.edu), Kosuke Imai (imai@harvard.edu)

Examples

Run this code
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, 
                                           conv_tol = 1e-2,
                                           hessian = FALSE))

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

Run the code above in your browser using DataLab