R: Update the edges in a network based on a matrix

update.network {ergm} | R Documentation

## Update the edges in a network based on a matrix

### Description

Replaces the edges in a `network` object with the edges corresponding to the sociomatrix or edge list specified by `new`.

### Usage

    ## S3 method for class 'network'
    update(object, ...)

    update_network(object, new, ...)

    ## S3 method for class 'matrix_edgelist'
    update_network(object, new, attrname = if (ncol(new) > 2) names(new)[3], ...)

    ## S3 method for class 'data.frame'
    update_network(object, new, attrname = if (ncol(new) > 2) names(new)[3], ...)

    ## S3 method for class 'matrix'
    update_network(object, new, matrix.type = NULL, attrname = NULL, ...)

    ## S3 method for class 'ergm_state'
    update_network(object, new, ...)

### Arguments

`object` | a `network` object.
`...` | Additional arguments; currently unused.
`new` | Either an adjacency matrix (a matrix of values indicating the presence and/or the value of a tie from i to j) or an edge list (a two-column matrix listing origin and destination node numbers for each edge, with an optional third column for the value of the edge).
`attrname` | For a network with edge weights gives the name of the edge attribute whose names to set.
`matrix.type` | One of `"adjacency"` or `"edgelist"` telling which type of matrix `new` is. Default is to use the `which.matrix.type` function.

### Value

A new `network` object with the edges specified by `new` and network and vertex attributes copied from the input network `object`. Input network is not modified.

### Functions

- `update_network`: dispatcher for network update based on the type of updating information.

- `update_network.matrix_edgelist`: a method for updating a network based on a matrix-form edgelist

- `update_network.data.frame`: a method for updating a network based on an edgelist

- `update_network.matrix`: a method for updating a network based on a matrix

- `update_network.ergm_state`: a method for updating a network based on an `ergm_state` object.

### See Also

`ergm()`, `network`

### Examples

    #
    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
    update(flomarriage, rand.mat, matrix.type="adjacency")
    # Try this with an edgelist
    rand.mat <- as.matrix.network.edgelist(flomarriage)[1:5,]
    update(flomarriage, rand.mat, matrix.type="edgelist")

[Package ergm version 4.2.1 Index]