msm.sim: MSM.sim : output of a stergm simulation of basic sex contact...

msm.simR Documentation

MSM.sim : output of a stergm simulation of basic sex contact network model

Description

A 1000 vertex networkDynamic object that contains the output of 10 timesteps of a discrete stergm simulation of a basic sex contact network model. The model has two vertex types ('races') with different contact preferencs expressed with a nodematch parameter. The output network object is included as an example because re-running the model can take a while.

Usage

data(msm.sim)

Format

a networkDynamic object

Details

The model was built with the following stergm:

msm.net <- network.initialize(1000, directed=F)  
msm.net %v% 'race' <- rep(c(1,2),500)
sm.form.constraints <- ~bd(maxout=2)
msm.form.formula <- ~edges+nodematch('race')+
	degree(2)
msm.target.stats <- c(450,375,50)
msm.diss.formula <- ~offset(edges)+offset(nodematch("race"))
msm.theta.diss <- c(2.944, -0.747)
msm.fit <- stergm(msm.net,
	formation= msm.form.formula,
	dissolution= msm.diss.formula,
	targets="formation",
	target.stats= msm.target.stats,
	offset.coef.diss = msm.theta.diss,
	form.constraints=msm.form.constraints,
	estimate = "EGMME",
	control=control.stergm(SA.plot.progress=TRUE)
)																				
msm.sim <- simulate(msm.fit,nsim=1,time.slices=100)

However, the tergm-related output that would normally be attached to the network (toggles, etc) has been removed.

Source

statnet project stergm tutorial.

Examples

require(network)
require(networkDynamic)
data(msm.sim)
# show the network, aggregating 5 timesteps
plot(network.extract(msm.sim,onset=0,terminus=5),
  vertex.col=msm.sim%v%"race",vertex.cex=0.5,edge.col="gray")

# this could take 10 minutes, so don't run in example checking
## Not run: 
# use ndtv to render a movie of the momentary view of the network
render.animation(msm.sim,vertex.col=msm.sim%v%'race',vertex.cex=.5)
ani.replay()
saveVideo(ani.replay(),video.name="msm.simMomentary.mp4", other.opts="-b 5000k",clean=TRUE)

# another version, this time with more temporal aggregation
msm.sim <- compute.animation(msm.sim,slice.par=list(start=0,
                                                    end=10,
                                                    interval=1,
                                                    aggregate.dur=3,
                                                    rule='latest'))
# also more render more inbetween frames
render.animation(msm.sim,render.par = list(tween.frames = 15,show.times=TRUE), 
  vertex.col=msm.net%v%'race',vertex.cex=.5)
saveVideo(ani.replay(),video.name="msm.sim3Aggregated.mp4", other.opts="-b 5000k",clean=TRUE)

## End(Not run)

ndtv documentation built on July 4, 2024, 5:08 p.m.