ndtv
ndtv copied to clipboard
test ndtv with output from RSiena
(migrated from statnet trac ticket #679) would be really cool to be able to have this working with another package
2 years ago
Corresponded with Christian about this, code below seems to work, hopefully he can recommend another model to visualize.
# example testing creating a movie using RSiena
library(RSiena)
library(ndtv)
# using example from siena07 man page
# need to set Maximum Likelihood to get chain estimation
myalgorithm <- sienaAlgorithmCreate(nsub=2, n3=10,maxlike=TRUE)
# nsub=2 and n3=100 is used here for having a brief computation, not for practice.
mynet1 <- sienaDependent(array(c(tmp3, tmp4), dim=c(32, 32, 2)))
mydata <- sienaDataCreate(mynet1)
myeff <- getEffects(mydata)
# set to return simulation chains as dataframe
sim_ans <- siena07( myalgorithm, data = mydata,
effects = myeff,
returnChains=TRUE,
returnDataFrame=TRUE,
batch=TRUE )
# convert it to a list of network objects
netList<-lapply(sim_ans$chain,function(sim){
edgelist<-cbind(sim[[1]][[1]]$Ego,sim[[1]][[1]]$Alter)+1
as.network.matrix(edgelist,matrix.type='edgelist',loops=TRUE)
})
# convert the list of network objects to a networkDynamic object
myDynamicNet<-networkDynamic(network.list=netList)
render.animation(myDynamicNet)
I also wrote some draft code for converting RSiena network objects to network dynamic and back, need to follow up on that...