nwsync

Synchronize a network with Stata variables

Syntax

nwsync
[netname]
[,
label
fromstata]
   
label Sync the node labels
fromstata Change the direction of the sync

Description

Networks ultimately exist as Mata objects. However, one can also load them as Stata variables that represent the adjacency matrix of a network (see nwload). Normally, when a network is changed through another nwcommand the Stata variables (if they exist) are automatically synced. But one can also invoke such a sync explicitly. Furthermore, nwsync can be used to sync the other way around, i.e. one can change the values of the Stata variables that represent the network and sync the network (that lives in Mata).

Options

fromstata Change the direction of the sync, i.e. the network is updated based on the Stata variables that represent the network.

label Run an additional _nwdatasync alignment pass (matching node identity against _nwnode) before the normal variable sync below. There is no separate node-label concept or _nodelab variable in this package - a node’s name (see nwnoderename) is its only label, and this option does not sync it.

Remarks

One can use nwload and nwsync, fromstata to replace tie values in a network. For example,

. nwwebuse florentine, nwclear
. nwload flomarriage
. replace acciaiuoli = 99 in 2
. nwsync flomarriage, fromstata

However, the preferred method to change the same tie value would be using nwreplace instead:

. nwwebuse florentine, nwclear
. nwreplace flomarriage[2,1] = 99

Network types

The command works the same for every network type (see nwnetworktypes). Temporal: the variables of a temporal network hold its ties aggregated over all times. fromstata changes these ties only; the times (events, snapshots, intervals) stay as they were and the command warns that they may no longer match the ties.

See also


nwcommands version 3.25.0, 14 November 2026 (check your installed version)


Back to top

nwcommands is free software under the GNU General Public License, version 3, as are the model packages nwsaom, nwergm, nwdynam and nwrem. Citing and licenses · Get help · GitHub. Issues with the core go to the nwcommands repository; issues with a model package go to that package's own repository.

This site uses Just the Docs, a documentation theme for Jekyll.