Learn R Programming

ergm (version 3.9.4)

network.update: Replace the sociomatrix in a network object

Description

Replaces the edges in a network object with the edges corresponding to the sociomatrix specified by newmatrix. See ergm for more information.

Usage

network.update(nw, newmatrix, matrix.type = NULL, output = "network",
  ignore.nattr = c("bipartite", "directed", "hyper", "loops", "mnext",
  "multiple", "n"), ignore.vattr = c())

Arguments

nw

a network object. See documentation for the network package.

newmatrix

Either an adjacency matrix (a matrix of zeros and ones indicating the presence of a tie from i to j) or an edgelist (a two-column matrix listing origin and destination node numbers for each edge; note that in an undirected matrix, the first column should be the smaller of the two numbers).

matrix.type

One of "adjacency" or "edgelist" telling which type of matrix newmatrix is. Default is to use the which.matrix.type function.

output

Currently unused.

ignore.nattr

character vector of the names of network-level attributes to ignore when updating network objects (defaults to standard network properties)

ignore.vattr

character vector of the names of vertex-level attributes to ignore when updating network objects

Value

network.update returns a new network object with the edges specified by newmatrix and network and vertex attributes copied from the input network nw. Input network is not modified.

See Also

ergm(), network

Examples

Run this code
# NOT RUN {
#
data(florentine)
#
# test the network.update function
#
# Create a Bernoulli network
rand.net <- network(network.size(flomarriage))
# store the sociomatrix 
rand.mat <- rand.net[,]
# Update the network
network.update(flomarriage, rand.mat, matrix.type="adjacency")
# Try this with an edgelist
rand.mat <- as.matrix.network.edgelist(flomarriage)[1:5,]
network.update(flomarriage, rand.mat, matrix.type="edgelist")

# }

Run the code above in your browser using DataLab