### Example Output of Package Version Check Source: https://statnet.org/workshop-relevent/relevent_tutorial.html This is an example output showing the version number of the 'relevent' package. ```text [1] '1.2.1' ``` -------------------------------- ### Install necessary packages Source: https://statnet.org/workshop-tergm/tergm_tutorial.R Installs the 'htmlwidgets' and 'latticeExtra' packages, which provide additional graphing utilities. ```R install.packages('htmlwidgets') install.packages('latticeExtra') ``` -------------------------------- ### Access FFmpeg Installation Help Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html Displays the help page for installing FFmpeg, which is required for saving animations as video files using the 'animation' package. ```R ?install.ffmpeg # help page for installing ffmpeg ``` -------------------------------- ### Install the Entire Statnet Suite Source: https://statnet.org/workshop-intro-sna-tools Installs all packages within the Statnet suite. This is an optional step for this tutorial but provides a comprehensive set of tools for network analysis. ```r install.packages('statnet') ``` -------------------------------- ### Example Version Output in R Source: https://statnet.org/workshop-relevent/sunbelt_2022_relevent_tutorial.html This is an example output showing the version number of the 'relevent' package. ```text [1] '1.1' ``` -------------------------------- ### Check Java Installation Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html Verify if Java is correctly installed by checking its version from the command line. Ensure Java is added to your system's PATH environment variable. ```bash system('java -version') ``` -------------------------------- ### Install Statnet Meta-Package Source: https://statnet.org/install-statnet Use this command to install the core Statnet packages and their dependencies from CRAN. This is recommended for beginners. ```r > install.packages("statnet") ``` -------------------------------- ### Install statnetWeb Package Source: https://statnet.org/nme/d0-install.html Install the statnetWeb package using this command. This is a separate installation from the main EpiModel package. ```r install.packages("statnetWeb") ``` -------------------------------- ### Install Statnet Packages in R Source: https://statnet.org/workshop-relevent-experiments/in_silico_experiments_tutorial.RData Installs the 'relevent', 'sna', and 'parallel' R packages. Ensure you have R installed and an internet connection. ```R install.packages(c("relevent","sna","parallel")) ``` -------------------------------- ### Install ndtv Package Source: https://statnet.org/nme/d3-s8-ndtv.R Install the ndtv package from CRAN. If CRAN binaries are unavailable, use remotes to install from GitHub. ```R install.packages("ndtv") ``` ```R # install this package in case you do not already have it installed install.packages("remotes") remotes::install_github("statnet/ndtv", subdir = "ndtv") ``` -------------------------------- ### Check Installed Package Versions Source: https://statnet.org/nme/d0-install.html Verify the installation and check the versions of installed EpiModel, statnet, and related packages. This command displays detailed session information. ```r sessionInfo() ``` -------------------------------- ### Install statnet Packages Source: https://statnet.org/workshop-ergmgp/ergmgp_tutorial.R Installs the ergmgp, sna, tsna, and ndtv R packages along with their dependencies. Ensure R is installed and configured before running. ```r install.packages(c("ergmgp","sna","tsna","ndtv")) ``` -------------------------------- ### Install Statnet Packages in R Source: https://statnet.org/workshop-relevent/sunbelt_2022_relevent_tutorial.html Installs the 'relevent' and 'sna' packages, which are essential for relational event modeling with Statnet. 'sna' will automatically install 'network' if needed. ```r install.packages(c("relevent","sna")) ``` -------------------------------- ### Install EpiModel Package Source: https://statnet.org/nme/d0-install.html Use this command to install the EpiModel package and its dependencies. R may prompt you to select a mirror site. ```r install.packages("EpiModel", dependencies = TRUE) ``` -------------------------------- ### Install R Package Source: https://statnet.org/nme/d0-tutR.html Installs a specified package from CRAN, including any necessary dependencies. ```r install.packages("packagename") ``` -------------------------------- ### Install Core Network Analysis Packages in R Source: https://statnet.org/workshop-intro-sna-tools Installs essential R packages for network analysis, including 'network', 'sna', 'igraph', 'tidygraph', 'ggraph', 'intergraph', and 'remotes'. Ensure R and RStudio are installed first. ```r install.packages(c("network", "sna", "igraph", "tidygraph", "ggraph", "intergraph", "remotes")) ``` -------------------------------- ### Get List of tsna Package Functions Source: https://statnet.org/workshop-tergm/tergm_tutorial.R To see all available functions in the tsna package, use the help.start() function. ```r help(package="tsna") ``` -------------------------------- ### Verbose Simulation Output Example Source: https://statnet.org/workshop-relevent/sunbelt_2022_relevent_tutorial.html This output shows the progress of the simulation process, indicating which event is currently being processed. ```text Working on event 25 of 481 Working on event 50 of 481 Working on event 75 of 481 Working on event 100 of 481 Working on event 125 of 481 Working on event 150 of 481 Working on event 175 of 481 Working on event 200 of 481 Working on event 225 of 481 Working on event 250 of 481 Working on event 275 of 481 Working on event 300 of 481 Working on event 325 of 481 Working on event 350 of 481 Working on event 375 of 481 Working on event 400 of 481 Working on event 425 of 481 Working on event 450 of 481 Working on event 475 of 481 ``` -------------------------------- ### Install and Load ndtv Package Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html Installs the ndtv package and its dependencies from CRAN, then loads it along with animation and networkDynamic. Requires R and potentially non-R external dependencies like FFmpeg for video output. ```r install.packages('ndtv',repos='http://cran.us.r-project.org', dependencies=TRUE) library(ndtv) # also loads animation and networkDynamic ``` -------------------------------- ### Load Example Dynamic Network Data Source: https://statnet.org/workshop-tergm/tergm_tutorial.R Loads the 'short.stergm.sim' dataset, which is an example of a simulated dynamic network generated by the tergm package. ```r data(short.stergm.sim) ``` -------------------------------- ### Install Individual Statnet Package Source: https://statnet.org/install-statnet Use this command to install a specific package from the Statnet suite, such as 'ergm', along with its dependencies. This is useful if you only need certain functionalities. ```r install.packages("ergm") ``` -------------------------------- ### Load ndtv Package and Dependencies Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html Loads the ndtv package and its dependencies. Ensure the package is installed before running. ```r library(ndtv) ``` -------------------------------- ### Load Statnet Package Source: https://statnet.org/install-statnet After installation, use this command to load the Statnet meta-package into your R session for use. ```r > library(statnet) ``` -------------------------------- ### Check ergmgp Package Version Source: https://statnet.org/workshop-ergmgp/ergmgp_tutorial.R Retrieves and displays the installed version of the ergmgp package. This is useful for ensuring compatibility with tutorial examples. ```r packageVersion("ergmgp") ``` -------------------------------- ### Load Florentine Network Data Source: https://statnet.org/workshop-tergm/tergm_tutorial.R Loads the Florentine marriage network dataset. This is a common starting point for network analysis examples. ```R data(florentine) ``` -------------------------------- ### Access R Package Vignettes Source: https://statnet.org/nme/d0-tutR.html Opens the vignette documentation for a specified R package, providing detailed examples and usage guides. ```r browseVignettes("network") ``` -------------------------------- ### Simulate SI Disease with Strong Intervention Source: https://statnet.org/nme/d4-s6-Vax.R Simulates an SI disease with a highly effective intervention starting at week 25. This setup is for a closed population. ```R param <- param.net(inf.prob = 0.5, inter.eff = 0.96, inter.start = 25) init <- init.net(i.num = 5) control <- control.net(type = "SI", nsteps = 100, nsims = 10, ncores = 5) sim <- netsim(est, param, init, control) plot(sim) ``` -------------------------------- ### Initialize Network and Simulate Trajectory Source: https://statnet.org/workshop-ergmgp/ergmgp_tutorial.R Sets up a network with vertex attributes and then simulates a trajectory using the simEGP function, returning the simulation history. ```R set.seed(1331) net <- network(rgraph(50, tp=1.5/49, mode="graph"), directed = FALSE) net %v% "x" <- sample(0:1, 50, replace = TRUE) set.seed(1331) simtgh <- simEGP(form = tgform, coef = tgcoef, time = 100, process = "CSTERGM", return.history = TRUE) ``` -------------------------------- ### Check ndtv Package Version Source: https://statnet.org/nme/d3-s8-ndtv.R Verify the installed version of the ndtv package. This should match the version number specified in the tutorial. ```R library("ndtv") packageVersion("ndtv") ``` -------------------------------- ### Initialize Network for Short Durations Source: https://statnet.org/nme/d3-s8-ndtv.R Initializes a network with 100 nodes and sets up parameters for a simulation with short edge durations (2 time steps). ```R nw <- network_initialize(n = 100) formation <- ~edges target.stats <- 40 coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 2) est <- netest(nw, formation, target.stats, coef.diss) ``` -------------------------------- ### Browse NDTV Package Vignettes Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html Open the package vignettes for NDTV to find more detailed examples and documentation. Vignettes provide in-depth guides on package usage. ```R browseVignettes(package='ndtv') ``` -------------------------------- ### Load R Package Source: https://statnet.org/nme/d0-tutR.html Loads an installed package into the current R session, making its functions available for use. ```r library("packagename") ``` -------------------------------- ### Fit ERGM with Valued Terms Source: https://statnet.org/workshop-valued/valued.R Example of fitting an ERGM model using valued network terms like mutuality and transitive/cyclical weights with a Binomial reference distribution. Ensure the 'ergm' package is installed and loaded. ```R samplk.tot.ergm <- ergm(samplk.tot ~ sum + nonzero + mutual("min") + transitiveweights("min", "max", "min") + cyclicalweights("min", "max", "min"), reference = ~Binomial(3)) ``` -------------------------------- ### Initialize Network and Run Basic CTERGM Simulation Source: https://statnet.org/workshop-ergmgp/ergmgp_tutorial.R Initializes an undirected network and runs a CTERGM simulation for 100 time units using the simEGP function. The coefficient is derived from the model's theoretical properties. ```R set.seed(1331) net <- network.initialize(10, directed = FALSE) #Initialize the network simbg <- simEGP(form = net ~ edges, coef = log(1.5/(9-1.5))/2, time = 100, process = "CTERGM") #Run the simulation ``` -------------------------------- ### Install and Update Statnet Packages in R Source: https://statnet.org/workshop-advanced-ergm/advanced_ergm_tutorial.R Installs the 'ergm.multi' and 'ggrepel' packages, which will also install their dependencies like 'ergm' and 'network'. It then updates all installed packages to their latest versions. ```R install.packages(c('ergm.multi', 'ggrepel')) update.packages(ask=FALSE, checkBuilt=TRUE) ``` -------------------------------- ### Structure of Simulated Data Source: https://statnet.org/workshop-relevent/sunbelt_2022_relevent_tutorial.html This is an example of the output format for a simulated event sequence. It typically includes probabilities and event details. ```text [,1] [,2] [,3] [1,] 0.0004468037 27 13 [2,] 0.0004626364 13 27 [3,] 0.0004704296 27 13 [4,] 0.0004819716 13 27 [5,] 0.0004923628 27 13 [6,] 0.0005274594 13 27 [7,] 0.0005329692 27 13 [8,] 0.0005379387 13 27 [9,] 0.0005687593 27 13 [10,] 0.0006085596 13 27 [11,] 0.0006466945 27 13 [12,] 0.0006974054 13 27 [13,] 0.0007084274 27 13 [14,] 0.0007339464 13 27 [15,] 0.0007466830 27 13 [16,] 0.0007492684 13 27 [17,] 0.0007884910 27 13 [18,] 0.0008027626 13 27 [19,] 0.0008181866 27 13 [20,] 0.0008316953 13 27 [21,] 0.0008386961 27 13 [22,] 0.0008486558 13 27 [23,] 0.0008972992 27 13 [24,] 0.0009089349 13 27 [25,] 0.0009255863 27 13 [26,] 0.0009356596 13 27 [27,] 0.0009481630 27 13 [28,] 0.0009701589 13 27 [29,] 0.0010908132 27 13 [30,] 0.0011515705 13 27 [31,] 0.0011593256 27 13 [32,] 0.0012039064 13 27 [33,] 0.0012429321 27 13 [34,] 0.0012671529 13 27 [35,] 0.0012826756 27 13 [36,] 0.0012830967 13 27 [37,] 0.0012937788 27 13 [38,] 0.0013168741 13 27 [39,] 0.0013233227 27 13 [40,] 0.0013545029 13 27 [41,] 0.0013680710 27 13 [42,] 0.0014074783 13 27 [43,] 0.0014247736 27 13 [44,] 0.0014539617 13 27 [45,] 0.0015243130 27 13 [46,] 0.0015514804 13 27 [47,] 0.0015694450 27 13 [48,] 0.0015723410 14 7 [49,] 0.0016150099 7 14 [50,] 0.0019005500 14 7 [51,] 0.0019436756 14 1 [52,] 0.0026720080 10 15 [53,] 0.0027797172 15 27 [54,] 0.0028284341 27 13 [55,] 0.0028393713 13 27 [56,] 0.0028778679 27 13 [57,] 0.0028872755 13 27 [58,] 0.0029061584 27 13 [59,] 0.0029642798 13 27 [60,] 0.0029984286 27 13 [61,] 0.0030100941 13 27 [62,] 0.0030511743 13 10 [63,] 0.0031090747 10 13 [64,] 0.0032220014 13 10 [65,] 0.0032321834 10 13 [66,] 0.0032814074 13 10 [67,] 0.0032917877 10 13 [68,] 0.0033707924 19 13 [69,] 0.0034818303 13 19 [70,] 0.0034824403 19 13 [71,] 0.0034995468 13 19 [72,] 0.0035038253 19 13 [73,] 0.0036111933 13 19 [74,] 0.0036167921 19 13 [75,] 0.0036274954 13 19 [76,] 0.0036565886 19 13 [77,] 0.0037396416 13 19 [78,] 0.0037581215 19 13 [79,] 0.0037626692 13 19 [80,] 0.0038189895 19 13 [81,] 0.0039261296 13 19 [82,] 0.0039629416 19 13 [83,] 0.0040927937 13 19 ``` -------------------------------- ### Network Animation Setup Source: https://statnet.org/nme/d3-s8-ndtv.R Retrieves the network from simulation results, applies color transformations, and defines parameters for computing and rendering a network animation. ```R nw <- get_network(sim) nw <- color_tea(nw) slice.par <- list(start = 1, end = 25, interval = 1, aggregate.dur = 1, rule = "any") render.par <- list(tween.frames = 10, show.time = FALSE) plot.par <- list(mar = c(0, 0, 0, 0)) compute.animation(nw, slice.par = slice.par, verbose = TRUE) ``` -------------------------------- ### Install ERGM Package Source: https://statnet.org/workshop-ergm/ergm_tutorial.R Install the 'ergm' package in R. This will also install the 'network' package if it is not already present. ```R install.packages('ergm') ``` -------------------------------- ### Initialize Network with Triangles and Short Durations Source: https://statnet.org/nme/d3-s8-ndtv.R Initializes a network with 100 nodes, including triangle formation (gwesp) and short edge durations (20 time steps). ```R nw <- network_initialize(n = 100) formation <- ~edges + gwesp(0, TRUE) target.stats <- c(40, 25) coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 20) est <- netest(nw, formation, target.stats, coef.diss) sim <- netsim(est, param, init, control) ``` -------------------------------- ### Initialize Network for Long Durations Source: https://statnet.org/nme/d3-s8-ndtv.R Initializes a network with 100 nodes and sets up parameters for a simulation with very long edge durations (1e5 time steps). ```R nw <- network_initialize(n = 100) formation <- ~edges target.stats <- 40 coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 1e5) est <- netest(nw, formation, target.stats, coef.diss) ``` -------------------------------- ### Initialize Infected Individuals Source: https://statnet.org/nme/d4-s3-Demography.R Use `init.net` to specify the initial number of infected individuals in the simulation. This example sets 50 individuals to be infected initially. ```R init <- init.net(i.num = 50) ``` -------------------------------- ### Install Statnet Packages in R Source: https://statnet.org/workshop-tergm/tergm_tutorial.R Installs the necessary Statnet packages for temporal network analysis in R. Ensure R and RStudio are installed first. ```r # statnet packages install.packages('tergm') install.packages('tsna') install.packages('ndtv') ``` -------------------------------- ### Initialize Network and Estimate Model Parameters Source: https://statnet.org/nme/d3-s8-ndtv.R Initialize a network with a specified number of nodes and define the formation model including 'edges' and 'concurrent' terms. Target statistics and dissolution coefficients are set for model estimation. ```R nw <- network_initialize(n = 100) formation <- ~edges + concurrent target.stats <- c(40, 0) coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 20) est <- netest(nw, formation, target.stats, coef.diss) ``` -------------------------------- ### Initialize Network and Set Formation Model Source: https://statnet.org/nme/d3-s8-ndtv.R Initialize a network with 100 nodes and define an edges-only formation model. Set target statistics and dissolution coefficients for network evolution. ```R nw <- network_initialize(n = 100) formation <- ~edges target.stats <- 40 coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 20) est <- netest(nw, formation, target.stats, coef.diss) ``` -------------------------------- ### Dynamic Network Visualization with ndtv Source: https://statnet.org/nme/d3.html Tutorial and lab for visualizing dynamic networks using the ndtv package with EpiModel. Requires R. ```R # R Code for Dynamic Network Visualization with ndtv # (Specific code content not provided in the source text, only a link to R Code) ``` -------------------------------- ### Install Statnet Packages in R Source: https://statnet.org/workshop-valued/valued.R Installs essential Statnet packages for network analysis, including ergm.count, ergm.rank, and latentnet. It also updates all installed packages to their latest versions. ```r install.packages("ergm.count") install.packages("ergm.rank") install.packages("latentnet") update.packages() ``` -------------------------------- ### Dynamic Network Initialization and Parameterization Source: https://statnet.org/nme/d2-s8-TERGMs.R Initialize a network with a dynamic number of nodes and calculate target statistics as a function of network size and desired mean degree. ```R # Do not run nnodes <- 1000 meandeg <- 0.4 net2 <- network_initialize(nnodes) fit2 <- netest(net2, formation = ~edges, target.stats = nnodes*meandeg/2, coef.diss = dissolution_coefs(~offset(edges), 90)) ``` -------------------------------- ### Configure Network Simulation Control Settings Source: https://statnet.org/nme/d4-s3-Demography.R Use `control.net` to set simulation parameters. Key arguments include `resimulate.network` to enable dynamic network updates, `epi.by` for stratified prevalence, and `tergmLite` for simulation efficiency. ```R control.full <- control.net(type = "SI", nsteps = 300, nsims = 1, ncores = 1, resimulate.network = TRUE, epi.by = "risk", tergmLite = FALSE) ``` ```R control.tl <- control.net(type = "SI", nsteps = 300, nsims = 1, ncores = 1, resimulate.network = TRUE, epi.by = "risk", tergmLite = TRUE) ``` -------------------------------- ### Initialize Network Source: https://statnet.org/nme/d2-s8-TERGMs.R Initialize a dynamic network with a specified number of nodes. This creates an empty network structure. ```r net1 <- network_initialize(100) ``` -------------------------------- ### Initialize a Static Network Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html Initializes a static network with a specified number of vertices. Use this to begin creating a network structure. ```R wheel <- network.initialize(10) class(wheel) ``` ```R [1] "network" ``` -------------------------------- ### Check 'relevent' Package Version Source: https://statnet.org/workshop-relevent-experiments/in_silico_experiments_tutorial.RData Displays the installed version number of the 'relevent' package. Useful for verifying installation. ```R packageVersion("relevent") ``` -------------------------------- ### Initialize and Simulate Network with Modified Size Source: https://statnet.org/nme/d2-s8-TERGMs.R Initialize a network with a specified number of nodes and simulate its evolution. Adjust target statistics when changing network size. ```R net2 <- network_initialize(1000) fit2 <- netest(net2, formation = ~edges, target.stats = 200, coef.diss = dissolution_coefs(~offset(edges), 90)) sim2 <- netdx(fit2, nsteps = 1000, nsims = 10, keep.tedgelist = TRUE) ``` -------------------------------- ### Simulation Initialization Output Source: https://statnet.org/workshop-ergmgp/ergmgp_tutorial.R This output shows the initialization process for each simulated trajectory, including the maximum number of events, time limits, and initial potential values. ```text Initializing simulation: max events=6, max time=inf, initial pot=(0.000000,0.000000) event=0, t=0.000000, pot=(0.000000,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(-6.614965,0.000000) event=0, t=0.000000, pot=(-6.614965,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(-6.068909,0.000000) event=0, t=0.000000, pot=(-6.068909,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(-7.205523,0.000000) event=0, t=0.000000, pot=(-7.205523,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(1.308488,0.000000) event=0, t=0.000000, pot=(1.308488,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(4.462090,0.000000) event=0, t=0.000000, pot=(4.462090,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(10.371563,0.000000) event=0, t=0.000000, pot=(10.371563,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(9.941063,0.000000) event=0, t=0.000000, pot=(9.941063,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(16.868028,0.000000) event=0, t=0.000000, pot=(16.868028,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(28.695987,0.000000) event=0, t=0.000000, pot=(28.695987,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(30.802444,0.000000) event=0, t=0.000000, pot=(30.802444,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(33.829234,0.000000) event=0, t=0.000000, pot=(33.829234,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(39.418635,0.000000) event=0, t=0.000000, pot=(39.418635,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(42.200572,0.000000) event=0, t=0.000000, pot=(42.200572,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(47.073620,0.000000) event=0, t=0.000000, pot=(47.073620,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(51.472271,0.000000) event=0, t=0.000000, pot=(51.472271,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(52.581093,0.000000) event=0, t=0.000000, pot=(52.581093,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(56.297169,0.000000) event=0, t=0.000000, pot=(56.297169,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(59.387128,0.000000) event=0, t=0.000000, pot=(59.387128,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(64.073258,0.000000) event=0, t=0.000000, pot=(64.073258,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(66.237036,0.000000) event=0, t=0.000000, pot=(66.237036,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(72.609808,0.000000) event=0, t=0.000000, pot=(72.609808,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(80.081198,0.000000) event=0, t=0.000000, pot=(80.081198,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(77.794111,0.000000) event=0, t=0.000000, pot=(77.794111,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(72.354091,0.000000) event=0, t=0.000000, pot=(72.354091,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(0.000000,0.000000) event=0, t=0.000000, pot=(0.000000,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(3.649974,0.000000) event=0, t=0.000000, pot=(3.649974,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(14.044389,0.000000) event=0, t=0.000000, pot=(14.044389,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(16.614915,0.000000) event=0, t=0.000000, pot=(16.614915,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(22.589453,0.000000) event=0, t=0.000000, pot=(22.589453,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(23.076663,0.000000) event=0, t=0.000000, pot=(23.076663,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(28.597234,0.000000) event=0, t=0.000000, pot=(28.597234,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(31.908205,0.000000) event=0, t=0.000000, pot=(31.908205,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(26.006400,0.000000) event=0, t=0.000000, pot=(26.006400,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(27.798922,0.000000) event=0, t=0.000000, pot=(27.798922,0.000000) Initializing simulation: max events=6, max time=inf, initial pot=(39.877427,0.000000) ``` -------------------------------- ### Install ergm.ego from CRAN Source: https://statnet.org/workshop-ergm-ego/ergm.ego_tutorial.R Use this command to install the ergm.ego package and all its required dependencies from the Comprehensive R Archive Network (CRAN). ```r install.packages('ergm.ego') ``` -------------------------------- ### Initialize and Run Network Simulation in R Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html Loads network data, sets simulation parameters like time step and transmission probability, initializes the rumor spread from a starting vertex, and then runs the simulation using the previously defined `runSim` function. Ensure the `networkDynamic` data object is loaded before executing. ```R data(windsurfers) # let's go to the beach! # set initial params... timeStep <- 1 # units are in days transProb <- 0.2 # how likely to tell in each conversation/day # start the rumor out on vertex 1 activate.vertex.attribute(windsurfers,"knowsRumor",TRUE,v=1, onset=0-timeStep,terminus=Inf) activate.vertex.attribute(windsurfers,"heardRumorFrom",1,v=1, onset=0-timeStep,length=timeStep) activate.edge.attribute(windsurfers,'passedRumor',value=FALSE, onset=-Inf,terminus=Inf) # run the sim! windsurfers<-runSim(windsurfers,timeStep,transProb) ``` -------------------------------- ### Access R Help Documentation Source: https://statnet.org/nme/d0-tutR.html Retrieves help documentation for a specific function or package in R. Use '?' or help(). ```r ?mean ``` ```r help("mean") ``` -------------------------------- ### Check R Library Path Source: https://statnet.org/install-statnet This command displays the location of your R library where packages are installed. Useful for verifying installation paths. ```r > .libPaths() ``` -------------------------------- ### Initialize Network Model Source: https://statnet.org/nme/d4-s5-Serosort.R Initializes a network model with a specified number of nodes. Use this to begin setting up network simulations. ```R n <- 500 nw <- network_initialize(n) ``` -------------------------------- ### Verify ergm.ego Package Version Source: https://statnet.org/workshop-ergm-ego/ergm.ego_tutorial.R Check the installed version of the ergm.ego package. This is useful for confirming a successful installation or ensuring compatibility with specific project requirements. ```r packageVersion('ergm.ego') ``` -------------------------------- ### Initialize Network and Set Up SIR Model Parameters Source: https://statnet.org/nme/d4-s9-SEIR.R This snippet initializes a network, defines formation and dissolution coefficients, sets up model parameters, initial conditions, and control settings for an SIR simulation. It is a foundational step for running network-based epidemic simulations with EpiModel. ```r nw <- network_initialize(n = 100) formation <- ~edges target.stats <- 50 coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 20) est1 <- netest(nw, formation, target.stats, coef.diss, verbose = FALSE) param <- param.net(inf.prob = 0.3, rec.rate = 0.1) init <- init.net(i.num = 10, r.num = 0) control <- control.net(type = "SIR", nsteps = 25, nsims = 1, verbose = FALSE) mod1 <- netsim(est1, param, init, control) ``` -------------------------------- ### Attach required packages Source: https://statnet.org/workshop-tergm/tergm_tutorial.R Loads the 'tergm', 'tsna', 'ndtv', 'htmlwidgets', and 'latticeExtra' packages into the current R session. ```R library(tergm) library(tsna) library(ndtv) library(htmlwidgets) library(latticeExtra) ``` -------------------------------- ### Initialize Network and Assign Attributes Source: https://statnet.org/workshop-advanced-ergm/advanced_ergm_tutorial.R Initializes an empty network of a specified size and assigns nodal attributes based on provided weights. This step prepares the network structure before fitting the ERGM. ```R set.seed(4321) net_size <- 50000 nw <- network.initialize(net_size, directed = FALSE) inds <- sample(seq_len(NROW(cohab_PopWts)), net_size, TRUE, cohab_PopWts$weight) set.vertex.attribute(nw, names(cohab_PopWts)[-1], cohab_PopWts[inds,-1]) ``` -------------------------------- ### Prepare Multilayer Network with Layer() (Method 2) Source: https://statnet.org/workshop-advanced-ergm/advanced_ergm_tutorial.R Create a multilayer network object by passing networks as named arguments to the Layer() function. This is a convenient way to combine networks when they are readily available. ```R # Method 2: networks as arguments flo <- Layer(m = flomarriage, b = flobusiness) ``` -------------------------------- ### Explore egor Object Example in R Source: https://statnet.org/workshop-ergm-ego/ergm.ego_tutorial.R Run the example for the 'egor' function to see a demonstration of its usage with alter-alter ties. This is useful for understanding more complex scenarios. ```r example("egor") ``` -------------------------------- ### Configure Network Simulation Control Settings Source: https://statnet.org/nme/d4-s5-Serosort.R Sets up control parameters for the simulation, including simulation type, number of steps and simulations, core usage, network resimulation, and monitoring statistics. Use 'tergmLite = TRUE' when individual-level network histories are not required. ```R control <- control.net(type = "SI", nsteps = 500, nsims = 5, ncores = 5, resimulate.network = TRUE, tergmLite = TRUE, nwstats.formula = ~edges + meandeg + nodefactor("status", levels = NULL) + nodematch("status")) ``` -------------------------------- ### Load Workshop Data in R Source: https://statnet.org/workshop-relevent-experiments/in_silico_experiments_tutorial.RData Loads the 'in_silico_experiments_tutorial.RData' file. Ensure the data file is in your current working directory or provide the correct path. ```R load("in_silico_experiments_tutorial.RData") ``` -------------------------------- ### Install and Load tsna Package Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html Installs the tsna package and its dependencies from CRAN, then loads it. This package is used for temporal SNA and will also load the sna and ergm packages. ```r install.packages('tsna',repos='http://cran.us.r-project.org', dependencies=TRUE) library(tsna) ``` -------------------------------- ### Install 'graph' Package from Bioconductor Source: https://statnet.org/workshop-intro-sna-tools Installs the 'graph' package using the 'remotes' package, which is necessary for certain network analysis functionalities. This command is specific to Bioconductor repositories. ```r remotes::install_bioc("graph") ``` -------------------------------- ### Initialize and Animate MDSJ Layout Source: https://statnet.org/workshop-ndtv/ndtv_workshop.html This snippet initializes a network and then animates it using the MDSJ layout algorithm. This action may trigger a prompt to download the MDSJ Java library if it's not already installed. ```r network.layout.animate.MDSJ(network.initialize(1)) ``` -------------------------------- ### Install ergm.ego from R-universe Source: https://statnet.org/workshop-ergm-ego/ergm.ego_tutorial.R Install the development version of ergm.ego from Statnet's R-universe repository, which may include newer features or bug fixes not yet available on CRAN. ```r install.packages( "ergm.ego", repos = c("https://statnet.r-universe.dev", "https://cloud.r-project.org") ) ``` -------------------------------- ### Initialize Network for Simulation Source: https://statnet.org/workshop-ergmgp/ergmgp_tutorial.R Creates a base network for simulation using `rgraph` and assigns random memberships to nodes. Ensure `set.seed` is used for reproducibility. ```R set.seed(1331) net <- network(rgraph(50, tp=1.5/49, mode="graph"), directed = FALSE) net %v% "x" <- sample(0:1, 50, replace = TRUE) ``` -------------------------------- ### ERGMP: Starting Maximum Pseudolikelihood Estimation (MPLE) Source: https://statnet.org/workshop-ergmgp/ergmgp_tutorial.R This output indicates the start of the Maximum Pseudolikelihood Estimation (MPLE) process for the ERGM model. It is a computational step in fitting the model. ```text Starting maximum pseudolikelihood estimation (MPLE): ``` -------------------------------- ### Initialize Network Conditions Source: https://statnet.org/nme/d4-s5-Serosort.R Creates an empty object for initial network conditions. The actual initial conditions are passed through the 'netest' object. ```R init <- init.net() ``` -------------------------------- ### Create a Dynamic Network with a Specified Start Time Source: https://statnet.org/workshop-tergm/tergm_tutorial.R Creates a networkDynamic object from a list of networks, explicitly setting the starting time to 1. This adjusts the temporal indexing of the network data. ```r samp.dyn <- networkDynamic(network.list = samp.list, start=1) ``` -------------------------------- ### Specify Initial Conditions for Epidemic Model Source: https://statnet.org/nme/d4-s9-SEIR.R Initializes the epidemic model by setting the number of infectious individuals at the start. For models starting with latent individuals, nodal attributes on the network should be used. ```R init <- init.net(i.num = 10) ``` -------------------------------- ### Plot Relational Durations Source: https://statnet.org/nme/d2-s8-TERGMs.R Visualizes the relational durations within the simulated network. Set duration.imputed to FALSE to exclude imputed starting dates for ties present at the simulation's start. ```R plot(sim1, type = "duration") ``` ```R plot(sim1, type = "duration", duration.imputed = FALSE) ``` -------------------------------- ### Example: Displaying Newcomb's Fraternity Data Source: https://statnet.org/workshop-valued/valued.R This example demonstrates how to load and display Newcomb's fraternity data as a matrix with rank attributes. It is useful for practicing with ordinal network data. ```R data(newcomb) as.matrix(newcomb[[1]], attrname = "rank") ``` -------------------------------- ### View ERGM Term Cross-Reference Guide Source: https://statnet.org/workshop-ergm/ergm_tutorial.R Access the cross-reference guide vignette to find tables summarizing keywords for terms, definitions, and a list of keywords with their corresponding terms. This provides a comprehensive overview. ```r vignette("ergm-term-crossRef") ``` -------------------------------- ### Get Structure of an R Object Source: https://statnet.org/nme/d0-tutR.html Use the `str()` function to get a concise summary of the internal structure of an R object, including data frames. Useful for understanding data types and dimensions. ```R str(h) ``` ```R 'data.frame': 10 obs. of 2 variables: $ id : int 1 2 3 4 5 6 7 8 9 10 $ sex: chr "Female" "Female" "Female" "Female" ... ``` -------------------------------- ### Prepare Multilayer Network with Layer() (Method 1) Source: https://statnet.org/workshop-advanced-ergm/advanced_ergm_tutorial.R Create a multilayer network object by passing a list of networks to the Layer() function. This method is useful when networks are already stored as a list. ```R data(florentine) # Method 1: list of networks flo <- Layer(list(m = flomarriage, b = flobusiness)) ``` -------------------------------- ### Initialize Network Parameters Source: https://statnet.org/nme/d5-s6-COVIDScreen.R Sets up age-specific mortality rates and age spans for network initialization. Mortality rates are converted to a daily probability. ```R ages <- 0:85 departure_rate <- c(588.45, 24.8, 11.7, 14.55, 47.85, 88.2, 105.65, 127.2, 154.3, 206.5, 309.3, 495.1, 736.85, 1051.15, 1483.45, 2294.15, 3642.95, 6139.4, 13938.3) dr_pp_pd <- departure_rate / 1e5 / 365 age_spans <- c(1, 4, rep(5, 16), 1) dr_vec <- rep(dr_pp_pd, times = age_spans) ``` -------------------------------- ### Set up Model Skeleton with Time-Varying Covariates Source: https://statnet.org/workshop-relevent/relevent_tutorial.html This code initializes a time-varying covariate and sets up the model skeleton. Note that covariates must be passed as static when creating the skeleton, as the model does not yet contain time points. ```R set.seed(1331) #Set up the model tcovar<-array(sweep(sapply(1:10,rep,100),1,1/1.05^(0:99),"*"),dim=c(100,10,1)) SndInt<-rep(1,10) #Note that, in making the skeleton, we need to pass the covariates as if #they are static - that's because the model doesn't contain time points yet. modskel2<-rem.dyad(NULL, n=10, effects=c("CovSnd", "CovInt"), coef.seed=c(-1,1), covar=list(CovSnd=SndInt, CovInt=tcovar[1,,1])) ``` -------------------------------- ### Calculate Network Metrics (Second Example) Source: https://statnet.org/COVID-JustOneFriend Calculates network metrics for the second combined network, similar to the first example. Use this to compare structural properties of networks generated with different ERGM specifications. ```R largcomp.comb.2 <- sum(component.largest(net.comb.2)) kpath.comb.2 <- sna:::kpath.census(net.comb.2)$path.count[3,'Agg']/2 ```