Learn R Programming

EpiModel (version 2.3.1)

networkLite: networkLite Constructor Utilities

Description

Constructor methods for networkLite objects.

Usage

networkLite(x, ...)

# S3 method for edgelist networkLite( x, attr = list(vertex.names = seq_len(attributes(x)[["n"]]), na = logical(attributes(x)[["n"]])), ... )

# S3 method for matrix networkLite( x, attr = list(vertex.names = seq_len(attributes(x)[["n"]]), na = logical(attributes(x)[["n"]])), ... )

# S3 method for numeric networkLite(x, directed = FALSE, bipartite = FALSE, ...)

networkLite_initialize(x, directed = FALSE, bipartite = FALSE, ...)

Value

A networkLite object with edge list el, vertex attributes attr, and network attributes gal.

Arguments

x

Either an edgelist class network representation (including network attributes in its attributes list), or a number specifying the network size.

...

Additional arguments used by other methods.

attr

A named list of vertex attributes for the network represented by x.

directed, bipartite

Common network attributes that may be set via arguments to the networkLite.numeric method.

Details

Currently there are several distinct networkLite constructor methods available.

The edgelist method takes an edgelist class object x with network attributes attached in its attributes list, and a named list of vertex attributes attr, and returns a networkLite object, which is a named list with fields el, attr, and gal; the fields el and attr match the arguments x and attr (the latter coerced to tibble) respectively, and the field gal is the list of network attributes (copied from attributes(x)). Missing network attributes directed and bipartite are defaulted to FALSE; the network size attribute n must not be missing. Attributes class, dim, dimnames, vnames, and mnext (if present) are not copied from x to the networkLite. (For convenience, a matrix method, identical to the edgelist method, is also defined, to handle cases where the edgelist is, for whatever reason, not classed as an edgelist.)

The numeric method takes a number x as well as the network attributes directed and bipartite (defaulting to FALSE), and returns an empty networkLite with these network attributes and number of nodes x.

The constructor networkLite_initialize is also available for creating an empty networkLite, and its x argument should be a number indicating the size of the networkLite to create.

Within tergmLite, the networkLite data structure is used in the calls to ergm and tergm simulate functions.

Examples

Run this code
if (FALSE) {
library("EpiModel")
nw <- network_initialize(100)
formation <- ~edges
target.stats <- 50
coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 20)
x <- netest(nw, formation, target.stats, coef.diss, verbose = FALSE)

param <- param.net(inf.prob = 0.3)
init <- init.net(i.num = 10)
control <- control.net(type = "SI", nsteps = 100, nsims = 5,
                       tergmLite = TRUE)

# networkLite representation after initialization
dat <- crosscheck.net(x, param, init, control)
dat <- initialize.net(x, param, init, control)

# Conversion to networkLite class format
nwl <- networkLite(dat$el[[1]], dat$attr)
nwl
}

Run the code above in your browser using DataLab