#Examples are a bit slow, so not automatically run
#Generate a simple CD-CSTERGM trajectory; equilibrium mean outdegree
#is 2, dissolution rate is 1/3
set.seed(1331)
n <- 25
net <- simulate(network.initialize(n)~edges, coef=log(2/(n-3)))
traj <- simEGP(net~edges, coef=list(formation=log(2/(n-3)*1/3),
dissolution=log(1/3)), time=5000, process="CDCSTERGM",
return.changetime=TRUE, verbose=FALSE)
network.edgecount(traj)/(n-1) #Mean degree apx 2
dur <- durations(traj) #Get durations
head(dur) #All are right-censored
mean(dur[,1]) #Apx 3 (despite censoring)
#Repeat, but now using a networkDynamic object
set.seed(1331)
net <- simulate(network.initialize(n)~edges, coef=log(2/(n-3)))
traj <- simEGP(net~edges, coef=list(formation=log(2/(n-3)*1/3),
dissolution=log(1/3)), time=500, process="CDCSTERGM",
return.networkDynamic=TRUE, verbose=FALSE)
slice <- traj %t% 499 #Take a slice near the end
network.edgecount(slice)/(n-1) #Mean degree apx 2
dur <- durations(traj) #Get durations
head(dur) #More of a mix
mean(dur[,1]) #Apx 3
hist(dur[,1], xlab="Time", main="Duration Distribution") #Visualize
Run the code above in your browser using DataLab